Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fe 591 change relocation notice text #20

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
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()
}
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
35 changes: 34 additions & 1 deletion wxm-ios/Resources/Localizable/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
}
}
}
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"
}
}
}
Loading