Skip to content

Commit 25432d4

Browse files
committed
Revert "Configure AddEditCoupon to display Coupon creation success sheet when the ViewModel signals the presentation value"
This reverts commit 5a364d2
1 parent 7e1855e commit 25432d4

File tree

1 file changed

+92
-92
lines changed

1 file changed

+92
-92
lines changed

WooCommerce/Classes/ViewRelated/Coupons/Add and Edit Coupons/AddEditCoupon.swift

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -92,166 +92,166 @@ struct AddEditCoupon: View {
9292

9393
Group {
9494
TitleAndValueRow(title: Localization.discountType,
95-
value: viewModel.discountTypeValue,
96-
selectionStyle: .disclosure, action: {
95+
value: viewModel.discountTypeValue,
96+
selectionStyle: .disclosure, action: {
9797
// TODO: remove this workaround with `adaptiveSheetPresentationController` when we drop support for iOS 14
9898
if idiom == .pad {
9999
showingDiscountType.toggle()
100100
} else {
101101
discountTypeHandler(viewProperties)
102102
}
103103
}).popover(isPresented: $showingDiscountType) {
104-
let command = DiscountTypeBottomSheetListSelectorCommand(selected: viewModel.discountType) { selectedType in
105-
viewModel.discountType = selectedType
106-
showingDiscountType.toggle()
107-
}
108-
BottomSheetListSelector(viewProperties: viewProperties, command: command, onDismiss: nil)
109-
}
104+
let command = DiscountTypeBottomSheetListSelectorCommand(selected: viewModel.discountType) { selectedType in
105+
viewModel.discountType = selectedType
106+
showingDiscountType.toggle()
107+
}
108+
BottomSheetListSelector(viewProperties: viewProperties, command: command, onDismiss: nil)
109+
}
110110

111111
Divider()
112-
.padding(.leading, Constants.margin)
112+
.padding(.leading, Constants.margin)
113113

114114
TitleAndTextFieldRow(title: viewModel.amountLabel,
115-
placeholder: "0",
116-
text: $viewModel.amountField,
117-
editable: true,
118-
fieldAlignment: .leading,
119-
keyboardType: .decimalPad,
120-
inputFormatter: CouponAmountInputFormatter())
115+
placeholder: "0",
116+
text: $viewModel.amountField,
117+
editable: true,
118+
fieldAlignment: .leading,
119+
keyboardType: .decimalPad,
120+
inputFormatter: CouponAmountInputFormatter())
121121
Divider()
122-
.padding(.leading, Constants.margin)
122+
.padding(.leading, Constants.margin)
123123

124124
Text(viewModel.amountSubtitleLabel)
125-
.subheadlineStyle()
126-
.padding(.horizontal, Constants.margin)
125+
.subheadlineStyle()
126+
.padding(.horizontal, Constants.margin)
127127
}
128-
.padding(.bottom, Constants.verticalSpacing)
128+
.padding(.bottom, Constants.verticalSpacing)
129129

130130
Group {
131131
TitleAndTextFieldRow(title: Localization.couponCode,
132-
placeholder: Localization.couponCodePlaceholder,
133-
text: $viewModel.codeField,
134-
editable: true,
135-
fieldAlignment: .leading,
136-
keyboardType: .default,
137-
inputFormatter: CouponCodeInputFormatter())
132+
placeholder: Localization.couponCodePlaceholder,
133+
text: $viewModel.codeField,
134+
editable: true,
135+
fieldAlignment: .leading,
136+
keyboardType: .default,
137+
inputFormatter: CouponCodeInputFormatter())
138138
Divider()
139-
.padding(.leading, Constants.margin)
140-
.padding(.bottom, Constants.verticalSpacing)
139+
.padding(.leading, Constants.margin)
140+
.padding(.bottom, Constants.verticalSpacing)
141141
Text(Localization.footerCouponCode)
142-
.subheadlineStyle()
143-
.padding(.horizontal, Constants.margin)
142+
.subheadlineStyle()
143+
.padding(.horizontal, Constants.margin)
144144
}
145-
.padding(.bottom, Constants.verticalSpacing)
145+
.padding(.bottom, Constants.verticalSpacing)
146146

147147
Button {
148148
viewModel.generateRandomCouponCode()
149149
} label: {
150150
Text(Localization.regenerateCouponCodeButton)
151151
}
152-
.buttonStyle(LinkButtonStyle())
153-
.fixedSize()
154-
.frame(maxWidth: .infinity, alignment: .leading)
155-
.padding(.bottom, Constants.verticalSpacing)
152+
.buttonStyle(LinkButtonStyle())
153+
.fixedSize()
154+
.frame(maxWidth: .infinity, alignment: .leading)
155+
.padding(.bottom, Constants.verticalSpacing)
156156

