Parcourir la source

use AnyView instead of String for verboseHints in Notification Views

also add Defaults to verboseHints and exchange `\n\n` for a new `Text()`
Mike Plante il y a 1 an
Parent
commit
18b59d88e4

Fichier diff supprimé car celui-ci est trop grand
+ 42 - 8
FreeAPS/Sources/Modules/GlucoseNotificationSettings/View/GlucoseNotificationSettingsRootView.swift


+ 25 - 12
FreeAPS/Sources/Modules/Settings/View/Subviews/NotificationsView.swift

@@ -17,8 +17,14 @@ struct NotificationsView: BaseView {
     @State var showAlert = false
     @State var showAlert = false
     @State private var shouldDisplayHint: Bool = false
     @State private var shouldDisplayHint: Bool = false
     @State var hintDetent = PresentationDetent.large
     @State var hintDetent = PresentationDetent.large
-    @State var selectedVerboseHint: String? =
-        "Notifications give you important Trio information without requiring you to open the app.\n\nKeep these turned ON in your phone’s settings to ensure you receive Trio Notifications, Critical Alerts, and Time Sensitive Notifications."
+    @State var selectedVerboseHint: AnyView? = AnyView(
+        VStack(alignment: .leading, spacing: 10) {
+            Text("Notifications give you important Trio information without requiring you to open the app.")
+            Text(
+                "Keep these turned ON in your phone’s settings to ensure you receive Trio Notifications, Critical Alerts, and Time Sensitive Notifications."
+            )
+        }
+    )
     @State var hintLabel: String? = "Manage iOS Preferences"
     @State var hintLabel: String? = "Manage iOS Preferences"
 
 
     @Environment(\.colorScheme) var colorScheme
     @Environment(\.colorScheme) var colorScheme
@@ -40,7 +46,7 @@ struct NotificationsView: BaseView {
     }
     }
 
 
     var body: some View {
     var body: some View {
-        Form {
+        List {
             Section(
             Section(
                 header: Text("Manage iOS Preferences"),
                 header: Text("Manage iOS Preferences"),
                 content: {
                 content: {
@@ -51,18 +57,24 @@ struct NotificationsView: BaseView {
                 VStack {
                 VStack {
                     notificationsEnabledStatus
                     notificationsEnabledStatus
                     HStack(alignment: .top) {
                     HStack(alignment: .top) {
-                        Text(
-                            "Notifications give you important Trio information without requiring you to open the app."
-                        )
-                        .font(.footnote)
-                        .foregroundColor(.secondary)
-                        .lineLimit(nil)
+                        Text("Notifications give you important Trio information without requiring you to open the app.")
+                            .font(.footnote)
+                            .foregroundColor(.secondary)
+                            .lineLimit(nil)
                         Spacer()
                         Spacer()
                         Button(
                         Button(
                             action: {
                             action: {
                                 hintLabel = "Manage iOS Preferences"
                                 hintLabel = "Manage iOS Preferences"
-                                selectedVerboseHint =
-                                    "Notifications give you important Trio information without requiring you to open the app.\n\nKeep these turned ON in your phone’s settings to ensure you receive Trio Notifications, Critical Alerts, and Time Sensitive Notifications."
+                                selectedVerboseHint = AnyView(
+                                    VStack(alignment: .leading, spacing: 10) {
+                                        Text(
+                                            "Notifications give you important Trio information without requiring you to open the app."
+                                        )
+                                        Text(
+                                            "Keep these turned ON in your phone’s settings to ensure you receive Trio Notifications, Critical Alerts, and Time Sensitive Notifications."
+                                        )
+                                    }
+                                )
                                 shouldDisplayHint.toggle()
                                 shouldDisplayHint.toggle()
                             },
                             },
                             label: {
                             label: {
@@ -89,6 +101,7 @@ struct NotificationsView: BaseView {
             )
             )
             .listRowBackground(Color.chart)
             .listRowBackground(Color.chart)
         }
         }
+        .listSectionSpacing(sectionSpacing)
         .onReceive(
         .onReceive(
             resolver.resolve(AlertPermissionsChecker.self)!.$notificationsDisabled,
             resolver.resolve(AlertPermissionsChecker.self)!.$notificationsDisabled,
             perform: {
             perform: {
@@ -109,7 +122,7 @@ struct NotificationsView: BaseView {
                 hintDetent: $hintDetent,
                 hintDetent: $hintDetent,
                 shouldDisplayHint: $shouldDisplayHint,
                 shouldDisplayHint: $shouldDisplayHint,
                 hintLabel: hintLabel ?? "",
                 hintLabel: hintLabel ?? "",
-                hintText: selectedVerboseHint ?? "",
+                hintText: selectedVerboseHint ?? AnyView(EmptyView()),
                 sheetTitle: "Help"
                 sheetTitle: "Help"
             )
             )
         }
         }