@@ -15,29 +15,196 @@ struct AddEditCoupon: View {
1515
1616 var body : some View {
1717 NavigationView {
18+ GeometryReader { geometry in
19+ ScrollView {
20+ VStack ( alignment: . leading) {
21+ Group {
22+ ListHeaderView ( text: Localization . headerCouponDetails. uppercased ( ) , alignment: . left)
1823
19- //TODO: implement the content of the view
20- Text ( " Hello, World! " )
21- . toolbar {
22- ToolbarItem ( placement: . cancellationAction) {
23- Button ( " Cancel " , action: {
24- presentation. wrappedValue. dismiss ( )
25- } )
26- }
27- }
24+ Group {
25+ TitleAndTextFieldRow ( title: Localization . couponAmountPercentage,
26+ placeholder: Localization . couponAmountPercentage,
27+ text: $viewModel. amountField,
28+ editable: false ,
29+ fieldAlignment: . leading,
30+ keyboardType: . asciiCapableNumberPad)
31+ Divider ( )
32+ . padding ( . leading, Constants . margin)
33+ }
34+
35+ Text ( Localization . footerCouponAmountPercentage)
36+ . subheadlineStyle ( )
37+ . padding ( . horizontal, Constants . margin)
38+
39+ Group {
40+ TitleAndTextFieldRow ( title: Localization . couponCode,
41+ placeholder: Localization . couponCode,
42+ text: $viewModel. codeField,
43+ editable: false ,
44+ fieldAlignment: . leading,
45+ keyboardType: . asciiCapableNumberPad)
46+ Divider ( )
47+ . padding ( . leading, Constants . margin)
48+ }
49+
50+ Text ( Localization . footerCouponCode)
51+ . subheadlineStyle ( )
52+ . padding ( . horizontal, Constants . margin)
53+
54+ //TODO: leading aligning for this button
55+ Button {
56+ //TODO: handle action
57+ } label: {
58+ Text ( Localization . regenerateCouponCodeButton)
59+ }
60+ . buttonStyle ( LinkButtonStyle ( ) )
61+ . padding ( . horizontal, Constants . margin)
62+
63+ Button {
64+ //TODO: handle action
65+ } label: {
66+ Text ( Localization . addDescriptionButton)
67+ . bodyStyle ( )
68+ }
69+ . buttonStyle ( SecondaryButtonStyle ( ) )
70+ . padding ( . horizontal, Constants . margin)
71+ . padding ( . bottom, Constants . verticalSpacing)
72+
73+ Group {
74+ TitleAndValueRow ( title: Localization . couponExpiryDate,
75+ value: . placeholder( Localization . couponExpiryDatePlaceholder) ,
76+ selectionStyle: . disclosure, action: { } )
77+ Divider ( )
78+ . padding ( . leading, Constants . margin)
79+ }
80+
81+ Group {
82+ TitleAndToggleRow ( title: Localization . includeFreeShipping, isOn: . constant( false ) )
83+ . padding ( . horizontal, Constants . margin)
84+ Divider ( )
85+ . padding ( . leading, Constants . margin)
86+ }
87+ }
88+
89+ Group {
90+ ListHeaderView ( text: Localization . headerApplyCouponTo. uppercased ( ) , alignment: . left)
91+
92+ // TODO: add a new style with the icon on the left side
93+ Button {
94+ //TODO: handle action
95+ } label: {
96+ Text ( Localization . editProductsButton)
97+ . bodyStyle ( )
98+ }
99+ . buttonStyle ( SecondaryButtonStyle ( ) )
100+ . padding ( . horizontal, Constants . margin)
101+
102+ // TODO: add a new style with the icon on the left side
103+ Button {
104+ //TODO: handle action
105+ } label: {
106+ Text ( Localization . editProductCategoriesButton)
107+ . bodyStyle ( )
108+ }
109+ . buttonStyle ( SecondaryButtonStyle ( ) )
110+ . padding ( . horizontal, Constants . margin)
111+ }
112+
113+ Group {
114+ ListHeaderView ( text: Localization . headerUsageDetails. uppercased ( ) , alignment: . left)
115+
116+ TitleAndValueRow ( title: Localization . usageRestrictions,
117+ value: . placeholder( " " ) ,
118+ selectionStyle: . disclosure, action: { } )
119+ Divider ( )
120+ . padding ( . leading, Constants . margin)
121+ }
122+
123+ Button {
124+ //TODO: handle action
125+ } label: {
126+ Text ( Localization . saveButton)
127+ }
128+ . buttonStyle ( PrimaryButtonStyle ( ) )
129+ . padding ( . horizontal, Constants . margin)
130+ . padding ( . top, Constants . verticalSpacing)
131+ }
132+ }
133+ . ignoresSafeArea ( . container, edges: [ . horizontal, . bottom] )
134+ }
135+ . toolbar {
136+ ToolbarItem ( placement: . cancellationAction) {
137+ Button ( Localization . cancelButton, action: {
138+ presentation. wrappedValue. dismiss ( )
139+ } )
140+ }
141+ }
142+ . navigationTitle ( viewModel. title)
143+ . navigationBarTitleDisplayMode ( . large)
144+ . wooNavigationBarStyle ( )
28145 }
29- . navigationTitle ( viewModel. title)
30- . wooNavigationBarStyle ( )
31146 }
32147}
33148
34149// MARK: - Constants
35150//
36151private extension AddEditCoupon {
152+
153+ enum Constants {
154+ static let margin : CGFloat = 16
155+ static let verticalSpacing : CGFloat = 8
156+ }
157+
37158 enum Localization {
38- static let titleEditPercentageDiscount = NSLocalizedString (
159+ static let cancelButton = NSLocalizedString (
39160 " Cancel " ,
40161 comment: " Cancel button in the navigation bar of the view for adding or editing a coupon. " )
162+ static let headerCouponDetails = NSLocalizedString (
163+ " Coupon details " ,
164+ 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. " )
171+ static let couponCode = NSLocalizedString (
172+ " Coupon Code " ,
173+ comment: " Text field coupon code in the view for adding or editing a coupon. " )
174+ static let footerCouponCode = NSLocalizedString (
175+ " Customers need to enter this code to use the coupon. " ,
176+ comment: " The footer of the text field coupon code in the view for adding or editing a coupon. " )
177+ static let regenerateCouponCodeButton = NSLocalizedString (
178+ " Regenerate Coupon Code " ,
179+ comment: " Button in the view for adding or editing a coupon. " )
180+ static let addDescriptionButton = NSLocalizedString (
181+ " + Add Description (Optional) " ,
182+ comment: " Button for adding a description to a coupon in the view for adding or editing a coupon. " )
183+ static let couponExpiryDate = NSLocalizedString (
184+ " Coupon Expiry Date " ,
185+ comment: " Field in the view for adding or editing a coupon. " )
186+ static let couponExpiryDatePlaceholder = NSLocalizedString (
187+ " None " ,
188+ comment: " Coupon expiry date placeholder in the view for adding or editing a coupon " )
189+ static let includeFreeShipping = NSLocalizedString (
190+ " Include Free Shipping? " ,
191+ comment: " Toggle field in the view for adding or editing a coupon. " )
192+ static let headerApplyCouponTo = NSLocalizedString (
193+ " Apply this coupon to " ,
194+ comment: " Header of the section for applying a coupon to specific products or categories in the view for adding or editing a coupon. " )
195+ static let editProductsButton = NSLocalizedString (
196+ " Edit Products " ,
197+ comment: " Button for specify the products where a coupon can be applied in the view for adding or editing a coupon. " )
198+ static let editProductCategoriesButton = NSLocalizedString (
199+ " Edit Product Categories " ,
200+ comment: " Button for specify the product categories where a coupon can be applied in the view for adding or editing a coupon. " )
201+ static let headerUsageDetails = NSLocalizedString (
202+ " Usage Details " ,
203+ comment: " Header of the section usage details in the view for adding or editing a coupon. " )
204+ static let usageRestrictions = NSLocalizedString (
205+ " Usage Restrictions " ,
206+ comment: " Field in the view for adding or editing a coupon. " )
207+ static let saveButton = NSLocalizedString ( " Save " , comment: " Action for saving a Coupon remotely " )
41208 }
42209}
43210
0 commit comments