A multi-platform SwiftUI component for text input with presets support
Available as an open source library to be incorporated in SwiftUI apps.
SwiftTextFieldPreset is part of the OpenAlloc family of open source Swift software tools.
Text Field | Presets Picker |
---|---|
![]() |
![]() |
TextField
componentIn your Package.swift
:
To package .dependencies
add
.package(url: "https://github.com/openalloc/SwiftTextFieldPreset.git", .upToNextMajor(from: "1.1.2")),
To product .dependencies
add
.product(name: "TextFieldPreset", package: "SwiftTextFieldPreset"),
A simple example where the presets are String
type:
import SwiftUI
import TextFieldPreset
import Collections
struct MyView: View {
let presets: OrderedDictionary = [
"Machine/Free Weights": [
"Abdominal",
"Arm Curl",
],
"Bodyweight": [
"Crunch",
"Jumping-jack",
],
]
@State var name: String = "New Exercise"
var body: some View {
Form {
TextFieldPreset($name, prompt: "Enter name", axis: .vertical, presets: presets, pickerLabel: {
Text($0.description)
})
}
}
}
Note that presets can be more than String
, such as struct
s with additional values that can used to populate your target value/object via the onSelect
callback.
Please submit pull requests if you'd like to tackle any of these. Thanks!
This library is a member of the OpenAlloc Project.
Copyright 2023 OpenAlloc LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Contributions are welcome. You are encouraged to submit pull requests to fix bugs, improve documentation, or offer new features.
The pull request need not be a production-ready feature or fix. It can be a draft of proposed changes, or simply a test to show that expected behavior is buggy. Discussion on the pull request can proceed from there.
link |
Stars: 0 |
Last commit: 4 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics