|
|
|
|
@ -15,40 +15,47 @@ struct DialView: View { |
|
|
|
|
@EnvironmentObject var conductor: Conductor |
|
|
|
|
|
|
|
|
|
@State var timer: AbstractTimer |
|
|
|
|
var isEditingBinding: Binding<Bool> |
|
|
|
|
|
|
|
|
|
var frameSize: CGFloat |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
ZStack(alignment: .topLeading) { |
|
|
|
|
ZStack { |
|
|
|
|
|
|
|
|
|
Image(timer.imageName).resizable() |
|
|
|
|
|
|
|
|
|
Button { |
|
|
|
|
self._launchTimer(timer) |
|
|
|
|
} label: { |
|
|
|
|
self._dialView(timer: timer).padding() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HStack { |
|
|
|
|
Spacer() |
|
|
|
|
NavigationLink { |
|
|
|
|
self._editView(timer: timer, isPresented: $boringContext.isShowingNewData) |
|
|
|
|
switch self.isEditingBinding.wrappedValue { |
|
|
|
|
case false: |
|
|
|
|
Button { |
|
|
|
|
self._launchTimer() |
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "gearshape.fill") |
|
|
|
|
.font(.system(size: 24, weight: .light)) |
|
|
|
|
.padding() |
|
|
|
|
.foregroundColor(Color.white) |
|
|
|
|
self._dialView().padding() |
|
|
|
|
} |
|
|
|
|
case true: |
|
|
|
|
self._dialView().padding() |
|
|
|
|
|
|
|
|
|
VStack { |
|
|
|
|
Spacer() |
|
|
|
|
NavigationLink { |
|
|
|
|
self._editView(timer: timer, isPresented: $boringContext.isShowingNewData) |
|
|
|
|
} label: { |
|
|
|
|
Image(systemName: "gearshape.fill") |
|
|
|
|
.font(.system(size: 50.0)) |
|
|
|
|
.padding(30.0) |
|
|
|
|
.foregroundColor(Color.white) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
.frame(width: frameSize, height: frameSize) |
|
|
|
|
.cornerRadius(40.0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
fileprivate func _dialView(timer: AbstractTimer) -> some View { |
|
|
|
|
fileprivate func _dialView() -> some View { |
|
|
|
|
Group { |
|
|
|
|
switch timer { |
|
|
|
|
switch self.timer { |
|
|
|
|
case let countdown as Countdown: |
|
|
|
|
CountdownDialView(countdown: countdown) |
|
|
|
|
.environmentObject(Conductor.maestro) |
|
|
|
|
@ -81,9 +88,9 @@ struct DialView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _launchTimer(_ timer: AbstractTimer) { |
|
|
|
|
fileprivate func _launchTimer() { |
|
|
|
|
|
|
|
|
|
TimerRouter.performAction(timer: timer) { result in |
|
|
|
|
TimerRouter.performAction(timer: self.timer) { result in |
|
|
|
|
switch result { |
|
|
|
|
case .success: |
|
|
|
|
break |
|
|
|
|
@ -107,10 +114,9 @@ struct DialView_Previews: PreviewProvider { |
|
|
|
|
|
|
|
|
|
DialView( |
|
|
|
|
timer: Countdown.fake(context: PersistenceController.preview.container.viewContext), |
|
|
|
|
frameSize: 150.0) |
|
|
|
|
isEditingBinding: .constant(false), frameSize: 150.0) |
|
|
|
|
.environmentObject(Conductor.maestro) |
|
|
|
|
.environmentObject(BoringContext()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|