Go to file
Cokile Ceoi 0831f8684f
fix(ui): fix tweak list crash after scrolling (#4)
2023-01-13 15:20:01 +08:00
.github/workflows chore(project): add workflow to validate pr 2022-11-16 22:31:06 +08:00
Demo chore(project): change author info for demo 2022-06-08 19:27:31 +08:00
Images improve(READ): add more screenshots 2022-02-12 22:18:35 +08:00
Sources fix(ui): fix tweak list crash after scrolling (#4) 2023-01-13 15:20:01 +08:00
Tests chore(source): tweak lint rules 2022-07-23 08:23:39 +08:00
TweaKit.xcodeproj chore(project): bump version to 1.0.3 2022-11-16 22:03:27 +08:00
TweaKit.xcworkspace chore(project): Initial project 2021-05-30 11:05:38 +08:00
docs doc: update 2022-07-03 09:16:04 +08:00
.gitignore doc: generate documentation with jazzy 2022-02-11 22:49:04 +08:00
.jazzy.yaml chore(project): adopt repo transfer 2022-06-30 13:10:00 +08:00
.swiftlint.yml chore(source): tweak lint rules 2022-07-23 08:23:39 +08:00
CHANGELOG.md fix(ui): fix tweak list crash after scrolling (#4) 2023-01-13 15:20:01 +08:00
Gemfile doc: generate documentation with jazzy 2022-02-11 22:49:04 +08:00
Gemfile.lock chore(deps): bump cocoapods-downloader from 1.5.1 to 1.6.3 2022-06-09 09:21:32 +08:00
LICENSE chore: update License 2022-07-22 18:41:14 +08:00
Package.swift fix(project): fix build issues with spm 2021-12-15 16:42:21 +08:00
README.md chore(project): bump version to 1.0.3 2022-11-16 22:03:27 +08:00
TweaKit.podspec chore(project): bump version to 1.0.3 2022-11-16 22:03:27 +08:00

README.md

TweaKit

TweaKit, a.k.a. "Tweak It", is a pure-swift library for adjusting parameters and feature flagging.

Features

  • Declaring tweaks with property wrapper and result builder.
  • Tweaking frequently used types on the fly.
  • Carefully designed UI/UX.
  • Searching tweaks fuzzily.
  • Importing and exporting tweaks with json.

Requirements

  • iOS 13 and later
  • Swift 5.4 and later

Installation

CocoaPods

pod 'TweaKit', '~> 1.0'

Carthage

github "Alpensegler/TweaKit" ~> 1.0

Swift Package Manager

.package(url: "https://github.com/Alpensegler/TweaKit.git", .upToNextMajor(from: "1.0.0"))

Get Started

Declare Tweaks

import TweaKit

enum Tweaks {
    @Tweak<CGFloat>(name: "Line Width", defaultValue: 1, from: 0.5, to: 2, stride: 0.05)
    static var sketchLineWidth
    @Tweak(name: "Line Color", defaultValue: UIColor(red: 0.227, green: 0.529, blue: 0.992, alpha: 1))
    static var sketchLineColor
    @Tweak(name: "Order", defaultValue: SketchAction.allCases)
    static var sketchActionsOrder
    @Tweak(name: "Name", defaultValue: "My Sketch")
    static var sketchName
    
    @Tweak(name: "Navigation Title", defaultValue: "Demo", options: ["Demo", "Example", "Guide"])
    static var rootViewNavigationTitle
    @Tweak(name: "Shake To Show Tweaks", defaultValue: true)
    static var rootViewEnableShake
    
    static let context = TweakContext {
        TweakList("Sketch") {
            TweakSection("Line") {
                $sketchLineWidth
                $sketchLineColor
            }
            TweakSection("Info") {
                $sketchName
            }
            TweakSection("Actions") {
                $sketchActionsOrder
            }
        }
        TweakList("Root View") {
            TweakSection("UI") {
                $rootViewNavigationTitle
            }
            TweakSection("Interaction") {
                $rootViewEnableShake
            }
        }
    }
}

You can tweak the following types:

  • Bool
  • Numeric Types: Int[8|16|32|64], UInt[8|16|32|64], Float, Double and CGFloat
  • String
  • Array that Element conforming some protocols
  • UIColor

Aside from changing value in place, you can also select value from given options.

Initialize Tweak Context

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    _ = Tweaks.context
    return true
}

You can initialize tweak context at any time, but you should make sure the context is initialized before using tweaks in it.

Use Tweaks

myViewController.title = Tweaks.rootViewNavigationTitle
mySketchView.lineWidth = Tweaks.sketchLineWidth

Show the Tweak UI

Tweaks.context.show()

Screenshot1 Screenshot2 Screenshot3 Screenshot4

Screenshot5 Screenshot6 Screenshot7 Screenshot8

That's all. Now you already know enough about TweaKit.

Feel free to play with the demo app or check wiki and documentation for more usage information.

Credits

The logo of TweaKit is a cute stoat, a mustelid that can tweak fur color during summer and winter.