Skip to content

Commit

Permalink
General improvements and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LEOYoon-Tsaw committed Sep 24, 2023
1 parent 5b9f10a commit 485ede1
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 117 deletions.
8 changes: 4 additions & 4 deletions Chinese Time.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1440,8 +1440,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APP_BUILD = 95;
APP_VERSION = 5.0;
APP_BUILD = 97;
APP_VERSION = 5.0.1;
ASSETCATALOG_COMPILER_APPICON_NAME = "";
ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOL_FRAMEWORKS = SwiftUI;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
Expand Down Expand Up @@ -1520,8 +1520,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APP_BUILD = 95;
APP_VERSION = 5.0;
APP_BUILD = 97;
APP_VERSION = 5.0.1;
ASSETCATALOG_COMPILER_APPICON_NAME = "";
ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOL_FRAMEWORKS = SwiftUI;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,4 @@
uuid = "17FF20B8-95CE-4A9A-9D52-A57C1B74571D"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "63122D00-D169-4540-BF7A-28DE42B812B6"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Watch/Views/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B798E9F8-1428-42D7-9E03-B171655AF133"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Shared/HoverView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "136"
endingLineNumber = "136"
landmarkName = "body"
landmarkType = "24">
<Locations>
<Location
uuid = "B798E9F8-1428-42D7-9E03-B171655AF133 - 22b60f4c57031cd1"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 (SwiftUI.GeometryProxy) -&gt; Swift.Optional&lt;SwiftUI._ConditionalContent&lt;&lt;&lt;opaque return type of SwiftUI.View.onPreferenceChange&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.PreferenceKey, &#x3c4;_1_0.Value: Swift.Equatable&gt;(_: &#x3c4;_1_0.Type, perform: (&#x3c4;_1_0.Value) -&gt; ()) -&gt; some&gt;&gt;.0, &lt;&lt;opaque return type of SwiftUI.View.onPreferenceChange&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.PreferenceKey, &#x3c4;_1_0.Value: Swift.Equatable&gt;(_: &#x3c4;_1_0.Type, perform: (&#x3c4;_1_0.Value) -&gt; ()) -&gt; some&gt;&gt;.0&gt;&gt; in Chinese_Time.Hover.body.getter : some"
moduleName = "Chinese Time"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/leo/Library/Mobile%20Documents/com~apple~CloudDocs/Codes/ChineseTime/Shared/HoverView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "133"
endingLineNumber = "133"
offsetFromSymbolStart = "3104">
</Location>
<Location
uuid = "B798E9F8-1428-42D7-9E03-B171655AF133 - 34d9e55738e60b43"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #6 (__C.CGRect) -&gt; () in closure #1 (SwiftUI.GeometryProxy) -&gt; Swift.Optional&lt;SwiftUI._ConditionalContent&lt;&lt;&lt;opaque return type of SwiftUI.View.onPreferenceChange&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.PreferenceKey, &#x3c4;_1_0.Value: Swift.Equatable&gt;(_: &#x3c4;_1_0.Type, perform: (&#x3c4;_1_0.Value) -&gt; ()) -&gt; some&gt;&gt;.0, &lt;&lt;opaque return type of SwiftUI.View.onPreferenceChange&lt;&#x3c4;_0_0 where &#x3c4;_1_0: SwiftUI.PreferenceKey, &#x3c4;_1_0.Value: Swift.Equatable&gt;(_: &#x3c4;_1_0.Type, perform: (&#x3c4;_1_0.Value) -&gt; ()) -&gt; some&gt;&gt;.0&gt;&gt; in Chinese_Time.Hover.body.getter : some"
moduleName = "Chinese Time"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/leo/Library/Mobile%20Documents/com~apple~CloudDocs/Codes/ChineseTime/Shared/HoverView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "133"
endingLineNumber = "133"
offsetFromSymbolStart = "76">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "F206FBE9-9E0F-4B36-9020-A0270F9C7398"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Shared/WatchFaceBasics.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "233"
endingLineNumber = "233"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "75FD7F5E-B3DF-47EB-A22B-CDC07AB353AB"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Shared/WatchFaceView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "213"
endingLineNumber = "213"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
3 changes: 3 additions & 0 deletions Shared/DataModel/MetaLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ extension String {
}
}

@ObservationIgnored var initialized = false
var globalMonth: Bool = false
var apparentTime: Bool = false
var locationEnabled: Bool = true
Expand Down Expand Up @@ -342,6 +343,8 @@ extension String {
}
}

initialized = true

