-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
141 additions
and
344 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
import SwiftUI | ||
|
||
extension AppStorageKey where Value == Bool { | ||
public static let enableCubeShadow = Self(key: "enableCubeShadow", defaultValue: true) | ||
public static let showSceneStatistics = Self(key: "showSceneStatistics", defaultValue: false) | ||
extension _AppStorageKey where Value == Bool { | ||
public static let enableCubeShadow = _AppStorageKey(key: "enableCubeShadow", defaultValue: true) | ||
public static let showSceneStatistics = _AppStorageKey(key: "showSceneStatistics", defaultValue: false) | ||
} | ||
|
||
public struct AppStorageKey<Value> { | ||
public struct _AppStorageKey<Value> { | ||
public let key: String | ||
public let defaultValue: Value | ||
} | ||
|
||
extension AppStorage { | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Bool { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Bool { | ||
self.init(wrappedValue: key.defaultValue, key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Int { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Int { | ||
self.init(wrappedValue: key.defaultValue, key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Double { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Double { | ||
self.init(wrappedValue: key.defaultValue, key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == String { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == String { | ||
self.init(wrappedValue: key.defaultValue, key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Data { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Data { | ||
self.init(wrappedValue: key.defaultValue, key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) | ||
where Value: RawRepresentable, Value.RawValue == Int { | ||
self.init(wrappedValue: key.defaultValue, key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) | ||
where Value: RawRepresentable, Value.RawValue == String { | ||
self.init(wrappedValue: key.defaultValue, key.key, store: store) | ||
} | ||
} | ||
|
||
extension AppStorage where Value: ExpressibleByNilLiteral { | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Bool? { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Bool? { | ||
self.init(key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Int? { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Int? { | ||
self.init(key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Double? { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Double? { | ||
self.init(key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == String? { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == String? { | ||
self.init(key.key, store: store) | ||
} | ||
public init(_ key: AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Data? { | ||
public init(_ key: _AppStorageKey<Value>, store: UserDefaults? = nil) where Value == Data? { | ||
self.init(key.key, store: store) | ||
} | ||
} |
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,22 @@ | ||
import ComposableArchitecture | ||
|
||
extension PersistenceKey where Self == AppStorageKey<Double> { | ||
public static var installationTime: Self { | ||
appStorage("installationTimeKey") | ||
} | ||
} | ||
extension PersistenceKey where Self == AppStorageKey<Bool> { | ||
public static var hasShownFirstLaunchOnboarding: Self { | ||
AppStorageKey("hasShownFirstLaunchOnboardingKey") | ||
} | ||
} | ||
extension PersistenceKey where Self == AppStorageKey<Int> { | ||
public static var multiplayerOpensCount: Self { | ||
AppStorageKey("multiplayerOpensCount") | ||
} | ||
} | ||
extension PersistenceKey where Self == AppStorageKey<Double> { | ||
public static var lastReviewRequest: Self { | ||
AppStorageKey("last-review-request-timeinterval") | ||
} | ||
} |
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.