I have a struct:
In SpaceAxisProtocol bounds are defined as:
And I try to edit bounds in a View:
When axis.bounds.lowerbound and axis.bounds.upperbound became let? How to edit them in View?
Code Block public typealias CoordUnit = Double public struct StyledAxis: StyledAxisProtocol { public var name: String public var bounds: ClosedRange<CoordUnit> public var distribution: Double? ... }
In SpaceAxisProtocol bounds are defined as:
Code Block public protocol SpaceAxisProtocol: Equatable & Hashable { var name: String {get set} var bounds: ClosedRange<CoordUnit> {get set} init(_ name: String, bounds: ClosedRange<CoordUnit>) } public protocol StyledAxisProtocol: SpaceAxisProtocol {...}
And I try to edit bounds in a View:
Code Block struct StyledAxisView<SA:StyledAxisProtocol>: View { @Binding var axis: SA public var body : some View { VStack { // Axis name and distribution works HStack(alignment: .lastTextBaseline) { TextField("", text: $axis.name) .controlSize(.small) .font(.headline) DistributionView( value: $axis.distribution) .controlSize(.mini) } // It causes compiler `Cannot assign to property: 'lowerBound' is a 'let' constant`. But it isn't. ? HStack { ValueView(value: $axis.bounds.lowerBound) ValueView(value: $axis.bounds.upperBound) } ...
When axis.bounds.lowerbound and axis.bounds.upperbound became let? How to edit them in View?