Przeglądaj źródła

use swipe action instead of button

ejm0 2 dni temu
rodzic
commit
785dcbd32c
1 zmienionych plików z 17 dodań i 7 usunięć
  1. 17 7
      Trio/Sources/Views/SnoozeAlertsSheetView.swift

+ 17 - 7
Trio/Sources/Views/SnoozeAlertsSheetView.swift

@@ -17,7 +17,7 @@ struct SnoozeAlertsSheetView: View {
         NavigationStack {
             List {
                 if snoozeUntilDate > Date() {
-                    Section {
+                    Section(footer: Text("Swipe left or right to end snooze.")) {
                         HStack {
                             Image(systemName: "moon.zzz.fill").foregroundStyle(.tint)
                             Text(String(
@@ -26,13 +26,14 @@ struct SnoozeAlertsSheetView: View {
                             ))
                                 .font(.headline)
                         }
-                        Button {
-                            endSnooze()
-                        } label: {
-                            Text("End Snooze")
-                                .foregroundColor(.red)
+                        .swipeActions(edge: .leading, allowsFullSwipe: true) {
+                            endSnoozeAction
                         }
-                    }.listRowBackground(Color.chart)
+                        .swipeActions(edge: .trailing, allowsFullSwipe: true) {
+                            endSnoozeAction
+                        }
+                    }
+                    .listRowBackground(Color.chart)
                 }
                 Section(footer: Text(
                     "Pick a duration to mute every Trio alarm. Critical alerts (e.g. occlusion, urgent low) still pierce the snooze."
@@ -68,6 +69,15 @@ struct SnoozeAlertsSheetView: View {
         }
     }
 
+    private var endSnoozeAction: some View {
+        Button(role: .destructive) {
+            endSnooze()
+        } label: {
+            Text("End Snooze")
+        }
+        .tint(.red)
+    }
+
     private func applySnooze(_ duration: TimeInterval) {
         let trioAlertManager = resolver.resolve(TrioAlertManager.self)
         Task { @MainActor in