Change navigation

main
Laurent 3 years ago
parent 57e3895a99
commit b4ef494280
  1. 34
      LeCountdown/Views/ContentView.swift
  2. 38
      LeCountdown/Views/HomeView.swift
  3. 4
      LeCountdown/Views/Reusable/VolumeView.swift

@ -31,6 +31,8 @@ struct ContentView<T : AbstractTimer>: View {
@State private var siriTipShown: Bool = false @State private var siriTipShown: Bool = false
@State private var showSettingsSheet: Bool = false @State private var showSettingsSheet: Bool = false
@State private var showStatsSheet: Bool = false
@State private var showAddSheet: Bool = false
@State private var showSubscriptionSheet: Bool = false @State private var showSubscriptionSheet: Bool = false
@ -74,7 +76,7 @@ struct ContentView<T : AbstractTimer>: View {
SiriTimerView(timer: self.boringContext.siriTimer, isVisible: self.$siriTipShown) SiriTimerView(timer: self.boringContext.siriTimer, isVisible: self.$siriTipShown)
HStack(alignment: .center) { HStack(alignment: .center) {
VolumeView() VolumeView(changeVolume: true)
.padding(12.0) .padding(12.0)
}.frame(width: 300.0, height: 40.0) }.frame(width: 300.0, height: 40.0)
.background(Color(white: 0.9)) .background(Color(white: 0.9))
@ -86,7 +88,9 @@ struct ContentView<T : AbstractTimer>: View {
SiriTimerView(timer: self.boringContext.siriTimer, isVisible: self.$siriTipShown) SiriTimerView(timer: self.boringContext.siriTimer, isVisible: self.$siriTipShown)
Spacer() Spacer()
} }
VolumeView().padding(12.0).frame(width: 300.0, height: 40.0) VolumeView()
.padding(12.0)
.frame(width: 300.0, height: 40.0)
.background(Color(white: 0.9)) .background(Color(white: 0.9))
.cornerRadius(16.0) .cornerRadius(16.0)
}.padding(.horizontal) }.padding(.horizontal)
@ -118,6 +122,16 @@ struct ContentView<T : AbstractTimer>: View {
.sheet(isPresented: self.$showSubscriptionSheet, content: { .sheet(isPresented: self.$showSubscriptionSheet, content: {
StoreView(isPresented: self.$showSubscriptionSheet) StoreView(isPresented: self.$showSubscriptionSheet)
}) })
.sheet(isPresented: self.$showStatsSheet, content: {
NavigationStack {
ActivitiesView()
}
})
.sheet(isPresented: self.$showAddSheet, content: {
NavigationStack {
PresetsView(tabSelection: .constant(0))
}
})
.toolbar { .toolbar {
ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
Button { Button {
@ -128,7 +142,7 @@ struct ContentView<T : AbstractTimer>: View {
Text(self.isEditing ? "Done" : "Edit") Text(self.isEditing ? "Done" : "Edit")
} }
} }
ToolbarItem(placement: .navigationBarTrailing) { ToolbarItemGroup(placement: .navigationBarTrailing) {
Button { Button {
withAnimation { withAnimation {
self.showSettingsSheet.toggle() self.showSettingsSheet.toggle()
@ -136,6 +150,20 @@ struct ContentView<T : AbstractTimer>: View {
} label: { } label: {
Image(systemName: "gearshape.fill") Image(systemName: "gearshape.fill")
} }
Button {
withAnimation {
self.showAddSheet.toggle()
}
} label: {
Image(systemName: "plus")
}
Button {
withAnimation {
self.showStatsSheet.toggle()
}
} label: {
Image(systemName: "chart.bar.doc.horizontal")
}
} }
} }
.onAppear { .onAppear {

@ -24,23 +24,27 @@ struct CompactHomeView: View {
NavigationStack { NavigationStack {
TabView(selection: $tabSelection) { ContentView<AbstractTimer>()
PresetsView(tabSelection: $tabSelection) .environment(\.managedObjectContext, viewContext)
.environment(\.managedObjectContext, viewContext) .environmentObject(Conductor.maestro)
.tabItem { Label("Presets", systemImage: "globe") }
.tag(0) // TabView(selection: $tabSelection) {
ContentView<AbstractTimer>() // PresetsView(tabSelection: $tabSelection)
.environment(\.managedObjectContext, viewContext) // .environment(\.managedObjectContext, viewContext)
.environmentObject(Conductor.maestro) // .tabItem { Label("Presets", systemImage: "globe") }
.tabItem { Label("Home", systemImage: "clock.fill") } // .tag(0)
.tag(1) // ContentView<AbstractTimer>()
ActivitiesView() // .environment(\.managedObjectContext, viewContext)
.environment(\.managedObjectContext, viewContext) // .environmentObject(Conductor.maestro)
.tabItem { Label("Stats", systemImage: "chart.bar.fill") } // .tabItem { Label("Home", systemImage: "clock.fill") }
.tag(2) // .tag(1)
} // ActivitiesView()
.navigationBarTitleDisplayMode(NavigationBarItem.TitleDisplayMode.large) // .environment(\.managedObjectContext, viewContext)
.tabViewStyle(.page(indexDisplayMode: .never)) // .tabItem { Label("Stats", systemImage: "chart.bar.fill") }
// .tag(2)
// }
// .navigationBarTitleDisplayMode(NavigationBarItem.TitleDisplayMode.large)
// .tabViewStyle(.page(indexDisplayMode: .never))
} }
.onAppear { .onAppear {
if self.timers.count > 0 { if self.timers.count > 0 {

@ -19,7 +19,7 @@ struct VolumeView: UIViewRepresentable {
func makeUIView(context: Context) -> MPVolumeView { func makeUIView(context: Context) -> MPVolumeView {
let volumeView = MPVolumeView(frame: .zero) let volumeView = MPVolumeView(frame: .zero)
volumeView.isHidden = self.changeVolume // volumeView.isHidden = self.changeVolume
if self.changeVolume { if self.changeVolume {
self._setVolume(volumeView: volumeView) self._setVolume(volumeView: volumeView)
@ -39,7 +39,7 @@ struct VolumeView: UIViewRepresentable {
if let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider { if let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.01) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.01) {
// Logger.log("update volume view") Logger.log("update volume view to \(Preferences.defaultVolume)")
slider.setValue(Preferences.defaultVolume, animated: false) slider.setValue(Preferences.defaultVolume, animated: false)
} }

Loading…
Cancel
Save