-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use property wrappers to have settings in a nice way. now it's the on…
…ly place for settings key
- Loading branch information
1 parent
c4928ee
commit cd2ec3d
Showing
5 changed files
with
56 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Foundation | ||
|
||
struct AppSettings { | ||
@UserDefault(key: "com.toxblh.mtmr.settings.showControlStrip", defaultValue: false) | ||
static var showControlStripState: Bool | ||
|
||
@UserDefault(key: "com.toxblh.mtmr.settings.hapticFeedback", defaultValue: true) | ||
static var hapticFeedbackState: Bool | ||
|
||
@UserDefault(key: "com.toxblh.mtmr.settings.multitouchGestures", defaultValue: true) | ||
static var multitouchGestures: Bool | ||
|
||
@UserDefault(key: "com.toxblh.mtmr.blackListedApps", defaultValue: []) | ||
static var blacklistedAppIds: [String] | ||
} | ||
|
||
@propertyWrapper | ||
struct UserDefault<T> { | ||
let key: String | ||
let defaultValue: T | ||
var wrappedValue: T { | ||
get { | ||
return UserDefaults.standard.object(forKey: key) as? T ?? defaultValue | ||
} | ||
set { | ||
UserDefaults.standard.set(newValue, forKey: key) | ||
UserDefaults.standard.synchronize() | ||
} | ||
} | ||
} |
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