feat: yangshi

This commit is contained in:
jinyaqiu 2025-09-03 15:43:52 +08:00
parent b1cd957d0c
commit 55255bf0f8

View File

@ -26,19 +26,23 @@ struct PermissionManagementView: View {
// 1. // 1.
PermissionRow( PermissionRow(
title: "Gallery Permissions", title: "Gallery Permissions",
isEnabled: photoLibraryStatus == .authorized isEnabled: photoLibraryStatus == .authorized,
) { action: {
requestPhotoLibraryPermission() requestPhotoLibraryPermission()
} },
openSettings: openAppSettings
)
.background(Color.white) .background(Color.white)
// 2. // 2.
PermissionRow( PermissionRow(
title: "Notification Permissions", title: "Notification Permissions",
isEnabled: notificationStatus == .authorized isEnabled: notificationStatus == .authorized,
) { action: {
requestNotificationPermission() requestNotificationPermission()
} },
openSettings: openAppSettings
)
.background(Color.white) .background(Color.white)
} }
.background(Color.white) .background(Color.white)
@ -122,9 +126,11 @@ struct PermissionManagementView: View {
/// ///
private func openAppSettings() { private func openAppSettings() {
if let url = URL(string: UIApplication.openSettingsURLString) { guard let settingsUrl = URL(string: UIApplication.openSettingsURLString),
UIApplication.shared.open(url) UIApplication.shared.canOpenURL(settingsUrl) else {
return
} }
UIApplication.shared.open(settingsUrl)
} }
} }
@ -133,6 +139,14 @@ struct PermissionRow: View {
let title: String // let title: String //
let isEnabled: Bool // let isEnabled: Bool //
let action: () -> Void // let action: () -> Void //
let openSettings: () -> Void //
init(title: String, isEnabled: Bool, action: @escaping () -> Void, openSettings: @escaping () -> Void) {
self.title = title
self.isEnabled = isEnabled
self.action = action
self.openSettings = openSettings
}
var body: some View { var body: some View {
Button(action: action) { Button(action: action) {
@ -145,10 +159,15 @@ struct PermissionRow: View {
Spacer() Spacer()
// //
Toggle("", isOn: .constant(isEnabled)) Toggle("", isOn: .init(
get: { isEnabled },
set: { newValue in
//
openSettings()
}
))
.labelsHidden() .labelsHidden()
.tint(Color.themePrimary) .tint(Color.themePrimary)
.disabled(true)
.onAppear { .onAppear {
// 使 // 使
let themeColor = UIColor(Color.themePrimary) let themeColor = UIColor(Color.themePrimary)