A light-weight, extensible package for building pixel-perfect iOS settings screens.

Related tags

Database SettingsKit
Overview

SettingsKit.

Swift Package Manager iOS Twitter: @sebjvidal

SettingsKit

A light-weight, extensible package for easily building pixel-perfect iOS settings screens in a pinch.

Installation

SettingsKit can be installed using Swift Package Manager. To get started...

  1. Open your project in Xcode and navigate to File, Add Packages...
  2. Search for https://github.com/sebjvidal/SettingsKit.git in the "Search or Enter Package URL" toolbar item
  3. Choose SettingsKit
  4. Click Add Package

Usage

In the following example, you'll learn how to build a settings screen with a single "General" group that has four child settings.

To begin, create an Array with a single SettingsKitSection object, parsing an Array of SettingsKitSetting to its setting initialiser.

import SettingsKit

let generalSections: [SettingsKitSection] = [
    SettingsKitSection(
        settings: [
            SettingsKitLabel(title: "A Label Cell", value: .userDefaults(key: "label")),
            SettingsKitToggle(title: "A Toggle Cell", value: .userDefaults(key: "toggle")),
            SettingsKitTextField(title: "A TextField Cell", value: .userDefaults(key: "textField")),
            SettingsKitStepper(title: "A Stepper Cell", value: .userDefaults(key: "stepper"), min: 0, max: 10)
        ]
    )
]

Each object conforming to the SettingsKitSetting protocol has a value property. This is an Enum case that can be a raw value, for example, .string("String"). Alternatively, this can be a UserDefaults key, for examlpe, .userDefaults(key: "Key").

Next, we'll build the SettingsKitGroup and, subsequently the SettingsKitGroup.Icon. Start by creating the SettingsKitGroup.Icon and populating its symbol, config and colour initialisers with a UIImage, UIImage.SymbolConfiguration and UIColor, respectively.

let generalIcon = SettingsKitGroup.Icon(
    symbol: UIImage(systemName: "gear"),
    config: UIImage.SymbolConfiguration(pointSize: 21),
    colour: UIColor.systemGray
)

Now, define a second Array of SettingsKitSection, passing an Array of SettingsKitSetting to its settings parameter. Populate the SettingsKitSetting Array with a single SettingsKitGroup object. Set the icon parameter to the generalIcon created above. Set the title parameter to "General". And set the children parameter to the generalSections array.

let rootSections: [SettingsKitSection] = [
    SettingsKitSection(
        settings: [
            SettingsKitGroup(icon: generalIcon, title: "General", children: generalSections)
        ]
    )
]

Finally, create the SettingsKitViewController, populating the sections parameter with the previously defined rootSections Array.

let viewController = SettingsKitViewController(sections: rootSections)

Additionally, the root SettingsKitViewController navigation elements can be customised as follows.

viewController.title = "SettingsKit"
viewController.navigationItem.largeTitleDisplayMode = .automatic
viewController.navigationController?.navigationBar.prefersLargeTitles = true

This is what your finished product should look like...

SettingsKit.

About

SettingsKit is built with UIKit, so you can customise the SettingsKitViewController as you would a UITableViewController.

Be careful when overriding the SettingsKitViewController tableView's delegate methods, as the following methods are used internally to make the package functional:

  • numberOfSections(in:)
  • tableView(_:titleForHeaderInSection:)
  • tableView(_:titleForFooterInSection:)
  • tableView(_:numberOfRowsInSection:)
  • tableView(_:cellForRowAt:)
  • tableView(_:heightForRowAt)
  • tableView(_:shouldHighlightRowAt:)
  • tableView(_:didSelectRowAt:)
You might also like...
A Library for iOS developers to check newer version of app from the app store
A Library for iOS developers to check newer version of app from the app store

swift-app-update-checker A very simple solution check new version of your application is available on store or not. Example To run the example project

Native iOS app for Habitica

Habitica for iOS Native iOS app for Habitica. Contributing For an introduction to the technologies used and how the software is organized, refer to Co

BucketServer - Small API with SQLite database that saves notes for an iOS appliction called Bucket list

BucketList Server-Side Small API with SQLite database that saves notes for an iO

CodableFiles - Save and load Codable objects from DocumentDirectory on iOS Devices.
CodableFiles - Save and load Codable objects from DocumentDirectory on iOS Devices.

Welcome to CodableFiles, a simple library that provides an easier way to save, load or delete Codable objects in Documents directory. It’s primarily a

BubblePop - a number of bubbles are randomly displayed on an iOS device screen
BubblePop - a number of bubbles are randomly displayed on an iOS device screen

Description The game is called BubblePop . In this game, a number of bubbles are

iOS dictionary for international movie titles & Wikipedia mining tools
iOS dictionary for international movie titles & Wikipedia mining tools

MovieDict. What do they call it? International movie title database for iPhone An app for travelers and language learners who like to talk about their

An iOS app to lift the speed limit of your Cowboy Bike
An iOS app to lift the speed limit of your Cowboy Bike

Legal Notice 1. I am not resposible to anything worse that could happen to your bike because of this app 2. Be careful that lifting the 25km/h limit c

The BART app for commuters, now native on iOS

Arrival iOS Built with SwiftUI, Arrival is the BART app for commuters. Available for download on the App Store: https://apps.apple.com/us/app/arrival-

This is the public repository of the MADBike app for iOS. Public bike rental service for BiciMAD.

MADBike Requirements iOS 10.3+ Xcode 10.3+ Swift 4+ Installation Copy BiciMAD/Supporting Files/GoogleService-Info-Sample.plist to BiciMAD/Supporting F

Comments
  • Typo in SettingsKitSecetion

    Typo in SettingsKitSecetion

    Hi,

    Great package, but I noticed what I think is a typo. In code as well as the readme it mentions SettingsKitSecetion instead of SettingsKitSection. If this was intentional feel free to remove this issue.

    opened by mrenty 1
Releases(v1.0.3)
Owner
Seb Vidal
Seb Vidal
Swift library that makes easier to serialize the user's preferences (app's settings) with system User Defaults or Property List file on disk.

PersistentStorageSerializable PersistentStorageSerializable is a protocol for automatic serialization and deserialization of Swift class, struct or NS

Ivan Rublev 163 Jun 3, 2021
A sample application showcasing Vapor 4 connecting to an Oracle database using SwiftOracle package.

vapor-oracle A sample application showcasing Vapor 4 connecting to an Oracle database using SwiftOracle package. In this Vapor application, we create

Ilia Sazonov 3 Sep 22, 2022
Shows the issue with swift using an ObjC class which has a property from a swift package.

SwiftObjCSwiftTest Shows the issue with swift using an ObjC class which has a property from a swift package. The Swift class (created as @objc derived

Scott Little 0 Nov 8, 2021
The Swift Package Index is the place to find Swift packages!

The Swift Package Index helps you make better decisions about the dependencies you use in your apps. The Swift Package Index is a search engine for pa

Swift Package Index 389 Dec 22, 2022
Ios-App-ication-Swift - A simple iOS application made in Xcode using Swift

?? iPhone Calculator A simple iOS application made in Xcode using Swift. This ap

Kushal Shingote 1 Feb 2, 2022
Disk is a powerful and simple file management library built with Apple's iOS Data Storage Guidelines in mind

Disk is a powerful and simple file management library built with Apple's iOS Data Storage Guidelines in mind

Saoud Rizwan 3k Jan 3, 2023
GraphQLite is a toolkit to work with GraphQL servers easily. It also provides several other features to make life easier during iOS application development.

What is this? GraphQLite is a toolkit to work with GraphQL servers easily. It also provides several other features to make life easier during iOS appl

Related Code 2.8k Jan 9, 2023
Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS

简体中文 DefaultsKit leverages Swift 4's powerful Codable capabilities to provide a Simple and Strongly Typed wrapper on top of UserDefaults. It uses less

Nuno Dias 1.4k Dec 26, 2022
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.

中文版本请参看这里 MMKV is an efficient, small, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on Andr

Tencent 15.4k Jan 6, 2023
This is the BlurrMC social media platform for iOS hosted on Apple's CloudKit.

BlurrMC for iOS This is the BlurrMC social media platform for IOS! WOOOOOOO! On this version of the social media platform, you have the full featured

BlurrMC 0 Nov 4, 2021