File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 11import SwiftUI
22
3+ /// PreferenceKey to store max value.
4+ /// Used in `MaxWidthModifier` to calculate max title width among multiple fields/rows.
5+ ///
36struct MaxWidthPreferenceKey : PreferenceKey {
47 static var defaultValue : CGFloat ? = nil
58
@@ -10,6 +13,9 @@ struct MaxWidthPreferenceKey: PreferenceKey {
1013 }
1114}
1215
16+ /// Modifier to calculate view width and store it in `MaxWidthPreferenceKey`.
17+ /// Used to calculate max frame and then align multiple fields/rows.
18+ ///
1319struct MaxWidthModifier : ViewModifier {
1420 private var sizeView : some View {
1521 GeometryReader { geometry in
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ struct TitleAndTextFieldRow: View {
1313
1414 @Binding private var text : String
1515
16+ /// Static width for title label. Used to align values between different rows.
17+ /// If `nil` - title will have intrinsic size.
18+ ///
1619 @Binding private var titleWidth : CGFloat ?
1720
1821 init ( title: String ,
Original file line number Diff line number Diff line change @@ -17,8 +17,13 @@ struct TitleAndValueRow: View {
1717 private let selectionStyle : SelectionStyle
1818 private let action : ( ) -> Void
1919
20+ /// Static width for title label. Used to align values between different rows.
21+ /// If `nil` - title will have intrinsic size.
22+ ///
2023 @Binding private var titleWidth : CGFloat ?
2124
25+ /// Value frame alignment derived from its text alignment
26+ ///
2227 private var valueFrameAligment : Alignment {
2328 switch valueTextAlignment {
2429 case . trailing:
You can’t perform that action at this time.
0 commit comments