diff options
| author | Christian Cleberg <[email protected]> | 2026-03-18 20:03:39 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-03-18 20:03:39 -0500 |
| commit | 090c829a5f800266da7f4ff0e59fb389f0dbfdd8 (patch) | |
| tree | 8861ac737cf90f38a740f9f7ce913f192585af2a /Hutch/Views/Tickets/TrackerListView.swift | |
| parent | 01ce5ee73feb8bda35749a186c0efcd3d6d7a060 (diff) | |
| download | hutch-090c829a5f800266da7f4ff0e59fb389f0dbfdd8.tar.gz hutch-090c829a5f800266da7f4ff0e59fb389f0dbfdd8.tar.bz2 hutch-090c829a5f800266da7f4ff0e59fb389f0dbfdd8.zip | |
show tracker creation errors inside the creation sheet
Diffstat (limited to 'Hutch/Views/Tickets/TrackerListView.swift')
| -rw-r--r-- | Hutch/Views/Tickets/TrackerListView.swift | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Hutch/Views/Tickets/TrackerListView.swift b/Hutch/Views/Tickets/TrackerListView.swift index d16246b..ee253ec 100644 --- a/Hutch/Views/Tickets/TrackerListView.swift +++ b/Hutch/Views/Tickets/TrackerListView.swift @@ -124,10 +124,17 @@ private struct CreateTrackerSheet: View { let onCreated: (TrackerSummary) -> Void @Environment(\.dismiss) private var dismiss + @Bindable var viewModelBindable: TrackerListViewModel @State private var name = "" @State private var description = "" @State private var visibility: Visibility = .public + init(viewModel: TrackerListViewModel, onCreated: @escaping (TrackerSummary) -> Void) { + self.viewModel = viewModel + self._viewModelBindable = Bindable(viewModel) + self.onCreated = onCreated + } + var body: some View { NavigationStack { Form { @@ -143,12 +150,30 @@ private struct CreateTrackerSheet: View { Text("Private").tag(Visibility.private) } } + + if let error = viewModel.error { + Section { + Label { + Text(error) + } icon: { + Image(systemName: "exclamationmark.triangle.fill") + .foregroundStyle(.red) + } + .foregroundStyle(.red) + } + } } .navigationTitle("New Tracker") .navigationBarTitleDisplayMode(.inline) + .onDisappear { + viewModelBindable.error = nil + } .toolbar { ToolbarItem(placement: .cancellationAction) { - Button("Cancel") { dismiss() } + Button("Cancel") { + viewModelBindable.error = nil + dismiss() + } } ToolbarItem(placement: .confirmationAction) { Button { |
