@@ -17,54 +17,61 @@ struct AddEditCoupon: View {
1717 NavigationView {
1818 GeometryReader { geometry in
1919 ScrollView {
20- VStack ( alignment: . leading) {
20+ VStack ( alignment: . leading, spacing : 0 ) {
2121 Group {
2222 ListHeaderView ( text: Localization . headerCouponDetails. uppercased ( ) , alignment: . left)
2323
2424 Group {
25- TitleAndTextFieldRow ( title: Localization . couponAmountPercentage ,
26- placeholder: Localization . couponAmountPercentage ,
25+ TitleAndTextFieldRow ( title: viewModel . amountLabel ,
26+ placeholder: " 0 " ,
2727 text: $viewModel. amountField,
28- editable: false ,
28+ editable: true ,
2929 fieldAlignment: . leading,
30- keyboardType: . asciiCapableNumberPad )
30+ keyboardType: . decimalPad )
3131 Divider ( )
3232 . padding ( . leading, Constants . margin)
33- }
3433
35- Text ( Localization . footerCouponAmountPercentage)
36- . subheadlineStyle ( )
37- . padding ( . horizontal, Constants . margin)
34+ Text ( viewModel. amountSubtitleLabel)
35+ . subheadlineStyle ( )
36+ . padding ( . horizontal, Constants . margin)
37+ }
38+ . padding ( . bottom, Constants . verticalSpacing)
3839
3940 Group {
4041 TitleAndTextFieldRow ( title: Localization . couponCode,
41- placeholder: Localization . couponCode ,
42+ placeholder: Localization . couponCodePlaceholder ,
4243 text: $viewModel. codeField,
43- editable: false ,
44+ editable: true ,
4445 fieldAlignment: . leading,
45- keyboardType: . asciiCapableNumberPad )
46+ keyboardType: . default )
4647 Divider ( )
4748 . padding ( . leading, Constants . margin)
49+ . padding ( . bottom, Constants . verticalSpacing)
50+ Text ( Localization . footerCouponCode)
51+ . subheadlineStyle ( )
52+ . padding ( . horizontal, Constants . margin)
4853 }
54+ . padding ( . bottom, Constants . verticalSpacing)
4955
50- Text ( Localization . footerCouponCode)
51- . subheadlineStyle ( )
52- . padding ( . horizontal, Constants . margin)
53-
54- //TODO: leading aligning for this button
5556 Button {
5657 //TODO: handle action
5758 } label: {
5859 Text ( Localization . regenerateCouponCodeButton)
5960 }
6061 . buttonStyle ( LinkButtonStyle ( ) )
61- . padding ( . horizontal, Constants . margin)
62+ . fixedSize ( )
63+ . frame ( maxWidth: . infinity, alignment: . leading)
64+ . padding ( . bottom, Constants . verticalSpacing)
6265
6366 Button {
6467 //TODO: handle action
6568 } label: {
66- Text ( Localization . addDescriptionButton)
67- . bodyStyle ( )
69+ HStack {
70+ Image ( uiImage: . plusImage)
71+ . frame ( width: Constants . iconSize, height: Constants . iconSize)
72+ Text ( Localization . addDescriptionButton)
73+ . bodyStyle ( )
74+ }
6875 }
6976 . buttonStyle ( SecondaryButtonStyle ( ) )
7077 . padding ( . horizontal, Constants . margin)
@@ -77,38 +84,50 @@ struct AddEditCoupon: View {
7784 Divider ( )
7885 . padding ( . leading, Constants . margin)
7986 }
87+ . padding ( . bottom, Constants . verticalSpacing)
8088
8189 Group {
8290 TitleAndToggleRow ( title: Localization . includeFreeShipping, isOn: . constant( false ) )
8391 . padding ( . horizontal, Constants . margin)
8492 Divider ( )
8593 . padding ( . leading, Constants . margin)
8694 }
95+ . padding ( . bottom, Constants . verticalSpacing)
8796 }
8897
8998 Group {
9099 ListHeaderView ( text: Localization . headerApplyCouponTo. uppercased ( ) , alignment: . left)
100+ . padding ( . bottom, Constants . verticalSpacing)
91101
92- // TODO: add a new style with the icon on the left side
93102 Button {
94103 //TODO: handle action
95104 } label: {
96- Text ( Localization . editProductsButton)
97- . bodyStyle ( )
105+ HStack {
106+ Image ( uiImage: . pencilImage) . colorMultiply ( Color ( . text) )
107+ . frame ( width: Constants . iconSize, height: Constants . iconSize)
108+ Text ( Localization . editProductsButton)
109+ . bodyStyle ( )
110+ }
98111 }
99112 . buttonStyle ( SecondaryButtonStyle ( ) )
100113 . padding ( . horizontal, Constants . margin)
114+ . padding ( . bottom, Constants . verticalSpacing)
101115
102- // TODO: add a new style with the icon on the left side
103116 Button {
104117 //TODO: handle action
105118 } label: {
106- Text ( Localization . editProductCategoriesButton)
107- . bodyStyle ( )
119+ HStack {
120+ Image ( uiImage: . pencilImage)
121+ . colorMultiply ( Color ( . text) )
122+ . frame ( width: Constants . iconSize, height: Constants . iconSize)
123+ Text ( Localization . editProductCategoriesButton)
124+ . bodyStyle ( )
125+ }
108126 }
109127 . buttonStyle ( SecondaryButtonStyle ( ) )
110128 . padding ( . horizontal, Constants . margin)
111129 }
130+ . padding ( . bottom, Constants . verticalSpacing)
112131
113132 Group {
114133 ListHeaderView ( text: Localization . headerUsageDetails. uppercased ( ) , alignment: . left)
@@ -119,6 +138,7 @@ struct AddEditCoupon: View {
119138 Divider ( )
120139 . padding ( . leading, Constants . margin)
121140 }
141+ . padding ( . bottom, Constants . verticalSpacing)
122142
123143 Button {
124144 //TODO: handle action
@@ -127,7 +147,7 @@ struct AddEditCoupon: View {
127147 }
128148 . buttonStyle ( PrimaryButtonStyle ( ) )
129149 . padding ( . horizontal, Constants . margin)
130- . padding ( . top, Constants . verticalSpacing)
150+ . padding ( [ . top, . bottom ] , Constants . verticalSpacing)
131151 }
132152 }
133153 . ignoresSafeArea ( . container, edges: [ . horizontal, . bottom] )
@@ -153,6 +173,7 @@ private extension AddEditCoupon {
153173 enum Constants {
154174 static let margin : CGFloat = 16
155175 static let verticalSpacing : CGFloat = 8
176+ static let iconSize : CGFloat = 16
156177 }
157178
158179 enum Localization {
@@ -162,23 +183,20 @@ private extension AddEditCoupon {
162183 static let headerCouponDetails = NSLocalizedString (
163184 " Coupon details " ,
164185 comment: " Header of the coupon details in the view for adding or editing a coupon. " )
165- static let couponAmountPercentage = NSLocalizedString (
166- " Amount (%) " ,
167- comment: " Text field Amount in percentage in the view for adding or editing a coupon. " )
168- static let footerCouponAmountPercentage = NSLocalizedString (
169- " Set the percentage of the discount you want to offer. " ,
170- comment: " The footer of the text field Amount in percentage in the view for adding or editing a coupon. " )
171186 static let couponCode = NSLocalizedString (
172187 " Coupon Code " ,
173188 comment: " Text field coupon code in the view for adding or editing a coupon. " )
189+ static let couponCodePlaceholder = NSLocalizedString (
190+ " Enter a coupon " ,
191+ comment: " Text field coupon code placeholder in the view for adding or editing a coupon. " )
174192 static let footerCouponCode = NSLocalizedString (
175193 " Customers need to enter this code to use the coupon. " ,
176194 comment: " The footer of the text field coupon code in the view for adding or editing a coupon. " )
177195 static let regenerateCouponCodeButton = NSLocalizedString (
178196 " Regenerate Coupon Code " ,
179197 comment: " Button in the view for adding or editing a coupon. " )
180198 static let addDescriptionButton = NSLocalizedString (
181- " + Add Description (Optional)" ,
199+ " Add Description (Optional) " ,
182200 comment: " Button for adding a description to a coupon in the view for adding or editing a coupon. " )
183201 static let couponExpiryDate = NSLocalizedString (
184202 " Coupon Expiry Date " ,
0 commit comments