157157
Button {
158158
showingEditDescription = true
159159
} label: {
160160
HStack {
161161
Image(uiImage: viewModel.editDescriptionIcon)
162-
.resizable()
163-
.colorMultiply(Color(.text))
164-
.frame(width: Constants.iconSize, height: Constants.iconSize)
162+
.resizable()
163+
.colorMultiply(Color(.text))
164+
.frame(width: Constants.iconSize, height: Constants.iconSize)
165165
Text(viewModel.editDescriptionLabel)
166-
.bodyStyle()
166+
.bodyStyle()
167167
}
168168
}
169-
.buttonStyle(SecondaryButtonStyle())
170-
.padding(.horizontal, Constants.margin)
171-
.padding(.bottom, Constants.verticalSpacing)
169+
.buttonStyle(SecondaryButtonStyle())
170+
.padding(.horizontal, Constants.margin)
171+
.padding(.bottom, Constants.verticalSpacing)
172172

173173
Group {
174174
TitleAndValueRow(title: Localization.couponExpiryDate,
175-
value: viewModel.expiryDateValue,
176-
selectionStyle: .disclosure, action: {
175+
value: viewModel.expiryDateValue,
176+
selectionStyle: .disclosure, action: {
177177
showingCouponExpiryDate = true
178178
})
179179
Divider()
180-
.padding(.leading, Constants.margin)
180+
.padding(.leading, Constants.margin)
181181
}
182-
.padding(.bottom, Constants.verticalSpacing)
182+
.padding(.bottom, Constants.verticalSpacing)
183183

184184
Group {
185185
TitleAndToggleRow(title: Localization.includeFreeShipping, isOn: $viewModel.freeShipping)
186-
.padding(.horizontal, Constants.margin)
186+
.padding(.horizontal, Constants.margin)
187187
Divider()
188-
.padding(.leading, Constants.margin)
188+
.padding(.leading, Constants.margin)
189189
}
190-
.padding(.bottom, Constants.verticalSpacing)
190+
.padding(.bottom, Constants.verticalSpacing)
191191
}
192192

193193
Group {
194194
ListHeaderView(text: Localization.headerApplyCouponTo.uppercased(), alignment: .left)
195-
.padding(.bottom, Constants.verticalSpacing)
195+
.padding(.bottom, Constants.verticalSpacing)
196196

197197
Button {
198198
showingSelectProducts = true
199199
} label: {
200200
HStack {
201201
if viewModel.hasSelectedProducts {
202202
Image(uiImage: .pencilImage)
203-
.resizable()
204-
.colorMultiply(Color(.text))
205-
.frame(width: Constants.iconSize, height: Constants.iconSize)
203+
.resizable()
204+
.colorMultiply(Color(.text))
205+
.frame(width: Constants.iconSize, height: Constants.iconSize)
206206
Text(viewModel.editProductsButtonTitle)
207-
.bodyStyle()
207+
.bodyStyle()
208208
} else {
209209
Text(Localization.allProductsButton)
210-
.bodyStyle()
210+
.bodyStyle()
211211
}
212212
}
213213
}
214-
.buttonStyle(SecondaryButtonStyle())
215-
.padding(.horizontal, Constants.margin)
216-
.padding(.bottom, Constants.verticalSpacing)
214+
.buttonStyle(SecondaryButtonStyle())
215+
.padding(.horizontal, Constants.margin)
216+
.padding(.bottom, Constants.verticalSpacing)
217217

218218
Button {
219219
showingSelectCategories = true
220220
} label: {
221221
HStack {
222222
if viewModel.hasSelectedCategories {
223223
Image(uiImage: .pencilImage)
224-
.resizable()
225-
.colorMultiply(Color(.text))
226-
.frame(width: Constants.iconSize, height: Constants.iconSize)
224+
.resizable()
225+
.colorMultiply(Color(.text))
226+
.frame(width: Constants.iconSize, height: Constants.iconSize)
227227
Text(viewModel.editCategoriesButtonTitle)
228-
.bodyStyle()
228+
.bodyStyle()
229229
} else {
230230
Image(uiImage: .plusImage)
231-
.resizable()
232-
.frame(width: Constants.iconSize, height: Constants.iconSize)
231+
.resizable()
232+
.frame(width: Constants.iconSize, height: Constants.iconSize)
233233
Text(Localization.selectCategoriesButton)
234-
.bodyStyle()
234+
.bodyStyle()
235235
}
236236
}
237237
}
238-
.buttonStyle(SecondaryButtonStyle())
239-
.padding(.horizontal, Constants.margin)
238+
.buttonStyle(SecondaryButtonStyle())
239+
.padding(.horizontal, Constants.margin)
240240
}
241-
.padding(.bottom, Constants.verticalSpacing)
241+
.padding(.bottom, Constants.verticalSpacing)
242242

