29 lines
986 B
Swift
29 lines
986 B
Swift
public extension Label {
|
|
/// Creates a ``Label`` from a plain string. Applied once at mount.
|
|
@_disfavoredOverload
|
|
init<S: StringProtocol>(_ label: S) {
|
|
self.init(str: nil)
|
|
self = self.label(String(label))
|
|
}
|
|
|
|
/// Creates a ``Label`` from a string literal whose interpolated segments are
|
|
/// re-evaluated when the `@State` they read changes, pushing the new value into
|
|
/// the widget in-place.
|
|
init(_ label: Portico.InterpolatedText) {
|
|
self.init(str: nil)
|
|
self = self.label(label)
|
|
}
|
|
|
|
/// Creates a ``Label`` that tracks a ``Binding<String>``.
|
|
init(_ label: Portico.Binding<String>) {
|
|
self.init(str: nil)
|
|
self = self.label(label)
|
|
}
|
|
|
|
/// Creates a ``Label`` whose text is re-evaluated inside a ``DependencyTracker``
|
|
/// whenever `@State` values read by the closure change.
|
|
init(_ label: @escaping () -> String) {
|
|
self.init(str: nil)
|
|
self = self.label(label)
|
|
}
|
|
}
|