diff --git a/LeCountdown.xcodeproj/project.pbxproj b/LeCountdown.xcodeproj/project.pbxproj index 7546fab..315609c 100644 --- a/LeCountdown.xcodeproj/project.pbxproj +++ b/LeCountdown.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ C415D3F729C378D10037B215 /* QP01 0037 Tropical forest morning.wav in Resources */ = {isa = PBXBuildFile; fileRef = C415D3F629C378D10037B215 /* QP01 0037 Tropical forest morning.wav */; }; C415D3FB29C37A460037B215 /* QP01 0096 Wetland lake early morning.wav in Resources */ = {isa = PBXBuildFile; fileRef = C415D3FA29C37A460037B215 /* QP01 0096 Wetland lake early morning.wav */; }; C415D3FD29C37AA40037B215 /* QP01 0118 Riparian Zone thrush.wav in Resources */ = {isa = PBXBuildFile; fileRef = C415D3FC29C37AA40037B215 /* QP01 0118 Riparian Zone thrush.wav */; }; + C419EEE52AC5AC0200A66BBB /* ViewStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C419EEE42AC5AC0200A66BBB /* ViewStyles.swift */; }; C4286E962A14EC4E0070D075 /* AppError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4286E952A14EC4E0070D075 /* AppError.swift */; }; C4286EA12A1502FD0070D075 /* Stopwatch+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4286E9F2A1502FD0070D075 /* Stopwatch+CoreDataClass.swift */; }; C4286EA32A1503320070D075 /* Stopwatch+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4286E9F2A1502FD0070D075 /* Stopwatch+CoreDataClass.swift */; }; @@ -379,6 +380,7 @@ C415D3FA29C37A460037B215 /* QP01 0096 Wetland lake early morning.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "QP01 0096 Wetland lake early morning.wav"; sourceTree = ""; }; C415D3FC29C37AA40037B215 /* QP01 0118 Riparian Zone thrush.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "QP01 0118 Riparian Zone thrush.wav"; sourceTree = ""; }; C418A14F298428CB00C22230 /* LeCountdown.0.1.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LeCountdown.0.1.xcdatamodel; sourceTree = ""; }; + C419EEE42AC5AC0200A66BBB /* ViewStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewStyles.swift; sourceTree = ""; }; C4286E952A14EC4E0070D075 /* AppError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppError.swift; sourceTree = ""; }; C4286E9F2A1502FD0070D075 /* Stopwatch+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Stopwatch+CoreDataClass.swift"; sourceTree = ""; }; C4286EA52A150A7E0070D075 /* TimePickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimePickerView.swift; sourceTree = ""; }; @@ -973,6 +975,7 @@ C4BA2B2E299E69A000CB4FBA /* View+Extension.swift */, C4742B5E2984205000D5D950 /* ViewModifiers.swift */, C4E5D67929B8C5A1008E7465 /* VolumeView.swift */, + C419EEE42AC5AC0200A66BBB /* ViewStyles.swift */, ); path = Reusable; sourceTree = ""; @@ -1279,6 +1282,7 @@ C4742B5F2984205000D5D950 /* ViewModifiers.swift in Sources */, C4F8B1D8298C0727005C86A5 /* TimerRouter.swift in Sources */, C4BA2B13299BE61E00CB4FBA /* Countdown+CoreDataProperties.swift in Sources */, + C419EEE52AC5AC0200A66BBB /* ViewStyles.swift in Sources */, C4F8B186298AC234005C86A5 /* Activity+CoreDataClass.swift in Sources */, C4BA2B57299FFA4F00CB4FBA /* AppGuard.swift in Sources */, C4F8B15729891271005C86A5 /* Conductor.swift in Sources */, diff --git a/LeCountdown/Views/Countdown/CountdownDialView.swift b/LeCountdown/Views/Countdown/CountdownDialView.swift index 4fb8bd4..a88bf53 100644 --- a/LeCountdown/Views/Countdown/CountdownDialView.swift +++ b/LeCountdown/Views/Countdown/CountdownDialView.swift @@ -7,7 +7,7 @@ import SwiftUI -struct CountdownDialView: View { +struct CountdownDialView: View, DialStyle { @EnvironmentObject var conductor: Conductor @Environment(\.colorScheme) var colorScheme @@ -19,7 +19,10 @@ struct CountdownDialView: View { var body: some View { HStack { - VStack(alignment: .leading) { + if UIDevice.isPadIdiom { + Spacer() + } + VStack(alignment: self.dialAlignment) { Text(countdown.activity?.name?.uppercased() ?? "") .foregroundColor(self._titleColor) .multilineTextAlignment(.leading) @@ -28,7 +31,7 @@ struct CountdownDialView: View { .foregroundColor(self._durationColor) } Spacer() - } + }.font(.system(size: self.dialFontSize)) } private var _titleColor: Color { diff --git a/LeCountdown/Views/DialView.swift b/LeCountdown/Views/DialView.swift index bbb91fb..b13ec36 100644 --- a/LeCountdown/Views/DialView.swift +++ b/LeCountdown/Views/DialView.swift @@ -65,11 +65,16 @@ struct DialView: View { } } - }.background(self._dialBackgroundColor) - .frame(width: frameSize, height: 80.0) + } + .background(self._dialBackgroundColor) + .frame(width: frameSize, height: self._height) .cornerRadius(20.0) } + fileprivate var _height: CGFloat { + return UIDevice.isPhoneIdiom ? 80.0 : 200.0 + } + private var _dialBackgroundColor: Color { let darkMode = self.colorScheme == .dark let isEditing = self.isEditingBinding.wrappedValue diff --git a/LeCountdown/Views/Reusable/ViewStyles.swift b/LeCountdown/Views/Reusable/ViewStyles.swift new file mode 100644 index 0000000..87f2a00 --- /dev/null +++ b/LeCountdown/Views/Reusable/ViewStyles.swift @@ -0,0 +1,24 @@ +// +// ViewStyles.swift +// LeCountdown +// +// Created by Laurent Morvillier on 28/09/2023. +// + +import Foundation +import UIKit +import SwiftUI + +protocol DialStyle { } + +extension DialStyle { + + var dialFontSize: CGFloat { + return UIDevice.isPhoneIdiom ? 17.0 : 24.0 + } + + var dialAlignment: HorizontalAlignment { + return UIDevice.isPhoneIdiom ? .leading : .center + } + +} diff --git a/LeCountdown/Views/Stopwatch/StopwatchDialView.swift b/LeCountdown/Views/Stopwatch/StopwatchDialView.swift index cce7405..a4de1b5 100644 --- a/LeCountdown/Views/Stopwatch/StopwatchDialView.swift +++ b/LeCountdown/Views/Stopwatch/StopwatchDialView.swift @@ -7,7 +7,7 @@ import SwiftUI -struct StopwatchDialView: View { +struct StopwatchDialView: View, DialStyle { @EnvironmentObject var conductor: Conductor @Environment(\.colorScheme) var colorScheme @@ -18,7 +18,12 @@ struct StopwatchDialView: View { var body: some View { HStack { - Text(stopwatch.activity?.name?.uppercased() ?? "").foregroundColor(self._titleColor) + if UIDevice.isPadIdiom { + Spacer() + } + Text(stopwatch.activity?.name?.uppercased() ?? "") + .foregroundColor(self._titleColor) + .font(.system(size: self.dialFontSize)) Spacer() } }