243243
Group {
244244
ListHeaderView(text: Localization.headerUsageDetails.uppercased(), alignment: .left)
245245

246246
TitleAndValueRow(title: Localization.usageRestrictions,
247-
value: .placeholder(""),
248-
selectionStyle: .disclosure, action: {
247+
value: .placeholder(""),
248+
selectionStyle: .disclosure, action: {
249249
showingCouponRestrictions = true
250250
})
251251
Divider()
252-
.padding(.leading, Constants.margin)
252+
.padding(.leading, Constants.margin)
253253
}
254-
.padding(.bottom, Constants.verticalSpacing)
254+
.padding(.bottom, Constants.verticalSpacing)
255255

256256
Button {
257257
// This should be replaced with `@FocusState` when we drop support for iOS 14
@@ -262,47 +262,47 @@ struct AddEditCoupon: View {
262262
} label: {
263263
Text(viewModel.addEditCouponButtonText)
264264
}
265-
.buttonStyle(PrimaryLoadingButtonStyle(isLoading: viewModel.isLoading))
266-
.padding(.horizontal, Constants.margin)
267-
.padding([.top, .bottom], Constants.verticalSpacing)
268-
.disabled(!viewModel.hasChangesMade)
265+
.buttonStyle(PrimaryLoadingButtonStyle(isLoading: viewModel.isLoading))
266+
.padding(.horizontal, Constants.margin)
267+
.padding([.top, .bottom], Constants.verticalSpacing)
268+
.disabled(!viewModel.hasChangesMade)
269269

270270
LazyNavigationLink(destination: FullScreenTextView(title: Localization.titleEditDescriptionView,
271-
text: $viewModel.descriptionField,
272-
placeholder: Localization.addDescriptionPlaceholder),
273-
isActive: $showingEditDescription) {
271+
text: $viewModel.descriptionField,
272+
placeholder: Localization.addDescriptionPlaceholder),
273+
isActive: $showingEditDescription) {
274274
EmptyView()
275275
}
276276

277277
LazyNavigationLink(destination: CouponExpiryDateView(date: viewModel.expiryDateField ?? Date(),
278-
isRemovalEnabled: viewModel.expiryDateField != nil,
279-
timezone: viewModel.timezone,
280-
onCompletion: { updatedExpiryDate in
281-
viewModel.expiryDateField = updatedExpiryDate
282-
}), isActive: $showingCouponExpiryDate) {
278+
isRemovalEnabled: viewModel.expiryDateField != nil,
279+
timezone: viewModel.timezone,
280+
onCompletion: { updatedExpiryDate in
281+
viewModel.expiryDateField = updatedExpiryDate
282+
}), isActive: $showingCouponExpiryDate) {
283283
EmptyView()
284284
}
285285

286286
LazyNavigationLink(destination: CouponRestrictions(viewModel: viewModel.couponRestrictionsViewModel),
287-
isActive: $showingCouponRestrictions) {
287+
isActive: $showingCouponRestrictions) {
288288
EmptyView()
289289
}
290290
}
291291
}
292292
}
293293
.sheet(isPresented: $showingSelectProducts) {
294294
ProductSelector(configuration: ProductSelector.Configuration.productsForCoupons,
295-
isPresented: $showingSelectProducts,
296-
viewModel: viewModel.productSelectorViewModel)
297-
.onDisappear {
298-
viewModel.productSelectorViewModel.clearSearchAndFilters()
299-
}
295+
isPresented: $showingSelectProducts,
296+
viewModel: viewModel.productSelectorViewModel)
297+
.onDisappear {
298+
viewModel.productSelectorViewModel.clearSearchAndFilters()
299+
}
300300
}
301301
.sheet(isPresented: $showingSelectCategories) {
302302
ProductCategorySelector(isPresented: $showingSelectCategories,
303-
viewConfig: categorySelectorConfig,
304-
categoryListConfig: categoryListConfig,
305-
viewModel: viewModel.categorySelectorViewModel)
303+
viewConfig: categorySelectorConfig,
304+
categoryListConfig: categoryListConfig,
305+
viewModel: viewModel.categorySelectorViewModel)
306306
}
307307
.sheet(isPresented: $viewModel.showingCouponCreationSuccess) {
308308
let couponCode = viewModel.coupon?.code ?? ""

0 commit comments

Comments
 (0)