diff --git a/PresentationLayer/Constants/Strings/SuccessFailEnum.swift b/PresentationLayer/Constants/Strings/SuccessFailEnum.swift index 18024dfaa..094b6e403 100644 --- a/PresentationLayer/Constants/Strings/SuccessFailEnum.swift +++ b/PresentationLayer/Constants/Strings/SuccessFailEnum.swift @@ -31,6 +31,7 @@ enum SuccessFailEnum: CustomStringConvertible { case history case profile case deleteAccount + case editLocation var description: String { switch self { @@ -80,6 +81,8 @@ enum SuccessFailEnum: CustomStringConvertible { return Constants.profile case .deleteAccount: return "" + case .editLocation: + return "" } } } diff --git a/PresentationLayer/UI Components/Base Components/Fail Success /FailSuccessStateObject.swift b/PresentationLayer/UI Components/Base Components/Fail Success /FailSuccessStateObject.swift index c88cbf866..5fa902da8 100644 --- a/PresentationLayer/UI Components/Base Components/Fail Success /FailSuccessStateObject.swift +++ b/PresentationLayer/UI Components/Base Components/Fail Success /FailSuccessStateObject.swift @@ -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) + } } diff --git a/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationView.swift b/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationView.swift index 578a6657e..ffb062f34 100644 --- a/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationView.swift +++ b/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationView.swift @@ -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)) { - acknowledgementView + VStack(spacing: CGFloat(.defaultSpacing)) { + CardWarningView(message: LocalizableString.SelectStationLocation.warningText(DisplayedLinks.polAlgorithm.linkURL).localized, + closeAction: nil, + content: { EmptyView() }) - CardWarningView(message: LocalizableString.SelectStationLocation.warningText(DisplayedLinks.polAlgorithm.linkURL).localized, - closeAction: nil, - content: { EmptyView() }) + acknowledgementView - Button { - viewModel.handleConfirmTap() - } label: { - Text(LocalizableString.SelectStationLocation.buttonTitle.localized) + 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() } diff --git a/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationViewModel.swift b/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationViewModel.swift index 6a109d96d..7e2ced66f 100644 --- a/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationViewModel.swift +++ b/PresentationLayer/UI Components/Screens/Select Station Location/SelectStationLocationViewModel.swift @@ -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 = .init() @@ -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 { @@ -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 { diff --git a/wxm-ios/Resources/Localizable/Localizable.xcstrings b/wxm-ios/Resources/Localizable/Localizable.xcstrings index 3598c28c1..0677cf737 100644 --- a/wxm-ios/Resources/Localizable/Localizable.xcstrings +++ b/wxm-ios/Resources/Localizable/Localizable.xcstrings @@ -5271,7 +5271,40 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "Station relocation is subject to a relocation fee.
[Read more here](%@)" + "value" : "Editing the station’s location is subject to a **relocation penalty** and the station will be excluded from rewards for the next **2 days**.
[Read more here](%@)" + } + } + } + }, + "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!" } } } diff --git a/wxm-ios/Resources/Localizable/LocalizableString+SelectStationLocation.swift b/wxm-ios/Resources/Localizable/LocalizableString+SelectStationLocation.swift index d64e0047f..49293f2ec 100644 --- a/wxm-ios/Resources/Localizable/LocalizableString+SelectStationLocation.swift +++ b/wxm-ios/Resources/Localizable/LocalizableString+SelectStationLocation.swift @@ -14,6 +14,9 @@ extension LocalizableString { case termsText case warningText(String) case buttonTitle + case successTitle + case successDescription + case successButtonTitle } } @@ -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" } } }