Skip to content

Commit

Permalink
Show success
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantelis Giazitsis committed Feb 19, 2024
1 parent 451ea45 commit 1ccf218
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 26 deletions.
3 changes: 3 additions & 0 deletions PresentationLayer/Constants/Strings/SuccessFailEnum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum SuccessFailEnum: CustomStringConvertible {
case history
case profile
case deleteAccount
case editLocation

var description: String {
switch self {
Expand Down Expand Up @@ -80,6 +81,8 @@ enum SuccessFailEnum: CustomStringConvertible {
return Constants.profile
case .deleteAccount:
return ""
case .editLocation:
return ""
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ extension FailSuccessStateObject {
cancelAction: nil,
retryAction: {})
}

static var emptyObj: FailSuccessStateObject {
FailSuccessStateObject(type: .noView,
title: "",
subtitle: nil,
cancelTitle: nil,
retryTitle: nil,
contactSupportAction: nil,
cancelAction: nil,
retryAction: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,44 @@ struct SelectStationLocationView: View {
.ignoresSafeArea()

VStack(spacing: 0.0) {
GeometryReader { proxy in
ZStack {
MapBoxClaimDeviceView(location: $viewModel.selectedCoordinate,
annotationTitle: Binding(get: { viewModel.selectedDeviceLocation?.name }, set: { _ in }),
geometryProxyForFrameOfMapView: proxy.frame(in: .local))
.cornerRadius(CGFloat(.cardCornerRadius), corners: [.topLeft, .topRight])

searchArea
VStack(spacing: 0.0) {
GeometryReader { proxy in
ZStack {
MapBoxClaimDeviceView(location: $viewModel.selectedCoordinate,
annotationTitle: Binding(get: { viewModel.selectedDeviceLocation?.name }, set: { _ in }),
geometryProxyForFrameOfMapView: proxy.frame(in: .local))
.cornerRadius(CGFloat(.cardCornerRadius), corners: [.topLeft, .topRight])

searchArea
}
}
}

VStack(spacing: CGFloat(.defaultSpacing)) {
CardWarningView(message: LocalizableString.SelectStationLocation.warningText(DisplayedLinks.polAlgorithm.linkURL).localized,
closeAction: nil,
content: { EmptyView() })

acknowledgementView

Button {
viewModel.handleConfirmTap()
} label: {
Text(LocalizableString.SelectStationLocation.buttonTitle.localized)
VStack(spacing: CGFloat(.defaultSpacing)) {
CardWarningView(message: LocalizableString.SelectStationLocation.warningText(DisplayedLinks.polAlgorithm.linkURL).localized,
closeAction: nil,
content: { EmptyView() })

acknowledgementView

Button {
viewModel.handleConfirmTap()
} label: {
Text(LocalizableString.SelectStationLocation.buttonTitle.localized)
}
.buttonStyle(WXMButtonStyle.filled())
.disabled(!viewModel.termsAccepted)
}
.buttonStyle(WXMButtonStyle.filled())
.disabled(!viewModel.termsAccepted)
.WXMCardStyle(cornerRadius: 0.0)
.cornerRadius(CGFloat(.cardCornerRadius), corners: [.bottomLeft, .bottomRight])
}
.WXMCardStyle(cornerRadius: 0.0)
.cornerRadius(CGFloat(.cardCornerRadius), corners: [.bottomLeft, .bottomRight])
.success(show: $viewModel.isSuccessful, obj: viewModel.successObj)
}
.padding(.horizontal, CGFloat(.defaultSidePadding))
.padding(.bottom, CGFloat(.defaultSidePadding))
.cornerRadius(CGFloat(.cardCornerRadius), corners: [.topLeft, .topRight])
.wxmShadow()
.if(!viewModel.isSuccessful) { view in
view.wxmShadow()
}
.onTapGesture {
hideKeyboard()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class SelectStationLocationViewModel: ObservableObject {
@Published var searchTerm: String = ""
@Published private(set) var selectedDeviceLocation: DeviceLocation?
@Published private(set) var searchResults: [DeviceLocationSearchResult] = []
@Published var isSuccessful: Bool = false
private(set) var successObj: FailSuccessStateObject = .emptyObj

private var latestTask: Cancellable?
private var cancellableSet: Set<AnyCancellable> = .init()
Expand Down Expand Up @@ -120,7 +122,7 @@ private extension SelectStationLocationViewModel {
switch reslut {
case .success(let device):
self?.delegate?.locationUpdated(with: device)
Router.shared.pop()
self?.showSuccess()
case .failure(let error):
let info = error.uiInfo
if let message = info.description?.attributedMarkdown {
Expand All @@ -133,6 +135,22 @@ private extension SelectStationLocationViewModel {
print(error)
}
}

func showSuccess() {
let obj = FailSuccessStateObject(type: .editLocation,
title: LocalizableString.SelectStationLocation.successTitle.localized,
subtitle: LocalizableString.SelectStationLocation.successDescription.localized.attributedMarkdown,
cancelTitle: nil,
retryTitle: LocalizableString.SelectStationLocation.successButtonTitle.localized,
actionButtonsAtTheBottom: true,
contactSupportAction: nil,
cancelAction: nil) {
Router.shared.pop()
}

successObj = obj
isSuccessful = true
}
}

extension SelectStationLocationViewModel: HashableViewModel {
Expand Down
33 changes: 33 additions & 0 deletions wxm-ios/Resources/Localizable/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -5276,6 +5276,39 @@
}
}
},
"select_station_success_button_title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Dismiss"
}
}
}
},
"select_station_success_description" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Your station’s location has been updated. The station should start earning rewards again when your location is verified by our systems in **~2-3** days."
}
}
}
},
"select_station_success_title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Location Updated!"
}
}
}
},
"send_email" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ extension LocalizableString {
case termsText
case warningText(String)
case buttonTitle
case successTitle
case successDescription
case successButtonTitle
}
}

Expand Down Expand Up @@ -41,6 +44,12 @@ extension LocalizableString.SelectStationLocation: WXMLocalizable {
return "select_station_location_warning_text_format"
case .buttonTitle:
return "select_station_location_button_title"
case .successTitle:
return "select_station_success_title"
case .successDescription:
return "select_station_success_description"
case .successButtonTitle:
return "select_station_success_button_title"
}
}
}

0 comments on commit 1ccf218

Please sign in to comment.