Skip to content

Commit b0e7e3e

Browse files
authored
Merge pull request #7 from Kyome22/swift-concurrency
Migration: Swift Concurrency & Observation
2 parents 9cbe626 + fcda416 commit b0e7e3e

25 files changed

+571
-345
lines changed

ShiftWindow.xcodeproj/project.pbxproj

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1C1461D626BC1629006442F5 /* ShortcutPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1461D526BC1629006442F5 /* ShortcutPanel.swift */; };
1313
1C80700E2880684900A12D56 /* ShortcutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C80700D2880684900A12D56 /* ShortcutView.swift */; };
1414
1C8070102880713000A12D56 /* ShortcutSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C80700F2880713000A12D56 /* ShortcutSettingsViewModel.swift */; };
15+
1CA357832C84488C00E853EC /* PreActionButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA357822C84488C00E853EC /* PreActionButtonStyle.swift */; };
16+
1CA357862C844CF600E853EC /* AsyncAlgorithms in Frameworks */ = {isa = PBXBuildFile; productRef = 1CA357852C844CF600E853EC /* AsyncAlgorithms */; };
17+
1CA3578A2C84B60800E853EC /* ExecuteModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA357892C84B60800E853EC /* ExecuteModel.swift */; };
18+
1CA3578C2C8C244A00E853EC /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA3578B2C8C244A00E853EC /* SettingsViewModel.swift */; };
1519
1CAB3F162AE7E7CC00BE23F0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 1CAB3F152AE7E7CC00BE23F0 /* Localizable.xcstrings */; };
1620
1CAB3F182AE7EE7F00BE23F0 /* MenuViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAB3F172AE7EE7F00BE23F0 /* MenuViewModel.swift */; };
1721
1CAB3F1A2AE7F26C00BE23F0 /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAB3F192AE7F26C00BE23F0 /* MenuView.swift */; };
@@ -54,6 +58,9 @@
5458
1C1461D526BC1629006442F5 /* ShortcutPanel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutPanel.swift; sourceTree = "<group>"; };
5559
1C80700D2880684900A12D56 /* ShortcutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutView.swift; sourceTree = "<group>"; };
5660
1C80700F2880713000A12D56 /* ShortcutSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutSettingsViewModel.swift; sourceTree = "<group>"; };
61+
1CA357822C84488C00E853EC /* PreActionButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreActionButtonStyle.swift; sourceTree = "<group>"; };
62+
1CA357892C84B60800E853EC /* ExecuteModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExecuteModel.swift; sourceTree = "<group>"; };
63+
1CA3578B2C8C244A00E853EC /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
5764
1CAB3F152AE7E7CC00BE23F0 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
5865
1CAB3F172AE7EE7F00BE23F0 /* MenuViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewModel.swift; sourceTree = "<group>"; };
5966
1CAB3F192AE7F26C00BE23F0 /* MenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuView.swift; sourceTree = "<group>"; };
@@ -83,6 +90,7 @@
8390
buildActionMask = 2147483647;
8491
files = (
8592
1C0D29ED26AEFC6900DD0690 /* SpiceKey in Frameworks */,
93+
1CA357862C844CF600E853EC /* AsyncAlgorithms in Frameworks */,
8694
);
8795
runOnlyForDeploymentPostprocessing = 0;
8896
};
@@ -147,6 +155,7 @@
147155
1CC92D092869EFBC00D46424 /* ShortcutSettingsView.swift */,
148156
1C1461D526BC1629006442F5 /* ShortcutPanel.swift */,
149157
1C80700D2880684900A12D56 /* ShortcutView.swift */,
158+
1CA357822C84488C00E853EC /* PreActionButtonStyle.swift */,
150159
);
151160
path = View;
152161
sourceTree = "<group>";
@@ -156,6 +165,7 @@
156165
children = (
157166
1CF137F726B565CC00E2147E /* ShiftModel.swift */,
158167
1CC6C1152980072700D89250 /* ShortcutModel.swift */,
168+
1CA357892C84B60800E853EC /* ExecuteModel.swift */,
159169
);
160170
path = Model;
161171
sourceTree = "<group>";
@@ -164,9 +174,10 @@
164174
isa = PBXGroup;
165175
children = (
166176
1CC6C14A2985065500D89250 /* WindowModel.swift */,
167-
1CAB3F172AE7EE7F00BE23F0 /* MenuViewModel.swift */,
177+
1CA3578B2C8C244A00E853EC /* SettingsViewModel.swift */,
168178
1CC92D012869EED200D46424 /* GeneralSettingsViewModel.swift */,
169179
1C80700F2880713000A12D56 /* ShortcutSettingsViewModel.swift */,
180+
1CAB3F172AE7EE7F00BE23F0 /* MenuViewModel.swift */,
170181
);
171182
path = ViewModel;
172183
sourceTree = "<group>";
@@ -229,6 +240,7 @@
229240
name = ShiftWindow;
230241
packageProductDependencies = (
231242
1C0D29EC26AEFC6900DD0690 /* SpiceKey */,
243+
1CA357852C844CF600E853EC /* AsyncAlgorithms */,
232244
);
233245
productName = ShiftWindow;
234246
productReference = 1C0D29D626AEFBDA00DD0690 /* ShiftWindow.app */;
@@ -242,7 +254,7 @@
242254
attributes = {
243255
BuildIndependentTargetsInParallel = YES;
244256
LastSwiftUpdateCheck = 1250;
245-
LastUpgradeCheck = 1500;
257+
LastUpgradeCheck = 1540;
246258
TargetAttributes = {
247259
1C0D29D526AEFBDA00DD0690 = {
248260
CreatedOnToolsVersion = 12.5.1;
@@ -261,6 +273,7 @@
261273
mainGroup = 1C0D29CD26AEFBDA00DD0690;
262274
packageReferences = (
263275
1C0D29EB26AEFC6900DD0690 /* XCRemoteSwiftPackageReference "SpiceKey" */,
276+
1CA357842C844CF600E853EC /* XCRemoteSwiftPackageReference "swift-async-algorithms" */,
264277
);
265278
productRefGroup = 1C0D29D726AEFBDA00DD0690 /* Products */;
266279
projectDirPath = "";
@@ -303,11 +316,14 @@
303316
1C80700E2880684900A12D56 /* ShortcutView.swift in Sources */,
304317
1CC6C14B2985065500D89250 /* WindowModel.swift in Sources */,
305318
1CC92CFF2869ED8200D46424 /* AppKit+Extensions.swift in Sources */,
319+
1CA357832C84488C00E853EC /* PreActionButtonStyle.swift in Sources */,
306320
1CC6C10E297F6B8000D89250 /* SettingsTabType.swift in Sources */,
307321
1CF1380426B5947800E2147E /* ShiftPattern.swift in Sources */,
308322
1CC6C10A297F64EE00D89250 /* Utils.swift in Sources */,
309323
1CC92CFD2869ED5A00D46424 /* CoreGraphics+Extensions.swift in Sources */,
310324
1C1461D626BC1629006442F5 /* ShortcutPanel.swift in Sources */,
325+
1CA3578C2C8C244A00E853EC /* SettingsViewModel.swift in Sources */,
326+
1CA3578A2C84B60800E853EC /* ExecuteModel.swift in Sources */,
311327
1CAB3F182AE7EE7F00BE23F0 /* MenuViewModel.swift in Sources */,
312328
1CC92D062869EF3D00D46424 /* SettingsView.swift in Sources */,
313329
1C8070102880713000A12D56 /* ShortcutSettingsViewModel.swift in Sources */,
@@ -321,6 +337,7 @@
321337
isa = XCBuildConfiguration;
322338
buildSettings = {
323339
ALWAYS_SEARCH_USER_PATHS = NO;
340+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
324341
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
325342
CLANG_ANALYZER_NONNULL = YES;
326343
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -373,20 +390,23 @@
373390
GCC_WARN_UNUSED_VARIABLE = YES;
374391
GENERATE_INFOPLIST_FILE = NO;
375392
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
376-
MACOSX_DEPLOYMENT_TARGET = 13.0;
393+
MACOSX_DEPLOYMENT_TARGET = 14.0;
377394
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
378395
MTL_FAST_MATH = YES;
379396
ONLY_ACTIVE_ARCH = YES;
380397
SDKROOT = macosx;
381398
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
382399
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
400+
SWIFT_STRICT_CONCURRENCY = complete;
401+
SWIFT_VERSION = 5.0;
383402
};
384403
name = Debug;
385404
};
386405
1C0D29E526AEFBDC00DD0690 /* Release */ = {
387406
isa = XCBuildConfiguration;
388407
buildSettings = {
389408
ALWAYS_SEARCH_USER_PATHS = NO;
409+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
390410
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
391411
CLANG_ANALYZER_NONNULL = YES;
392412
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -433,13 +453,15 @@
433453
GCC_WARN_UNUSED_VARIABLE = YES;
434454
GENERATE_INFOPLIST_FILE = NO;
435455
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
436-
MACOSX_DEPLOYMENT_TARGET = 13.0;
456+
MACOSX_DEPLOYMENT_TARGET = 14.0;
437457
MTL_ENABLE_DEBUG_INFO = NO;
438458
MTL_FAST_MATH = YES;
439459
SDKROOT = macosx;
440460
SWIFT_ACTIVE_COMPILATION_CONDITIONS = RELEASE;
441461
SWIFT_COMPILATION_MODE = wholemodule;
442462
SWIFT_OPTIMIZATION_LEVEL = "-O";
463+
SWIFT_STRICT_CONCURRENCY = complete;
464+
SWIFT_VERSION = 5.0;
443465
};
444466
name = Release;
445467
};
@@ -452,7 +474,7 @@
452474
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
453475
CODE_SIGN_STYLE = Automatic;
454476
COMBINE_HIDPI_IMAGES = YES;
455-
CURRENT_PROJECT_VERSION = 2.7.0;
477+
CURRENT_PROJECT_VERSION = 2.8.0;
456478
DEAD_CODE_STRIPPING = YES;
457479
DEVELOPMENT_TEAM = VJ5N2X84K8;
458480
ENABLE_HARDENED_RUNTIME = YES;
@@ -464,7 +486,7 @@
464486
"$(inherited)",
465487
"@executable_path/../Frameworks",
466488
);
467-
MARKETING_VERSION = 2.7;
489+
MARKETING_VERSION = 2.8;
468490
PRODUCT_BUNDLE_IDENTIFIER = com.kyome.ShiftWindow;
469491
PRODUCT_NAME = "$(TARGET_NAME)";
470492
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -481,7 +503,7 @@
481503
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
482504
CODE_SIGN_STYLE = Automatic;
483505
COMBINE_HIDPI_IMAGES = YES;
484-
CURRENT_PROJECT_VERSION = 2.7.0;
506+
CURRENT_PROJECT_VERSION = 2.8.0;
485507
DEAD_CODE_STRIPPING = YES;
486508
DEVELOPMENT_TEAM = VJ5N2X84K8;
487509
ENABLE_HARDENED_RUNTIME = YES;
@@ -493,7 +515,7 @@
493515
"$(inherited)",
494516
"@executable_path/../Frameworks",
495517
);
496-
MARKETING_VERSION = 2.7;
518+
MARKETING_VERSION = 2.8;
497519
PRODUCT_BUNDLE_IDENTIFIER = com.kyome.ShiftWindow;
498520
PRODUCT_NAME = "$(TARGET_NAME)";
499521
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -530,7 +552,15 @@
530552
repositoryURL = "https://github.com/Kyome22/SpiceKey.git";
531553
requirement = {
532554
kind = exactVersion;
533-
version = 5.0.0;
555+
version = 5.4.1;
556+
};
557+
};
558+
1CA357842C844CF600E853EC /* XCRemoteSwiftPackageReference "swift-async-algorithms" */ = {
559+
isa = XCRemoteSwiftPackageReference;
560+
repositoryURL = "https://github.com/apple/swift-async-algorithms.git";
561+
requirement = {
562+
kind = exactVersion;
563+
version = 1.0.1;
534564
};
535565
};
536566
/* End XCRemoteSwiftPackageReference section */
@@ -541,6 +571,11 @@
541571
package = 1C0D29EB26AEFC6900DD0690 /* XCRemoteSwiftPackageReference "SpiceKey" */;
542572
productName = SpiceKey;
543573
};
574+
1CA357852C844CF600E853EC /* AsyncAlgorithms */ = {
575+
isa = XCSwiftPackageProductDependency;
576+
package = 1CA357842C844CF600E853EC /* XCRemoteSwiftPackageReference "swift-async-algorithms" */;
577+
productName = AsyncAlgorithms;
578+
};
544579
/* End XCSwiftPackageProductDependency section */
545580
};
546581
rootObject = 1C0D29CE26AEFBDA00DD0690 /* Project object */;

ShiftWindow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 22 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ShiftWindow.xcodeproj/xcshareddata/xcschemes/ShiftWindow.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1500"
3+
LastUpgradeVersion = "1540"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ShiftWindow/Data/Entity/SettingsTabType.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@
1818
limitations under the License.
1919
*/
2020

21+
import SwiftUI
22+
2123
enum SettingsTabType {
2224
case general
2325
case shortcuts
2426
}
27+
28+
struct SettingsTabTypeKey: EnvironmentKey {
29+
static let defaultValue: Binding<SettingsTabType> = .constant(.general)
30+
}
31+
32+
extension EnvironmentValues {
33+
var settingsTab: Binding<SettingsTabType> {
34+
get { self[SettingsTabTypeKey.self] }
35+
set { self[SettingsTabTypeKey.self] = newValue }
36+
}
37+
}

ShiftWindow/Data/Entity/ShiftPattern.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import SwiftUI
2222
import SpiceKey
2323

24-
struct ShiftPattern: Codable, Identifiable {
24+
struct ShiftPattern: Codable, Identifiable, Sendable {
2525
enum CodingKeys: String, CodingKey {
2626
case shiftType
2727
case spiceKeyData
@@ -31,26 +31,26 @@ struct ShiftPattern: Codable, Identifiable {
3131
var spiceKeyData: SpiceKeyData?
3232

3333
var id: ShiftType {
34-
return shiftType
34+
shiftType
3535
}
36-
var titleKey: LocalizedStringKey {
37-
return shiftType.titleKey
36+
var label: String {
37+
shiftType.label
3838
}
3939
var imageResource: ImageResource {
40-
return shiftType.imageResource
40+
shiftType.imageResource
4141
}
4242
var keyEquivalent: KeyEquivalent? {
43-
return spiceKeyData?.key?.keyEquivalent
43+
spiceKeyData?.key?.keyEquivalent
4444
}
4545
var eventModifiers: EventModifiers? {
46-
return spiceKeyData?.modifierFlags?.eventModifiers
46+
spiceKeyData?.modifierFlags?.eventModifiers
4747
}
4848
var keyCombination: KeyCombination? {
49-
return spiceKeyData?.keyCombination
49+
spiceKeyData?.keyCombination
5050
}
5151
var description: String {
5252
let str = spiceKeyData?.keyCombination?.string ?? "nil"
53-
return "type: \(titleKey), spiceKeyData: \(str)"
53+
return "type: \(label), spiceKeyData: \(str)"
5454
}
5555

5656
init(shiftType: ShiftType) {

ShiftWindow/Data/Entity/ShiftType.swift

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,36 @@ enum ShiftType: Int, Codable, Identifiable, CaseIterable {
3333
case rightThird
3434
case maximize
3535

36-
var id: String {
37-
switch self {
38-
case .topHalf: return "shiftTopHalf"
39-
case .bottomHalf: return "shiftBottomHalf"
40-
case .leftHalf: return "shiftLeftHalf"
41-
case .rightHalf: return "shiftRighthalf"
42-
case .leftThird: return "shiftLeftThird"
43-
case .leftTwoThirds: return "shiftLeftTwoThirds"
44-
case .middleThird: return "shiftMiddleThird"
45-
case .rightTwoThirds: return "shiftRightThirds"
46-
case .rightThird: return "shiftRightThird"
47-
case .maximize: return "shiftMaximize"
36+
var id: String { String(describing: self) }
37+
38+
var label: String {
39+
let localizationValue: String.LocalizationValue = switch self {
40+
case .topHalf: "shiftTopHalf"
41+
case .bottomHalf: "shiftBottomHalf"
42+
case .leftHalf: "shiftLeftHalf"
43+
case .rightHalf: "shiftRighthalf"
44+
case .leftThird: "shiftLeftThird"
45+
case .leftTwoThirds: "shiftLeftTwoThirds"
46+
case .middleThird: "shiftMiddleThird"
47+
case .rightTwoThirds: "shiftRightThirds"
48+
case .rightThird: "shiftRightThird"
49+
case .maximize: "shiftMaximize"
4850
}
49-
}
50-
51-
var titleKey: LocalizedStringKey {
52-
return LocalizedStringKey(id)
51+
return String(localized: localizationValue)
5352
}
5453

5554
var imageResource: ImageResource {
5655
switch self {
57-
case .topHalf: return .windowTopHalf
58-
case .bottomHalf: return .windowBottomHalf
59-
case .leftHalf: return .windowLeftHalf
60-
case .rightHalf: return .windowRightHalf
61-
case .leftThird: return .windowLeftThird
62-
case .leftTwoThirds: return .windowLeftTwoThirds
63-
case .middleThird: return .windowMiddleThird
64-
case .rightTwoThirds: return .windowRightTwoThirds
65-
case .rightThird: return .windowRightThird
66-
case .maximize: return .windowMaximize
56+
case .topHalf: .windowTopHalf
57+
case .bottomHalf: .windowBottomHalf
58+
case .leftHalf: .windowLeftHalf
59+
case .rightHalf: .windowRightHalf
60+
case .leftThird: .windowLeftThird
61+
case .leftTwoThirds: .windowLeftTwoThirds
62+
case .middleThird: .windowMiddleThird
63+
case .rightTwoThirds: .windowRightTwoThirds
64+
case .rightThird: .windowRightThird
65+
case .maximize: .windowMaximize
6766
}
6867
}
6968
}

0 commit comments

Comments
 (0)