implement settings
This commit is contained in:
@@ -53,6 +53,7 @@ class ContentViewModel: ObservableObject {
|
||||
struct ContentView: View {
|
||||
@StateObject private var viewModel = ContentViewModel()
|
||||
@State private var isShowingAddSheet = false
|
||||
@State private var isShowingSettings = false
|
||||
@State private var selectedStopwatch: Stopwatch?
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
@@ -78,6 +79,13 @@ struct ContentView: View {
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("MultiChrono")
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Button {
|
||||
isShowingSettings = true
|
||||
} label: {
|
||||
Image(systemName: "gearshape")
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(action: {
|
||||
isShowingAddSheet = true
|
||||
@@ -92,6 +100,9 @@ struct ContentView: View {
|
||||
isShowingAddSheet = false
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $isShowingSettings) {
|
||||
SettingsView()
|
||||
}
|
||||
.sheet(item: $selectedStopwatch) { stopwatch in
|
||||
StopwatchDetailView(
|
||||
stopwatch: stopwatch,
|
||||
@@ -115,6 +126,7 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.onChange(of: scenePhase) { newPhase in
|
||||
if newPhase == .background || newPhase == .inactive {
|
||||
viewModel.save()
|
||||
|
||||
Reference in New Issue
Block a user