Created
May 13, 2021 15:04
-
-
Save christianselig/430f677b8269024a93ec71224745957a to your computer and use it in GitHub Desktop.
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
struct Setting { | |
enum SettingIcon { | |
case system(name: String) | |
case custom(name: String) | |
} | |
enum SettingType: Equatable { | |
case toggle | |
case menu(settings: [MenuSetting]) | |
case viewController(creationBlock: (() -> UIViewController)) | |
static func ==(lhs: SettingType, rhs: SettingType) -> Bool { | |
switch (lhs, rhs) { | |
case (.toggle, .toggle): | |
return true | |
case (.menu(let settings1), .menu(let settings2)): | |
return settings1 == settings2 | |
case (.viewController, .viewController): | |
// Always assume two view controller creation blocks are inequal for simplicity | |
return false | |
default: | |
return false | |
} | |
} | |
} | |
let title: String | |
let key: String | |
let icon: SettingIcon | |
let type: SettingType | |
} | |
struct MenuSetting: Equatable { | |
let title: String | |
let isChecked: Bool | |
} | |
var settings: [Setting] = [ | |
Setting(title: "Dogs Can Fly", key: "DogsCanFly", icon: .system(name: "airplane"), type: .toggle), | |
Setting(title: "Dog Name", key: "DogName", icon: .system(name: "textformat"), type: .menu(settings: [ | |
MenuSetting(title: "Rover", isChecked: true), | |
MenuSetting(title: "Phyllis", isChecked: false), | |
MenuSetting(title: "Rosetta", isChecked: false), | |
MenuSetting(title: "Bartholimeu", isChecked: false), | |
])) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment