Native SwiftUI CNContactViewController replacement
Default list, without custom row layout
import SwiftUIContactPicker
@State var selectedContact: PhoneContact?
@State var viewModel: ContactPickerViewModel = ContactPickerViewModel(store:
@State var showSheet: Bool = false
private var cpConfig = ContactPickerConfiguration.default
var body: some View {
Text("Choose a contact")
.onTapGesture {
showSheet.toggle()
}
.sheet(isPresented: $showSheet, content: {
ContactPickerView(viewModel: viewModel,
config: cpConfig,
selectedContact: $selectedContact,
onCancel: {
showSheet = false
})
})
.onChange(of: selectedContact) { selected in
guard let selectedContact = selected else { return }
print("selected=\(selectedContact.name ?? "")")
}
}
- The "Groups" button not implemented. It's possible that will be removed/hidden because I don't need it for now.
- Missing "index bar" (letters on the right side)