From 3a8240756b36a50255f3171ae3286191272f931b Mon Sep 17 00:00:00 2001 From: Bonsung Koo Date: Mon, 3 Feb 2025 18:29:53 +1300 Subject: [PATCH 1/3] `AUTO_GENERATED` surcharge status is handled. #64 (#65) --- .../Surcharge/SurchargeStatus.swift | 2 +- .../Sources/Surcharge/SurchargeStatus.swift | 2 +- .../Sources/ConvertPlaceDTOtoEntity.swift | 2 + .../Sources/Place/GetPlaceUsecase.swift | 2 + .../Sources/Place/GetPlacesUsecase.swift | 2 + .../Sources/Surcharge/SurchargeStatus.swift | 2 +- .../Text+extension/surchargeStatus.swift | 4 + .../Main/Sources/SearchResult/PlaceView.swift | 4 + .../Sources/Button/ContributeButton.swift | 8 +- .../Sources/Surcharge/SurchargeView.swift | 13 +- .../yellow800.colorset/Contents.json | 56 ++++++ .../Localise/en.lproj/Localizable.strings | 6 +- .../Localise/ko.lproj/Localizable.strings | 6 +- .../Sources/SurchargeStatusHelpView.swift | 185 ++++++++++++------ .../Sources/ConvertPlaceEntityToModel.swift | 2 + 15 files changed, 220 insertions(+), 76 deletions(-) create mode 100644 Surcharges/PresentationLayer/UIs/Resources/Resources/Assets/Colors.xcassets/yellow800.colorset/Contents.json diff --git a/Surcharges/DataLayer/DTOs/Sources/ServerSide/Surcharge/SurchargeStatus.swift b/Surcharges/DataLayer/DTOs/Sources/ServerSide/Surcharge/SurchargeStatus.swift index 9ba73c6..3bf3406 100644 --- a/Surcharges/DataLayer/DTOs/Sources/ServerSide/Surcharge/SurchargeStatus.swift +++ b/Surcharges/DataLayer/DTOs/Sources/ServerSide/Surcharge/SurchargeStatus.swift @@ -9,5 +9,5 @@ import Foundation public enum SurchargeStatus: String, Codable, Equatable, Sendable { - case UNKNOWN, REPORTED, CONFIRMED + case UNKNOWN, REPORTED, CONFIRMED, AUTO_GENERATED, REJECTED } diff --git a/Surcharges/DomainLayer/Entities/Sources/Surcharge/SurchargeStatus.swift b/Surcharges/DomainLayer/Entities/Sources/Surcharge/SurchargeStatus.swift index a3aee2d..5e10130 100644 --- a/Surcharges/DomainLayer/Entities/Sources/Surcharge/SurchargeStatus.swift +++ b/Surcharges/DomainLayer/Entities/Sources/Surcharge/SurchargeStatus.swift @@ -9,5 +9,5 @@ import Foundation public enum SurchargeStatus: String, Codable, Equatable, Sendable { - case unknown, reported, confirmed + case unknown, reported, confirmed, autoGenerated, rejected } diff --git a/Surcharges/DomainLayer/UseCases/Sources/ConvertPlaceDTOtoEntity.swift b/Surcharges/DomainLayer/UseCases/Sources/ConvertPlaceDTOtoEntity.swift index bd29949..cd4e0db 100644 --- a/Surcharges/DomainLayer/UseCases/Sources/ConvertPlaceDTOtoEntity.swift +++ b/Surcharges/DomainLayer/UseCases/Sources/ConvertPlaceDTOtoEntity.swift @@ -37,6 +37,8 @@ struct ConvertDTOtoEntity { case .UNKNOWN: return .unknown case .REPORTED: return .reported case .CONFIRMED: return .confirmed + case .AUTO_GENERATED: return .autoGenerated + case .REJECTED: return .rejected } } diff --git a/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlaceUsecase.swift b/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlaceUsecase.swift index e83a848..fe2c5a5 100644 --- a/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlaceUsecase.swift +++ b/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlaceUsecase.swift @@ -37,6 +37,8 @@ public struct GetPlaceUsecase: GetPlaceUsecaseProtoc case .UNKNOWN: return .unknown case .REPORTED: return .reported case .CONFIRMED: return .confirmed + case .AUTO_GENERATED: return .autoGenerated + case .REJECTED: return .rejected case .none: return .unknown } } diff --git a/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlacesUsecase.swift b/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlacesUsecase.swift index 95ff87f..ef3237e 100644 --- a/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlacesUsecase.swift +++ b/Surcharges/DomainLayer/UseCases/Sources/Place/GetPlacesUsecase.swift @@ -52,6 +52,8 @@ public struct GetPlacesUsecase: GetPlacesUsecaseProt case .UNKNOWN: return .unknown case .REPORTED: return .reported case .CONFIRMED: return .confirmed + case .AUTO_GENERATED: return .autoGenerated + case .REJECTED: return .rejected case .none: return .unknown } } diff --git a/Surcharges/PresentationLayer/Models/Sources/Surcharge/SurchargeStatus.swift b/Surcharges/PresentationLayer/Models/Sources/Surcharge/SurchargeStatus.swift index 4e67f67..da23067 100644 --- a/Surcharges/PresentationLayer/Models/Sources/Surcharge/SurchargeStatus.swift +++ b/Surcharges/PresentationLayer/Models/Sources/Surcharge/SurchargeStatus.swift @@ -9,5 +9,5 @@ import Foundation public enum SurchargeStatus: Equatable, Sendable { - case notDetermined, unknown, reported, confirmed + case notDetermined, unknown, reported, confirmed, autoGenerated, rejected } diff --git a/Surcharges/PresentationLayer/UIs/CommonUI/Sources/Text+extension/surchargeStatus.swift b/Surcharges/PresentationLayer/UIs/CommonUI/Sources/Text+extension/surchargeStatus.swift index 63f65d4..85f46ed 100644 --- a/Surcharges/PresentationLayer/UIs/CommonUI/Sources/Text+extension/surchargeStatus.swift +++ b/Surcharges/PresentationLayer/UIs/CommonUI/Sources/Text+extension/surchargeStatus.swift @@ -23,6 +23,10 @@ public extension View { self._style(foreground: R.color.green800.color, background: R.color.green300.color) } + func surchargeStatusAutoGenerated() -> some View { + self._style(foreground: R.color.yellow800.color, background: R.color.yellow300.color) + } + private func _style(foreground: Color, background: Color) -> some View { self .foregroundStyle(foreground) diff --git a/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift b/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift index 3dbcc77..ad8ea2f 100644 --- a/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift +++ b/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift @@ -38,6 +38,10 @@ struct PlaceView: View { } else if _place.surcharge.status == .confirmed { Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") .surchargeStatusConfirmed() + + } else if _place.surcharge.status == .autoGenerated { + Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") + .surchargeStatusAutoGenerated() } } } diff --git a/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Button/ContributeButton.swift b/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Button/ContributeButton.swift index c769dd3..6136832 100644 --- a/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Button/ContributeButton.swift +++ b/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Button/ContributeButton.swift @@ -26,9 +26,9 @@ struct ContributeButton: View { Button { switch _surcharge.status { - case .notDetermined, .reported: + case .notDetermined, .reported, .rejected: break - case .unknown, .confirmed: + case .unknown, .confirmed, .autoGenerated: _action() } @@ -45,10 +45,10 @@ struct ContributeButton: View { private func buttonText() -> String { switch _surcharge.status { - case .notDetermined: return "" + case .notDetermined, .rejected: return "" case .unknown: return "\(R.string.localizable.reportForUnknownButtonTitle())๐Ÿ™๐Ÿป" case .reported: return "" - case .confirmed: return "\(R.string.localizable.reportForConfirmedButtonTitle())๐Ÿค”" + case .confirmed, .autoGenerated: return "\(R.string.localizable.reportForConfirmedButtonTitle())๐Ÿค”" } } } diff --git a/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift b/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift index 35a3546..f183166 100644 --- a/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift +++ b/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift @@ -75,7 +75,7 @@ struct SurchargeView: View { .shimmering(active: _isLoading) .cornerRadius(5) - case .unknown: + case .unknown, .rejected: Text("\(R.string.localizable.surchargeStatusUnknownMessage())๐Ÿ˜ž") .font(.headline) @@ -102,6 +102,15 @@ struct SurchargeView: View { .font(.headline) .surchargeStatusConfirmed() + case .autoGenerated: + + Text(verbatim: _rateText(rate: _surcharge.rate)) + .font(.largeTitle) + + Text(verbatim: R.string.localizable.surchargeStatusAutoGenerated()) + .font(.headline) + .surchargeStatusAutoGenerated() + } if let updatedDate = _surcharge.updatedDate { @@ -118,7 +127,7 @@ struct SurchargeView: View { private func _rateText(rate: Double?) -> String { if let rate = rate { - return rate == 0 ? "\(R.string.localizable.zeroRates)๐ŸŽ‰" : "\(rate)%" + return rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%" } else { return R.string.localizable.surchargeStatusUnknown() } diff --git a/Surcharges/PresentationLayer/UIs/Resources/Resources/Assets/Colors.xcassets/yellow800.colorset/Contents.json b/Surcharges/PresentationLayer/UIs/Resources/Resources/Assets/Colors.xcassets/yellow800.colorset/Contents.json new file mode 100644 index 0000000..a542e83 --- /dev/null +++ b/Surcharges/PresentationLayer/UIs/Resources/Resources/Assets/Colors.xcassets/yellow800.colorset/Contents.json @@ -0,0 +1,56 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "14", + "green" : "77", + "red" : "133" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "light" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "14", + "green" : "77", + "red" : "133" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "13", + "green" : "77", + "red" : "133" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings b/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings index 559a40b..c4280af 100644 --- a/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings +++ b/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings @@ -26,6 +26,7 @@ "surchargeStatusUnknown"="Unknown"; "surchargeStatusReported"="Reported"; "surchargeStatusConfirmed"="Confirmed"; +"surchargeStatusAutoGenerated"="Auto-Generated"; "updatedAt"="Updated at %@"; "recognitionSuccess"="Recognised๐ŸŽ‰, Just in case please check the amounts, if it may not accurate."; "recognitionNameNotMatched"="Place name is not matched."; @@ -49,7 +50,7 @@ "backToPlace"="Back to place"; "or"="or"; "surchargeStatusHelpDisclaimer"="Disclaimer: Although we are trying to provide the most accurate information, there may be some inaccuracies. Please use the information as a reference."; -"surchargeStatusHelpDiscription"="There are three types of surcharge status:"; +"surchargeStatusHelpDiscription"="There are four types of surcharge status:"; "surchargeStatusHelpUnknown1"="Means the surcharge status is not yet known. We're please to receive your report."; "surchargeStatusHelpUnknown2"="Remeber, Red colour is unknown about surcharge."; "surchargeStatusHelpUnknown2Emphasise"="Red"; @@ -59,6 +60,9 @@ "surchargeStatusHelpConfirmed1"="Means the surcharge status is confirmed by us. It's highly likely to be accurate.\nBut still, it may be accurate. Please check the updated date in place detail."; "surchargeStatusHelpConfirmed2"="Remeber, Green colour is confirmed for surcharge information."; "surchargeStatusHelpConfirmed2Emphasise"="Green"; +"surchargeStatusHelpAutoGenerated1"="Big franchises likely do not charge surcharge. So we automatically set surcharge as zero. It may not be accurate."; +"surchargeStatusHelpAutoGenerated2"="Remember, Yellow colour is auto-generated surcharge information."; +"surchargeStatusHelpAutoGenerated2Emphasise"="Yellow"; "gotIt"="Got it"; "toastUnauthorised"="Do you want some permissions?"; "toastOutOfRegion"="Only available in"; diff --git a/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/ko.lproj/Localizable.strings b/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/ko.lproj/Localizable.strings index 42ef01d..bef34e4 100644 --- a/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/ko.lproj/Localizable.strings +++ b/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/ko.lproj/Localizable.strings @@ -26,6 +26,7 @@ "surchargeStatusUnknown"="์•Œ๋ ค์ง€์ง€ ์•Š์Œ"; "surchargeStatusReported"="๋ณด๊ณ  ๋จ"; "surchargeStatusConfirmed"="ํ™•์ธ ๋จ"; +"surchargeStatusAutoGenerated"="์ž๋™ ์ƒ์„ฑ ๋จ"; "updatedAt"="%@์— ์—…๋ฐ์ดํŠธ ๋จ"; "recognitionSuccess"="์ธ์‹์™„๋ฃŒ๐ŸŽ‰, ๋งŒ์•ฝ์„ ์œ„ํ•ด ๋‹ค์‹œ ํ•œ ๋ฒˆ ์ž…๋ ฅ ๋œ ๊ธˆ์•ก์„ ํ™•์ธํ•ด ์ฃผ์„ธ์š”."; "recognitionNameNotMatched"="์ƒํ˜ธ๋ช…์ด ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."; @@ -49,7 +50,7 @@ "backToPlace"="์‚ผ์ •์œผ๋กœ ๋Œ์•„๊ฐ€๊ธฐ"; "or"="๋˜๋Š”"; "surchargeStatusHelpDisclaimer"="๋ฉด์ฑ…์กฐํ•ญ: ์ €ํฌ๋Š” ์ •ํ™•ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋ ค๊ณ  ๋…ธ๋ ฅํ•ฉ๋‹ˆ๋‹ค๋งŒ, ๋ถ€์ •ํ™•ํ•œ ์ •๋ณด๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Surcharge์—์„œ ์ œ๊ณต๋˜๋Š” ์ •๋ณด๋Š” ์ฐธ๊ณ ์šฉ์œผ๋กœ๋งŒ ์‚ฌ์šฉํ•ด ์ฃผ์„ธ์š”."; -"surchargeStatusHelpDiscription"="์ด ์„ธ๊ฐœ์˜ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์ƒํƒœ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค:"; +"surchargeStatusHelpDiscription"="์ด ๋„ค๊ฐœ์˜ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์ƒํƒœ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค:"; "surchargeStatusHelpUnknown1"="๋ณด๊ณ  ๋œ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์ •๋ณด๊ฐ€ ์—†์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ํ˜น์‹œ ์–ด๋”˜๊ฐ€์—์„œ ๊ฒฐ์ œํ•œ ์˜์ˆ˜์ฆ์„ ๊ฐ€์ง€๊ณ  ๊ณ„์‹œ๋‹ค๋ฉด ์ €ํฌ์—๊ฒŒ ์•Œ๋ ค์ฃผ์„ธ์š”."; "surchargeStatusHelpUnknown2"="Surcharge์˜ ์–ด๋””์„œ๋‚˜ ๋นจ๊ฐ„์ƒ‰์€ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์ •๋ณด๊ฐ€ ์•Œ๋ ค์ง€์ง€ ์•Š์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค."; "surchargeStatusHelpUnknown2Emphasise"="๋นจ๊ฐ„์ƒ‰"; @@ -59,6 +60,9 @@ "surchargeStatusHelpConfirmed1"="๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์ •๋ณด๊ฐ€ ํ™•์ธ ๋˜์—ˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์ด ์ •๋ณด๋Š” ์ •ํ™•ํ•  ํ™•๋ฅ ์ด ๋†’์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์—ฌ์ „ํžˆ, ๋ถ€์ •ํ™• ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ƒ์  ์ƒ์ œ ์ •๋ณด์—์„œ ์—…๋ฐ์ดํŠธ ๋‚ ์งœ๋ฅผ ํ™•์ธํ•ด ์ฃผ์„ธ์š”."; "surchargeStatusHelpConfirmed2"="Surcharge์˜ ์–ด๋””์„œ๋‚˜ ์ดˆ๋ก์ƒ‰์€ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์ •๋ณด๊ฐ€ ํ™•์ธ ๋˜์—ˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค."; "surchargeStatusHelpConfirmed2Emphasise"="์ดˆ๋ก์ƒ‰"; +"surchargeStatusHelpAutoGenerated1"="ํ”„๋ Œ์ฐจ์ด์ฆˆ ๊ฐ™์€ ํฐ ๊ธฐ์—…์˜ ์ƒ์ ์€ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ๋ถ€๊ณผํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค. ์ด์— ๋Œ€ํ•ด ์ž๋™์œผ๋กœ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์—†์Œ์œผ๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ์ •ํ™•ํ•œ ์ •๋ณด๊ฐ€ ์•„๋‹ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค."; +"surchargeStatusHelpAutoGenerated2"="Surcharge์˜ ์–ด๋””์„œ๋‚˜ ๋…ธ๋ž€์ƒ‰์€ ๊ฒฐ์ œ ์ˆ˜์ˆ˜๋ฃŒ ์ •๋ณด๊ฐ€ ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋˜์—ˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค."; +"surchargeStatusHelpAutoGenerated2Emphasise"="๋…ธ๋ž€์ƒ‰"; "gotIt"="ํ™•์ธ"; "toastUnauthorised"="๋ฌด์—‡์„ ํ•˜๊ณ  ์‹ถ์œผ์‹ ๊ฐ€์š”? ํ•„์š”ํ•œ ๊ถŒํ•œ์ด๋ผ๋„?"; "toastOutOfRegion"="๋‹ค์Œ ์ง€์—ญ์—์„œ๋งŒ ์ด์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."; diff --git a/Surcharges/PresentationLayer/UIs/SurchargeStatusHelp/Sources/SurchargeStatusHelpView.swift b/Surcharges/PresentationLayer/UIs/SurchargeStatusHelp/Sources/SurchargeStatusHelpView.swift index d4ff165..4615aaa 100644 --- a/Surcharges/PresentationLayer/UIs/SurchargeStatusHelp/Sources/SurchargeStatusHelpView.swift +++ b/Surcharges/PresentationLayer/UIs/SurchargeStatusHelp/Sources/SurchargeStatusHelpView.swift @@ -11,15 +11,20 @@ import SwiftUI import CommonUI import UIExtensions import Resources +import Models public struct SurchargeStatusHelpView: View { + @Environment(\.colorScheme) private var _colorScheme + @Environment(\.dismiss) private var _dismiss @State private var _contentHeight: CGFloat = 0 @State private var _presentationIndents: Set = [] @State private var _selectedPresentationIndents: PresentationDetent = .height(0) + private let _surchargeStatuses: [SurchargeStatus] = [.unknown, .reported, .confirmed, .autoGenerated] + public init() { } public var body: some View { @@ -44,76 +49,17 @@ public struct SurchargeStatusHelpView: View { .frame(maxWidth: .infinity, alignment: .leading) .multilineTextAlignment(.leading) .font(.headline) + + VStack(spacing: 30) { - HStack { - Text(R.string.localizable.surchargeStatusUnknown()) - .font(.title3) - .surchargeStatusUnknown() + _surchargeStatusView(status: .unknown) - Text(R.string.localizable.surchargeStatusReported()) - .font(.title3) - .surchargeStatusReported() + _surchargeStatusView(status: .reported) - Text(R.string.localizable.surchargeStatusConfirmed()) - .font(.title3) - .surchargeStatusConfirmed() - } - - VStack(spacing: 15) { - Text(R.string.localizable.surchargeStatusUnknown()) - .foregroundStyle(R.color.red800.color) - - VStack(spacing: 0) { - - Text(R.string.localizable.surchargeStatusHelpUnknown1()) - .frame(maxWidth: .infinity, alignment: .leading) - - Text( - _styledText( - string: R.string.localizable.surchargeStatusHelpUnknown2(), - target: R.string.localizable.surchargeStatusHelpUnknown2Emphasise(), - color: R.color.red800.color - ) - ) - .frame(maxWidth: .infinity, alignment: .leading) - - } - } - - VStack(spacing: 15) { - Text(R.string.localizable.surchargeStatusReported()) - .foregroundStyle(R.color.blue800.color) + _surchargeStatusView(status: .confirmed) - VStack(spacing: 0) { - - Text(R.string.localizable.surchargeStatusHelpReported1()) - .frame(maxWidth: .infinity, alignment: .leading) - - Text( - _styledText( - string: R.string.localizable.surchargeStatusHelpReported2(), - target: R.string.localizable.surchargeStatusHelpReported2Emphasise(), - color: R.color.blue800.color - ) - ) - .frame(maxWidth: .infinity, alignment: .leading) - - } - } - - VStack(spacing: 15) { - Text(R.string.localizable.surchargeStatusConfirmed()) - .foregroundStyle(R.color.green800.color) + _surchargeStatusView(status: .autoGenerated) - VStack(spacing: 0) { - - Text(R.string.localizable.surchargeStatusHelpConfirmed1()) - .frame(maxWidth: .infinity, alignment: .leading) - - Text(_styledText(string: R.string.localizable.surchargeStatusHelpConfirmed2(), target: R.string.localizable.surchargeStatusHelpConfirmed2Emphasise(), color: R.color.green800.color)) - .frame(maxWidth: .infinity, alignment: .leading) - - } } Button { @@ -134,6 +80,115 @@ public struct SurchargeStatusHelpView: View { } + @ViewBuilder + private func _surchargeStatusView(status: SurchargeStatus) -> some View { + + VStack(spacing: 15) { + switch status { + case .unknown: + + Text(R.string.localizable.surchargeStatusUnknown()) + .font(.title3) + .surchargeStatusUnknown() + + case .reported: + + Text(R.string.localizable.surchargeStatusReported()) + .font(.title3) + .surchargeStatusReported() + + case .confirmed: + + Text(R.string.localizable.surchargeStatusConfirmed()) + .font(.title3) + .surchargeStatusConfirmed() + + case .autoGenerated: + + Text(R.string.localizable.surchargeStatusAutoGenerated()) + .font(.title3) + .surchargeStatusAutoGenerated() + + default: + + EmptyView() + + } + + VStack(spacing: 0) { + _description(status: status) + } + + } + + } + + @ViewBuilder + private func _description(status: SurchargeStatus) -> some View { + + switch status { + case .unknown: + + Text(R.string.localizable.surchargeStatusHelpUnknown1()) + .frame(maxWidth: .infinity, alignment: .leading) + + Text( + _styledText( + string: R.string.localizable.surchargeStatusHelpUnknown2(), + target: R.string.localizable.surchargeStatusHelpUnknown2Emphasise(), + color: _colorScheme == .light ? R.color.red800.color : R.color.red300.color + ) + ) + .frame(maxWidth: .infinity, alignment: .leading) + + case .reported: + + Text(R.string.localizable.surchargeStatusHelpReported1()) + .frame(maxWidth: .infinity, alignment: .leading) + + Text( + _styledText( + string: R.string.localizable.surchargeStatusHelpReported2(), + target: R.string.localizable.surchargeStatusHelpReported2Emphasise(), + color: _colorScheme == .light ? R.color.blue800.color : R.color.blue300.color + ) + ) + .frame(maxWidth: .infinity, alignment: .leading) + + case .confirmed: + + Text(R.string.localizable.surchargeStatusHelpConfirmed1()) + .frame(maxWidth: .infinity, alignment: .leading) + + Text( + _styledText( + string: R.string.localizable.surchargeStatusHelpConfirmed2(), + target: R.string.localizable.surchargeStatusHelpConfirmed2Emphasise(), + color: _colorScheme == .light ? R.color.green800.color : R.color.green300.color + ) + ) + .frame(maxWidth: .infinity, alignment: .leading) + + case .autoGenerated: + Text(R.string.localizable.surchargeStatusHelpAutoGenerated1()) + .frame(maxWidth: .infinity, alignment: .leading) + + Text( + _styledText( + string: R.string.localizable.surchargeStatusHelpAutoGenerated2(), + target: R.string.localizable.surchargeStatusHelpAutoGenerated2Emphasise(), + color: _colorScheme == .light ? R.color.yellow800.color : R.color.yellow300.color + ) + ) + .frame(maxWidth: .infinity, alignment: .leading) + + default: + + EmptyView() + + } + } + private func _styledText(string: String, target: String, color: Color) -> AttributedString { var attributedString = AttributedString(string) if let range = attributedString.range(of: target) { diff --git a/Surcharges/PresentationLayer/ViewModels/Sources/ConvertPlaceEntityToModel.swift b/Surcharges/PresentationLayer/ViewModels/Sources/ConvertPlaceEntityToModel.swift index 15f32b8..47b532c 100644 --- a/Surcharges/PresentationLayer/ViewModels/Sources/ConvertPlaceEntityToModel.swift +++ b/Surcharges/PresentationLayer/ViewModels/Sources/ConvertPlaceEntityToModel.swift @@ -26,6 +26,8 @@ struct ConvertPlaceEntityToModel { case .unknown: return .unknown case .reported: return .reported case .confirmed: return .confirmed + case .autoGenerated: return .autoGenerated + case .rejected: return .rejected } } From 47b97d089950fcee30dc53d267499a2d6db291ae Mon Sep 17 00:00:00 2001 From: Bonsung Koo Date: Tue, 4 Feb 2025 07:00:43 +1300 Subject: [PATCH 2/3] Localised strings are changed. #66 (#67) --- .../Localise/en.lproj/Localizable.strings | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings b/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings index c4280af..2647492 100644 --- a/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings +++ b/Surcharges/PresentationLayer/UIs/Resources/Resources/Localise/en.lproj/Localizable.strings @@ -20,15 +20,15 @@ "close"="Close"; "searchBoxPlaceholder"="Search your destination"; "searchButtonTitle"="Search"; -"reportForUnknownButtonTitle"="We're welcome to your contribution."; +"reportForUnknownButtonTitle"="We welcome to your contribution."; "reportForConfirmedButtonTitle"="Something wrong?"; -"surchargeStatusUnknownMessage"="Haven't reported the surcharge rate yet"; +"surchargeStatusUnknownMessage"="There is no reported surcharge rate yet"; "surchargeStatusUnknown"="Unknown"; "surchargeStatusReported"="Reported"; "surchargeStatusConfirmed"="Confirmed"; "surchargeStatusAutoGenerated"="Auto-Generated"; "updatedAt"="Updated at %@"; -"recognitionSuccess"="Recognised๐ŸŽ‰, Just in case please check the amounts, if it may not accurate."; +"recognitionSuccess"="Recognised๐ŸŽ‰, please confirm amount entered, if it may not accurate."; "recognitionNameNotMatched"="Place name is not matched."; "reportProceedAnyway"="Do you think the recognition sucks?๐Ÿคฎ\nTap here to proceed anyway."; "recognitionExtractedPartially"="It is recognised partially. Please input the rest manually."; @@ -49,19 +49,19 @@ "reportSuccessTitle"="Thank you for your contribution to"; "backToPlace"="Back to place"; "or"="or"; -"surchargeStatusHelpDisclaimer"="Disclaimer: Although we are trying to provide the most accurate information, there may be some inaccuracies. Please use the information as a reference."; +"surchargeStatusHelpDisclaimer"="Disclaimer: Although we are trying to provide the most accurate information, there may be some inaccuracies. Please use the information as a guide only."; "surchargeStatusHelpDiscription"="There are four types of surcharge status:"; -"surchargeStatusHelpUnknown1"="Means the surcharge status is not yet known. We're please to receive your report."; -"surchargeStatusHelpUnknown2"="Remeber, Red colour is unknown about surcharge."; +"surchargeStatusHelpUnknown1"="Means the surcharge status is not yet known. We welcome your report."; +"surchargeStatusHelpUnknown2"="Remember, Red indicates surcharge is unknown."; "surchargeStatusHelpUnknown2Emphasise"="Red"; "surchargeStatusHelpReported1"="Means the surcharge status is reported from someone who has passion to help others.\nHowever, it's not yet confirmed which means it may not be accurate."; -"surchargeStatusHelpReported2"="Remeber, Blue colour is reported but not confirmed."; +"surchargeStatusHelpReported2"="Remember, Blue indicates it is reported but not confirmed."; "surchargeStatusHelpReported2Emphasise"="Blue"; -"surchargeStatusHelpConfirmed1"="Means the surcharge status is confirmed by us. It's highly likely to be accurate.\nBut still, it may be accurate. Please check the updated date in place detail."; -"surchargeStatusHelpConfirmed2"="Remeber, Green colour is confirmed for surcharge information."; +"surchargeStatusHelpConfirmed1"="Means the surcharge status is confirmed by us. It's highly likely to be accurate.\nBut still, it may be inaccurate. Please check the updated date in place detail."; +"surchargeStatusHelpConfirmed2"="Remember, Green indicates confirmed surcharge information."; "surchargeStatusHelpConfirmed2Emphasise"="Green"; -"surchargeStatusHelpAutoGenerated1"="Big franchises likely do not charge surcharge. So we automatically set surcharge as zero. It may not be accurate."; -"surchargeStatusHelpAutoGenerated2"="Remember, Yellow colour is auto-generated surcharge information."; +"surchargeStatusHelpAutoGenerated1"="Big franchises are unlikely to charge a surcharge, so we automatically set it to zero. However, this may not be accurate."; +"surchargeStatusHelpAutoGenerated2"="Remember, Yellow indicates auto-generated surcharge information."; "surchargeStatusHelpAutoGenerated2Emphasise"="Yellow"; "gotIt"="Got it"; "toastUnauthorised"="Do you want some permissions?"; @@ -69,6 +69,6 @@ "toastNoInternet"="Please check the Internet connection."; "toastNewVersion"="New version available. Please update."; "toastUnknown"="Oops๐Ÿซข Something went wrong. Please try again."; -"exposingAdsSuggestion"="If you are enjoy this app, and make it sustainable, is it okay to show you ads? It will show here and in the place list."; +"exposingAdsSuggestion"="Enjoying this app?\nWant to support us?\nLet us know if it is okay to show you ads.\nIt will appear here and in the place list."; "exposingAdsAcceptButtonTitle"="Yes. Show me ads!"; "exposingAdsThanks"="Thank you for supporting us!"; From 91503532f190ab791598441108029c11a47ae650 Mon Sep 17 00:00:00 2001 From: Bonsung Koo Date: Tue, 4 Feb 2025 16:23:05 +1300 Subject: [PATCH 3/3] Place name and address card design has been changed. #68 (#69) close #68 --- .../UIs/Main/App/Sources/MainApp.swift | 3 +- .../Main/Sources/SearchResult/PlaceView.swift | 47 ++++++++++--------- .../Sources/Surcharge/SurchargeView.swift | 31 +++++++----- .../Project/Surcharges.swift | 3 +- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/Surcharges/PresentationLayer/UIs/Main/App/Sources/MainApp.swift b/Surcharges/PresentationLayer/UIs/Main/App/Sources/MainApp.swift index c098dd3..a5f959a 100644 --- a/Surcharges/PresentationLayer/UIs/Main/App/Sources/MainApp.swift +++ b/Surcharges/PresentationLayer/UIs/Main/App/Sources/MainApp.swift @@ -19,6 +19,7 @@ import AppStatusService import AppStatusService import ViewUpdateService import DevelopmentEndpoint +import DevelopmentAdsService @main struct MainApp: App { @@ -32,7 +33,7 @@ struct MainApp: App { var body: some Scene { WindowGroup { NavigationStack { - MainView( + MainView.ViewModel, MainRouter, DevelopmentAdsService>( viewModel: MainFactory( locationService: _locationService, viewUpdateService: _viewUpdateService diff --git a/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift b/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift index ad8ea2f..eb5d0c2 100644 --- a/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift +++ b/Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift @@ -22,37 +22,40 @@ struct PlaceView: View { } var body: some View { - VStack(spacing: 5) { + HStack(spacing: 20) { - HStack(spacing: 10) { - + Image(systemName: "storefront") + .imageScale(.large) + + VStack(spacing: 5) { Text(_place.name) .font(.headline) + .frame(maxWidth: .infinity, alignment: .leading) .multilineTextAlignment(.leading) - if let rate = _place.surcharge.rate { - if _place.surcharge.status == .reported { - Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") - .surchargeStatusReported() - - } else if _place.surcharge.status == .confirmed { - Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") - .surchargeStatusConfirmed() - - } else if _place.surcharge.status == .autoGenerated { - Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") - .surchargeStatusAutoGenerated() - } - } + Text(_place.address) + .frame(maxWidth: .infinity, alignment: .leading) + .font(.subheadline) + .multilineTextAlignment(.leading) } - Text(_place.address) - .frame(maxWidth: .infinity, alignment: .center) - .font(.subheadline) - .multilineTextAlignment(.center) - + if let rate = _place.surcharge.rate { + if _place.surcharge.status == .reported { + Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") + .surchargeStatusReported() + + } else if _place.surcharge.status == .confirmed { + Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") + .surchargeStatusConfirmed() + + } else if _place.surcharge.status == .autoGenerated { + Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())๐ŸŽ‰" : "\(rate)%") + .surchargeStatusAutoGenerated() + } + } } .padding([.leading, .trailing], 20) + } } diff --git a/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift b/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift index f183166..6326b87 100644 --- a/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift +++ b/Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift @@ -35,21 +35,30 @@ struct SurchargeView: View { var body: some View { VStack(spacing: 10) { - VStack(spacing: 10) { + HStack(spacing: 20) { - Text(_placeName) - .font(.headline) - .frame(maxWidth: .infinity, alignment: .leading) - .multilineTextAlignment(.leading) + Image(systemName: "storefront") + .imageScale(.large) .shimmering(active: _isLoading) .redacted(reason: _isLoading ? .placeholder : []) - Text(_placeAddress) - .font(.subheadline) - .frame(maxWidth: .infinity, alignment: .leading) - .multilineTextAlignment(.leading) - .shimmering(active: _isLoading) - .redacted(reason: _isLoading ? .placeholder : []) + VStack(spacing: 5) { + + Text(_placeName) + .font(.headline) + .frame(maxWidth: .infinity, alignment: .leading) + .multilineTextAlignment(.leading) + .shimmering(active: _isLoading) + .redacted(reason: _isLoading ? .placeholder : []) + + Text(_placeAddress) + .font(.subheadline) + .frame(maxWidth: .infinity, alignment: .leading) + .multilineTextAlignment(.leading) + .shimmering(active: _isLoading) + .redacted(reason: _isLoading ? .placeholder : []) + } + } VStack(spacing: 10) { diff --git a/Tuist/ProjectDescriptionHelpers/Project/Surcharges.swift b/Tuist/ProjectDescriptionHelpers/Project/Surcharges.swift index 7066a58..9ecb173 100644 --- a/Tuist/ProjectDescriptionHelpers/Project/Surcharges.swift +++ b/Tuist/ProjectDescriptionHelpers/Project/Surcharges.swift @@ -100,7 +100,8 @@ public final class Surcharges: @unchecked Sendable { "NSLocationWhenInUseUsageDescription": .string("Surcharges uses your location to provide nearest places to you."), "NSCameraUsageDescription": .string("Surcharges uses your camera to take your receipt."), "ITSAppUsesNonExemptEncryption": .boolean(false), - "UISupportedInterfaceOrientations": .array([.string("UIInterfaceOrientationPortrait")]) + "UISupportedInterfaceOrientations": .array([.string("UIInterfaceOrientationPortrait")]), + "GADApplicationIdentifier": .string("ca-app-pub-2719055739020811~8730306210") ] ), sources: ["App/Sources/**"],