convenience view collection every view is already used for app but basically all views are under develop for improvement.
initially Text but it will become TextField with click.
Useful for textField in List, otherwise updating List (comes from updating binding data) will take a way focus from TextField Note: in indirectEdit-mode, need to have "return" or "loose focus" to apply input to binding
struct ContentView: View {
@State private var text = "Hello"
@State private var texts = ["Hello", "World"]
var body: some View {
VStack {
EditableText(value: $text)
List($texts, id: \.self) { $text in
EditableText(value: $text)
.indirectEdit()
}
}
.padding()
}
}
initially token view but it will become TokenField with click note: EditableToken is not implemented yet
struct ContentView: View {
@State private var selectedTokens: [String] = []
@State private var tokens = ["Hello", "World"]
var body: some View {
VStack {
let getSet = (getter: {
return selectedTokens
}, setter: { (newNames: [String]) in
selectedTokens = newNames
})
TokenField(getSet: getSet, selectableTokens: tokens))
}
.padding()
}
}
View will display data which will be delivered later (then might be updated via Publisher)
import SwiftUI
import Combine
import SDSCustomView
struct ContentView: View {
let updateProvider = PassthroughSubject<Int,Never>()
var body: some View {
VStack {
AsyncView(content: { (value: Int) in
Text(String(value))
}, placeholder: {
ProgressView()
}, dataProvider: {
return await longCalc()
}, updateProvider: updateProvider.eraseToAnyPublisher())
Button(action: {
updateProvider.send((1...10).randomElement()!)
}, label: { Text("Random") })
}
}
func longCalc() async -> Int {
// after long calculation
try? await Task.sleep(for: .seconds(3))
return 2
}
}
currently only for macOS
Sometimes we want to have fixed-width label"s" those have same width. Usually we don't mind width value itself, but want to align leading/center/traiing in same width.
looks like following.
You can easily achieve above layout with
VStack {
FixedWidthLabel("123",widthFor: "0000").alignment(.trailing)
FixedWidthLabel( "1",widthFor: "0000").alignment(.trailing)
}
basically above is equivalent with following.
VStack {
Text("0000")
.hidden()
.overlay(
Text("123")
.frame(maxWidth: .infinity, alignment: .trainling)
)
Text("0000")
.hidden()
.overlay(
Text("1")
.frame(maxWidth: .infinity, alignment: .trainling)
)
}
Just for reducing boilerplates.
Note: it is NOT ultimately fixed width label. in case user modify their text size setting, label width would be affected.
link |
Stars: 2 |
Last commit: Yesterday |
Full Changelog: https://github.com/tyagishi/SDSCustomView/compare/3.4.0...3.5.0
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics