Init commit

This commit is contained in:
世界
2023-07-15 15:03:45 +08:00
commit f441b89efb
122 changed files with 7355 additions and 0 deletions
@@ -0,0 +1,11 @@
import SwiftUI
public extension Binding {
func unwrapped<T>(_ defaultValue: T) -> Binding<T> where Value == T? {
Binding<T>(get: {
wrappedValue ?? defaultValue
}, set: { newValue in
wrappedValue = newValue
})
}
}
@@ -0,0 +1,35 @@
import Foundation
import SwiftUI
public func FormView(@ViewBuilder content: () -> some View) -> some View {
Form {
content()
}
#if os(macOS)
.formStyle(.grouped)
#endif
}
public func FormTextItem(_ name: String, _ value: String) -> some View {
HStack {
Text(name)
Spacer()
Text(value)
.multilineTextAlignment(.trailing)
.font(Font.system(.caption, design: .monospaced))
.textSelection(.enabled)
}
}
public func FormItem(_ title: String, @ViewBuilder content: () -> some View) -> some View {
#if os(iOS)
HStack {
Text(title)
Spacer()
Spacer()
content()
}
#else
content()
#endif
}
@@ -0,0 +1,6 @@
import Foundation
import SwiftUI
public func viewBuilder(@ViewBuilder _ builder: () -> some View) -> some View {
builder()
}