-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gated and refactored code to get the Localization export to work corr…
…ectly
- Loading branch information
1 parent
63229c4
commit dfa124b
Showing
48 changed files
with
444 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// AppKitDefaults.swift | ||
// AppKitPlugin | ||
// | ||
// Created by Maurice Parker on 1/6/24. | ||
// | ||
|
||
import Foundation | ||
|
||
enum UserInterfaceColorPalette: Int, CustomStringConvertible, CaseIterable { | ||
case automatic = 0 | ||
case light = 1 | ||
case dark = 2 | ||
|
||
var description: String { | ||
switch self { | ||
case .automatic: | ||
return String(localized: "Automatic", comment: "Control Label: Automatic") | ||
case .light: | ||
return String(localized: "Light", comment: "Control Label: Light") | ||
case .dark: | ||
return String(localized: "Dark", comment: "Control Label: Dark") | ||
} | ||
} | ||
} | ||
|
||
final class AppDefaults { | ||
|
||
static let shared = AppDefaults() | ||
private init() {} | ||
|
||
static var store: UserDefaults = { | ||
let appIdentifierPrefix = Bundle.main.object(forInfoDictionaryKey: "AppIdentifierPrefix") as! String | ||
let suiteName = "\(appIdentifierPrefix)group.\(Bundle.main.bundleIdentifier!)" | ||
return UserDefaults.init(suiteName: suiteName)! | ||
}() | ||
|
||
struct Key { | ||
static let userInterfaceColorPalette = "userInterfaceColorPalette"; | ||
} | ||
|
||
var userInterfaceColorPalette: UserInterfaceColorPalette { | ||
get { | ||
if let result = UserInterfaceColorPalette(rawValue: Self.int(for: Key.userInterfaceColorPalette)) { | ||
return result | ||
} | ||
return .automatic | ||
} | ||
set { | ||
Self.setInt(for: Key.userInterfaceColorPalette, newValue.rawValue) | ||
} | ||
} | ||
|
||
} | ||
|
||
// MARK: Helpers | ||
|
||
private extension AppDefaults { | ||
|
||
static func string(for key: String) -> String? { | ||
return AppDefaults.store.string(forKey: key) | ||
} | ||
|
||
static func setString(for key: String, _ value: String?) { | ||
AppDefaults.store.set(value, forKey: key) | ||
} | ||
|
||
static func bool(for key: String) -> Bool { | ||
return AppDefaults.store.bool(forKey: key) | ||
} | ||
|
||
static func setBool(for key: String, _ flag: Bool) { | ||
AppDefaults.store.set(flag, forKey: key) | ||
} | ||
|
||
static func int(for key: String) -> Int { | ||
return AppDefaults.store.integer(forKey: key) | ||
} | ||
|
||
static func setInt(for key: String, _ x: Int) { | ||
AppDefaults.store.set(x, forKey: key) | ||
} | ||
|
||
static func date(for key: String) -> Date? { | ||
return AppDefaults.store.object(forKey: key) as? Date | ||
} | ||
|
||
static func setDate(for key: String, _ date: Date?) { | ||
AppDefaults.store.set(date, forKey: key) | ||
} | ||
|
||
static func data(for key: String) -> Data? { | ||
return AppDefaults.store.object(forKey: key) as? Data | ||
} | ||
|
||
static func setData(for key: String, _ data: Data?) { | ||
AppDefaults.store.set(data, forKey: key) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"sourceLanguage" : "en", | ||
"strings" : { | ||
"%@ was moved or renamed while open." : { | ||
"comment" : "Message text for app moved while running alert" | ||
}, | ||
"Automatic" : { | ||
"comment" : "Control Label: Automatic" | ||
}, | ||
"Dark" : { | ||
"comment" : "Control Label: Dark" | ||
}, | ||
"Light" : { | ||
"comment" : "Control Label: Light" | ||
}, | ||
"Moving an open application can cause unexpected behavior. Manually relaunch the application to continue." : { | ||
"comment" : "Informative text for app moved while running alert" | ||
}, | ||
"Open Quickly" : { | ||
"comment" : "Window Title: Open Quickly" | ||
}, | ||
"Terminate" : { | ||
"comment" : "Relaunch Button" | ||
}, | ||
"This app" : { | ||
"comment" : "Backup name if the app name cannot be deduced from the bundle" | ||
} | ||
}, | ||
"version" : "1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.