Contents

familyActivityPicker(isPresented:selection:)

Presents an activity picker view as a sheet.

Declaration

@MainActor @preconcurrency func familyActivityPicker(isPresented: Binding<Bool>, selection: Binding<FamilyActivitySelection>) -> some View

Parameters

  • isPresented:

    A binding that indicates whether the app presents the picker view.

  • selection:

    A binding that manages the user-selected categories, apps, and web domains.

Discussion

Use this view modifier to present a FamilyControls/FamilyActivityPicker.

struct ExampleView: View {
    @State var selection = FamilyActivitySelection()
    @State var isPresented = false

   var body: some View {
       Button("Present FamilyActivityPicker") { isPresented = true }
       .familyActivityPicker(isPresented: $isPresented,
                             selection: $selection)
       .onChange(of: selection) { newSelection in
           let applications = selection.applications
           let categories = selection.categories
           let webDomains = selection.webDomains
       }
   }
}

See Also

Configuring Family Sharing