feat: Update dependecies
The package is early alpha (prototyping stage) Run make workspace from the terminal to generate .xcworkspace for the example
make workspace
.xcworkspace
DynamicText
DynamicButton
DynamicStack
DynamicTextField
DynamicTextView
DynamicSpacer
DynamicImage
DynamicToggle
DynamicConfirmationDialog
DynamicAlert
DynamicDragField
DynamicDropField
DynamicLink
DynamicNavigationView
Color
Font
Binding
Example
Import DynamicForms
DynamicForms
Declare your dynamic form model
DynamicForm { DynamicStack(.vertical) { DynamicText("Title").bold() DynamicText("Description") DynamicStack(.horizontal) { DynamicText("State: ") DynamicText("Initial") } DynamicStack(.horizontal) { DynamicButton( DynamicText("OK"), action: "content.ok" ) DynamicButton( DynamicText("Cancel"), action: "content.cancel" ) } } }
Equivalent for VStack { Text("Title").bold() Text("Description") HStack { Text("State: ") Text("Initial") } HStack { Button { DynamicFormClient.shared.send("content.id") } label: { Text("OK") } Button { DynamicFormClient.shared.send("content.cancel") } label: { Text("Cancel") } } }
Equivalent for
VStack { Text("Title").bold() Text("Description") HStack { Text("State: ") Text("Initial") } HStack { Button { DynamicFormClient.shared.send("content.id") } label: { Text("OK") } Button { DynamicFormClient.shared.send("content.cancel") } label: { Text("Cancel") } } }
Specify body for your dynamic-form-based view using DynamicFormView
DynamicFormView
DynamicFormView($form)
Handle button actions
// Returns AnyPublisher<Event, Never> where Event is // Event { // id: DynamicElementIdentifier // action: DynamicElementActionIdentifier // } DynamicFormClient.shared.publisher // Filters events and returns AnyPublisher<Void, Never> DynamicFormClient.shared.publisher( for: .init(id: "element", action: "tap") ) // Filters events by actionID and returns AnyPublisher<Void, Never> DynamicFormClient.shared.publisher( for: "actionID" )
You can add DynamicForms to an Xcode project by adding it as a package dependency.
"https://github.com/capturecontext/swiftui-dynamic-forms.git"
If you use SwiftPM for your project, you can add StandardClients to your package file.
.package( name: "swiftui-dynamic-forms", url: "https://github.com/capturecontext/swiftui-dynamic-forms.git", .branch("0.1.0") )
Do not forget about target dependencies:
.product( name: "DynamicFormss", package: "swiftui-dynamic-forms" )
This library is released under the MIT license. See LICENSE for details.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
swiftui-dynamic-forms
TODO
DynamicText
DynamicButton
DynamicStack
DynamicTextField
DynamicTextView
DynamicSpacer
DynamicImage
DynamicToggle
DynamicImage
DynamicConfirmationDialog
DynamicAlert
DynamicDragField
DynamicDropField
DynamicLink
DynamicNavigationView
Color
andFont
Binding
sUsage
Example
Import
DynamicForms
Declare your dynamic form model
Specify body for your dynamic-form-based view using
DynamicFormView
Handle button actions
Installation
Basic
You can add DynamicForms to an Xcode project by adding it as a package dependency.
"https://github.com/capturecontext/swiftui-dynamic-forms.git"
into the package repository URL text fieldRecommended
If you use SwiftPM for your project, you can add StandardClients to your package file.
Do not forget about target dependencies:
License
This library is released under the MIT license. See LICENSE for details.