{"id":15055317,"url":"https://github.com/aheze/setting","last_synced_at":"2025-04-07T23:13:08.745Z","repository":{"id":77697139,"uuid":"605208069","full_name":"aheze/Setting","owner":"aheze","description":"Compose beautiful preference panels.","archived":false,"fork":false,"pushed_at":"2024-04-08T10:16:46.000Z","size":16361,"stargazers_count":1608,"open_issues_count":28,"forks_count":67,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-07T23:12:58.252Z","etag":null,"topics":["ios","preferences","settings","swift","swiftui"],"latest_commit_sha":null,"homepage":"https://twitter.com/aheze0/status/1628615055163142144","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aheze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-22T17:14:44.000Z","updated_at":"2025-04-01T17:36:17.000Z","dependencies_parsed_at":"2024-10-30T12:44:21.395Z","dependency_job_id":null,"html_url":"https://github.com/aheze/Setting","commit_stats":{"total_commits":102,"total_committers":9,"mean_commits":"11.333333333333334","dds":0.0980392156862745,"last_synced_commit":"0f29fd49a514c5d63469884d7b45a4842eaf0e6b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSetting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSetting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSetting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheze%2FSetting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aheze","download_url":"https://codeload.github.com/aheze/Setting/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744335,"owners_count":20988783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","preferences","settings","swift","swiftui"],"created_at":"2024-09-24T21:40:47.716Z","updated_at":"2025-04-07T23:13:08.722Z","avatar_url":"https://github.com/aheze.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"Assets/Top.png\" width=\"300\" alt=\"Header image\"\u003e\n\n**Compose beautiful preference panels.**\n\n- Simple but powerful syntax (powered by [result builders](https://www.hackingwithswift.com/swift/5.4/result-builders)).\n- Create nested pages and groups.\n- Fully searchable.\n- Native integration with SwiftUI and AppStorage.\n- Comes with pre-made components: Toggle, Button, Slider, etc...\n- Style components with native SwiftUI modifiers.\n- Show and hide components dynamically.\n- Add your own custom SwiftUI views.\n- Works on iOS and macOS.\n\n![Screenshots of views created with Setting](Assets/Setting.png)\n\n![Screenshots of a nested page and search results](Assets/Details.png)\n\n### Installation\n\nSetting is available via the [Swift Package Manager](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app). Requires iOS 15+ or macOS Monterey and up.\n\n```\nhttps://github.com/aheze/Setting\n```\n\n### Usage\n\n```swift\nimport Setting\nimport SwiftUI\n\nstruct PlaygroundView: View {\n    /// Setting supports `@State`, `@AppStorage`, `@Published`, and more!\n    @AppStorage(\"isOn\") var isOn = true\n\n    var body: some View {\n        /// Start things off with `SettingStack`.\n        SettingStack {\n            /// This is the main settings page.\n            SettingPage(title: \"Playground\") {\n                /// Use groups to group components together.\n                SettingGroup(header: \"Main Group\") {\n                    /// Use any of the pre-made components...\n                    SettingToggle(title: \"This value is persisted!\", isOn: $isOn)\n\n                    /// ...or define your own ones!\n                    SettingCustomView {\n                        Image(\"Logo\")\n                            .resizable()\n                            .aspectRatio(contentMode: .fit)\n                            .frame(width: 160)\n                            .padding(20)\n                    }\n\n                    /// Nest `SettingPage` inside other `SettingPage`s!\n                    SettingPage(title: \"Advanced Settings\") {\n                        SettingText(title: \"I show up on the next page!\")\n                    }\n                }\n            }\n        }\n    }\n}\n```\n![The result, a generated settings page. Clicking on \"Advanced Settings\" presents a new page.](Assets/Customizable.png)\n\n\n### Examples\n\nView more examples in the [example app](https://github.com/aheze/Setting/tree/main/Example/SettingExample).\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```swift\nstruct PlaygroundView: View {\n    var body: some View {\n        SettingStack {\n            SettingPage(title: \"Playground\") {\n                SettingGroup {\n                    SettingText(title: \"Hello!\")\n                }\n            }\n        }\n    }\n}\n```\n\u003c/td\u003e\n\u003ctd\u003e\n\n![Settings view rendered with \"Hello!\" label](Assets/1.png)\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```swift\nSettingStack {\n    SettingPage(title: \"Playground\") {\n        SettingGroup {\n            SettingText(title: \"Hello!\")\n        }\n\n        SettingGroup {\n            SettingPage(title: \"First Page\") {}\n                .previewIcon(\"star\")\n\n            SettingPage(title: \"Second Page\") {}\n                .previewIcon(\"sparkles\")\n\n            SettingPage(title: \"Third Page\") {}\n                .previewIcon(\"leaf.fill\")\n        }\n    }\n}\n```\n\u003c/td\u003e\n\u003ctd\u003e\n\n![Settings view rendered with 3 row links](Assets/2.png)\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```swift\nstruct PlaygroundView: View {\n    @AppStorage(\"isOn\") var isOn = true\n    @AppStorage(\"value\") var value = Double(5)\n\n    var body: some View {\n        SettingStack {\n            SettingPage(title: \"Playground\") {\n                SettingGroup {\n                    SettingToggle(title: \"On\", isOn: $isOn)\n                }\n\n                SettingGroup(header: \"Slider\") {\n                    SettingSlider(\n                        value: $value,\n                        range: 0 ... 10\n                    )\n                }\n            }\n        }\n    }\n}\n```\n\u003c/td\u003e\n\u003ctd\u003e\n\n![Settings view rendered with toggle and slider](Assets/3.png)\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```swift\nstruct PlaygroundView: View {\n    @AppStorage(\"index\") var index = 0\n\n    var body: some View {\n        SettingStack {\n            SettingPage(title: \"Playground\") {\n                SettingGroup {\n                    SettingPicker(\n                        title: \"Picker\",\n                        choices: [\"A\", \"B\", \"C\", \"D\"],\n                        selectedIndex: $index\n                    )\n                    SettingPicker(\n                        title: \"Picker with menu\",\n                        choices: [\"A\", \"B\", \"C\", \"D\"],\n                        selectedIndex: $index,\n                        choicesConfiguration: .init(\n                            pickerDisplayMode: .menu\n                        )\n                    )\n                }\n            }\n        }\n    }\n}\n```\n\u003c/td\u003e\n\u003ctd\u003e\n\n![Settings view rendered with picker](Assets/4.png)\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```swift\nSettingStack {\n    SettingPage(title: \"Playground\") {\n        SettingCustomView {\n            Color.blue\n                .opacity(0.1)\n                .cornerRadius(12)\n                .overlay {\n                    Text(\"Put anything here!\")\n                        .foregroundColor(.blue)\n                        .font(.title.bold())\n                }\n                .frame(height: 150)\n                .padding(.horizontal, 16)\n        }\n    }\n}\n```\n\u003c/td\u003e\n\u003ctd\u003e\n\n![Settings view rendered with \"Put anything here!\" label](Assets/5.png)\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### Notes\n\n- If multiple components have the same title, use the `id` parameter to make sure everything gets rendered correctly.\n\n```swift\nSettingText(id: \"Announcement 1\", title: \"Hello!\")\nSettingText(id: \"Announcement 2\", title: \"Hello!\")\n```\n\n- Setting comes with `if-else` support!\n\n```swift\nSettingToggle(title: \"Turn on\", isOn: $isOn)\n\nif isOn {\n    SettingText(\"I'm turned on!\")\n}\n```\n\n- Wrap components in `SettingCustomView` to style them.\n\n```swift\nSettingCustomView {\n    SettingText(title: \"I'm bold!\")\n        .bold()\n}\n```\n\n- Want to split up a Setting into multiple variables/files? Just use `@SettingBuilder`.\n\n```swift\nstruct ContentView: View {\n    var body: some View {\n        SettingStack {\n            SettingPage(title: \"Settings\") {\n                general\n                misc\n            }\n        }\n    }\n    \n    @SettingBuilder var general: some Setting {\n        SettingPage(title: \"General\") {\n            SettingText(title: \"General Settings\")\n        }\n    }\n    \n    @SettingBuilder var misc: some Setting {\n        SettingPage(title: \"Misc\") {\n            SettingText(title: \"Misc Settings\")\n        }\n    }\n}\n```\n\n- Need to store custom structs in `AppStorage`? Check out @IanKeen's awesome [gist](https://gist.github.com/IanKeen/4d29b48519dca125b21675eeb7623d60)!\n\n- You can pass in a custom `SettingViewModel` instance for finer control.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```swift\nstruct PlaygroundView: View {\n    @StateObject var settingViewModel = SettingViewModel()\n\n    var body: some View {\n        SettingStack(settingViewModel: settingViewModel) {\n            SettingPage(title: \"Playground\") {\n                SettingGroup {\n                    SettingText(title: \"Welcome to Setting!\")\n                }\n            }\n        } customNoResultsView: {\n            VStack(spacing: 20) {\n                Image(systemName: \"xmark\")\n                    .font(.largeTitle)\n\n                Text(\"No results for '\\(settingViewModel.searchText)'\")\n            }\n            .frame(maxWidth: .infinity, maxHeight: .infinity)\n        }\n    }\n}\n```\n\u003c/td\u003e\n\u003ctd\u003e\n\n![Settings view rendered with \"Put anything here!\" label](Assets/NoResults.png)\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n\n\n\n---\n\n### Community\n\nAuthor | Contributing | Need Help?\n--- | --- | ---\nSetting is made by [aheze](https://github.com/aheze). | All contributions are welcome. Just [fork](https://github.com/aheze/Setting/fork) the repo, then make a pull request. | Open an [issue](https://github.com/aheze/Setting/issues) or join the [Discord server](https://discord.com/invite/Pmq8fYcus2). You can also ping me on [Twitter](https://twitter.com/aheze0).\n\n### License\n\n```\nMIT License\n\nCopyright (c) 2023 A. Zheng\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheze%2Fsetting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faheze%2Fsetting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheze%2Fsetting/lists"}