Swiftpack.co - p-x9/EditValueView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by p-x9.
p-x9/EditValueView 0.0.6
Library that makes easy to display property edit screens for SwiftUI.
⭐️ 6
🕓 2 weeks ago
iOS macOS
.package(url: "https://github.com/p-x9/EditValueView.git", from: "0.0.6")

EditValueView

Library that makes easy to display property edit screens for SwiftUI.

Demo

String Bool Int
String-light Bool-light Int-light
Double Date Color
Double-light Date-light Color-light
Array Dictionary
Array-light Dictionary-light
Enum(CaseIterable) Enum(CaseIterable & RawRepresentable)
Enum(CaseIterable)-light Enum(CaseIterable   RawRepresentable)-light
Codable
Codable-light

Usage

SwiftUI

EditValueView(target, key: "name", keyPath: \Item.name)
    .onUpdate { target, newValue in
        // update
    }
    .validate { target, newValue -> Bool in
        // input validation
    } 

UIKit

let vc = EditValueViewController(target, key: "name", keyPath: \Item.name)
vc.onUpdate = { target, newValue in
    // update
}
vc.validate = { target, newValue -> Bool in
    // input validation
}

Protocol

If you use a keypath of an optional type, either define a default value according to the DefaultRepresentable protocol or give the default value in the initilalize

struct Item: Codable {
    var name: String
    var date: Date
}

struct Message: Codable {
    var content: String
    var item: Item?
}
// Confirm to `DefaultRepresentable` protocol
extension Item: DefaultRepresentable {
    static var defaultValue: Self { 
        .init(name: "name", date: Date())
     }
}
// give default value
EditValueView(target, key: "item", keyPath: \Message.item, defaultValue: .init(name: "name", date: Date()))

GitHub

link
Stars: 6
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Release Notes

v0.0.6
2 weeks ago

What's Changed

Full Changelog: https://github.com/p-x9/EditValueView/compare/0.0.5...0.0.6

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics