Files
kontakte/Kontakte/ContactsAccessView.swift

72 lines
2.0 KiB
Swift

import Contacts
import ContactsUI
import SwiftUI
struct ContactsAccessView: View {
@ObservedObject var viewModel: ContactsViewModel
@State private var isPickerPresented = false
var body: some View {
VStack(spacing: 20) {
Image(systemName: "person.crop.circle.badge.checkmark")
.font(.system(size: 64))
.foregroundStyle(.blue)
VStack(spacing: 8) {
Text("contacts.access_title")
.font(.title2.weight(.semibold))
Text("contacts.access_subtitle")
.font(.body)
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
}
Button("contacts.access_full") {
viewModel.requestAccess()
}
.buttonStyle(.borderedProminent)
Button("contacts.access_select") {
isPickerPresented = true
}
.buttonStyle(.bordered)
Button("contacts.not_now") {
viewModel.refresh()
}
.foregroundStyle(.secondary)
}
.padding(24)
.contactAccessPicker(isPresented: $isPickerPresented) { _ in
viewModel.refresh()
}
}
}
struct ContactsAccessDeniedView: View {
let onOpenSettings: () -> Void
var body: some View {
VStack(spacing: 20) {
Image(systemName: "person.crop.circle.badge.xmark")
.font(.system(size: 64))
.foregroundStyle(.red)
VStack(spacing: 8) {
Text("contacts.access_off_title")
.font(.title2.weight(.semibold))
Text("contacts.access_off_subtitle")
.font(.body)
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
}
Button("contacts.open_settings") {
onOpenSettings()
}
.buttonStyle(.borderedProminent)
}
.padding(24)
}
}