globalMonth = values["globalMonth"]?.boolValue ?? globalMonth
apparentTime = values["apparentTime"]?.boolValue ?? apparentTime
locationEnabled = values["locationEnabled"]?.boolValue ?? locationEnabled
Expand Down
2 changes: 1 addition & 1 deletion Shared/DataModel/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ extension Array {
static let dayTimeName = ["夜中", "日出", "日中", "日入"]
static let moonTimeName = ["月出", "月中", "月入"]
static let moonPhases = ["", ""]
static let holidays = ["正月一日": "元旦", "正月十五": "上元", "三月三日": "上巳", "五月五日": "端午", "七月七日": "七夕", "七月十五": "中元", "九月九日": "重陽", "八月十五": "中秋", "冬月十五": "下元", "大年三十": "除夕"]
static let holidays = ["正月一日": "元旦", "正月十五": "上元", "三月三日": "上巳", "五月五日": "端午", "七月七日": "七夕", "七月十五": "中元", "九月九日": "重陽", "八月十五": "中秋", "十月十五": "下元", "大年三十": "除夕"]
static let start: Date = {
var components = DateComponents()
components.year = 1901
Expand Down
25 changes: 18 additions & 7 deletions Shared/Setting/LayoutSetting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct LayoutSettingCell<V: Numeric>: View {
let validation: ((V) -> V)?
let completion: (() -> Void)?
@State var tempValue: V
@FocusState var isFocused: Bool

init(text: Text, value: Binding<V>, validation: ((V) -> V)? = nil, completion: (() -> Void)? = nil) {
self.text = text
Expand All @@ -34,14 +35,14 @@ struct LayoutSettingCell<V: Numeric>: View {
formatter.minimumFractionDigits = 0
return formatter
}())
.focused($isFocused)
.autocorrectionDisabled()
.onSubmit {
if let validation = validation {
tempValue = validation(tempValue)
}
value = tempValue
if let completion = completion {
completion()
.onSubmit(of: .text) {
commit()
}
.onChange(of: isFocused) { _, newValue in
if !newValue {
commit()
}
}
.task {
Expand All @@ -61,6 +62,16 @@ struct LayoutSettingCell<V: Numeric>: View {
.padding(.trailing, 10)
}
}

func commit() {
if let validation = validation {
tempValue = validation(tempValue)
}
value = tempValue
if let completion = completion {
completion()
}
}
}

#if os(macOS)
Expand Down
9 changes: 8 additions & 1 deletion Shared/Setting/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ struct OnSubmitTextField<V: Numeric>: View {
let formatter: NumberFormatter
@Binding var value: V
@State var tempValue: V
@FocusState var isFocused: Bool

init(_ title: LocalizedStringKey, value: Binding<V>, formatter: NumberFormatter) {
self.title = title
Expand All @@ -155,9 +156,15 @@ struct OnSubmitTextField<V: Numeric>: View {

var body: some View {
TextField(title, value: $tempValue, formatter: formatter)
.onSubmit {
.focused($isFocused)
.onSubmit(of: .text) {
value = tempValue
}
.onChange(of: isFocused) { _, newValue in
if !newValue {
value = tempValue
}
}
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Shared/Setting/ThemesList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ struct ThemesList: View {
if let target = target, !target.isNil {
watchLayout.update(from: target.code!)
#if os(iOS)
let _ = WatchConnectivityManager.shared.sendLayout(watchLayout.encode(includeOffset: false))
WatchConnectivityManager.shared.sendLayout(watchLayout.encode(includeOffset: false))
#elseif os(macOS)
if let delegate = AppDelegate.instance {
delegate.update()
Expand Down
11 changes: 7 additions & 4 deletions Shared/WatchConnectivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ final class WatchConnectivityManager: NSObject, WCSessionDelegate {
func session(_ session: WCSession, didReceiveMessage message: [String: Any]) {
if let newLayout = message["layout"] as? String {
#if os(watchOS)
Task(priority: .userInitiated) {
let modelContext = ThemeData.context
Task(priority: .background) {
let watchLayout = WatchLayout.shared
watchLayout.update(from: newLayout)
LocationManager.shared.enabled = watchLayout.locationEnabled
let modelContext = ThemeData.context
watchLayout.saveDefault(context: modelContext)
try? modelContext.save()
LocationManager.shared.enabled = watchLayout.locationEnabled
}
#endif
} else if let request = message["request"] as? String, request == "layout" {
#if os(iOS)
self.sendLayout(WatchLayout.shared.encode(includeOffset: false))
let watchLayout = WatchLayout.shared
if watchLayout.initialized {
sendLayout(watchLayout.encode(includeOffset: false))
}
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion Watch/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct WatchFaceTab<Tab: View>: View {
Setting()
}
}
.tabViewStyle(VerticalPageTabViewStyle(transitionStyle: .identity))
.tabViewStyle(VerticalPageTabViewStyle(transitionStyle: .blur))
.onAppear {
watchSetting.size = proxy.size
}
Expand Down

0 comments on commit 485ede1

Please sign in to comment.