Merge pull request #1169 from LukasKorba/1108-Enhance-scan-UI
[#1108] Enhance scan UI
This commit is contained in:
commit
9e4b27e585
|
@ -6,6 +6,9 @@ directly impact users rather than highlighting other crucial architectural updat
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Open settings button added to the scan screen for a case when the camera is disabled.
|
||||
|
||||
## 1.0.4 build 2 (2024-03-29)
|
||||
|
||||
### Added
|
||||
|
|
|
@ -24,6 +24,10 @@ public struct Scan {
|
|||
public var isTorchAvailable = false
|
||||
public var isTorchOn = false
|
||||
|
||||
public var isCameraEnabled: Bool {
|
||||
info.isEmpty
|
||||
}
|
||||
|
||||
public init(
|
||||
info: String = "",
|
||||
isTorchAvailable: Bool = false,
|
||||
|
|
|
@ -11,8 +11,9 @@ import Generated
|
|||
import UIComponents
|
||||
|
||||
public struct ScanView: View {
|
||||
let store: StoreOf<Scan>
|
||||
@Environment(\.openURL) var openURL
|
||||
|
||||
let store: StoreOf<Scan>
|
||||
|
||||
public init(store: StoreOf<Scan>) {
|
||||
self.store = store
|
||||
|
@ -44,21 +45,32 @@ public struct ScanView: View {
|
|||
.multilineTextAlignment(.center)
|
||||
.padding(.bottom, 20)
|
||||
|
||||
Button(L10n.General.cancel.uppercased()) {
|
||||
store.send(.cancelPressed)
|
||||
if !store.isCameraEnabled {
|
||||
Button(L10n.Scan.openSettings.uppercased()) {
|
||||
if let url = URL(string: UIApplication.openSettingsURLString) {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
||||
.zcashStyle(.secondary)
|
||||
.padding(.horizontal, 50)
|
||||
.padding(.bottom, 70)
|
||||
} else {
|
||||
Button(L10n.General.cancel.uppercased()) {
|
||||
store.send(.cancelPressed)
|
||||
}
|
||||
.zcashStyle(.secondary)
|
||||
.padding(.horizontal, 50)
|
||||
.padding(.bottom, 70)
|
||||
}
|
||||
.zcashStyle(.secondary)
|
||||
.padding(.horizontal, 50)
|
||||
.padding(.bottom, 70)
|
||||
}
|
||||
.padding(.horizontal, 30)
|
||||
}
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
.ignoresSafeArea()
|
||||
.navigationBarHidden(true)
|
||||
.applyScreenBackground()
|
||||
.onAppear { store.send(.onAppear) }
|
||||
.onDisappear { store.send(.onDisappear) }
|
||||
.zashiBack(hidden: store.isCameraEnabled, invertedColors: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -513,6 +513,8 @@ public enum L10n {
|
|||
public static let cameraSettings = L10n.tr("Localizable", "scan.cameraSettings", fallback: "The camera is not authorized. Please go to the system settings of Zashi and turn it on.")
|
||||
/// This QR code doesn't hold a valid Zcash address.
|
||||
public static let invalidQR = L10n.tr("Localizable", "scan.invalidQR", fallback: "This QR code doesn't hold a valid Zcash address.")
|
||||
/// Open settings
|
||||
public static let openSettings = L10n.tr("Localizable", "scan.openSettings", fallback: "Open settings")
|
||||
}
|
||||
public enum SecurityWarning {
|
||||
/// I acknowledge
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
// MARK: - Scan
|
||||
"scan.invalidQR" = "This QR code doesn't hold a valid Zcash address.";
|
||||
"scan.cameraSettings" = "The camera is not authorized. Please go to the system settings of Zashi and turn it on.";
|
||||
"scan.openSettings" = "Open settings";
|
||||
|
||||
// MARK: - Send
|
||||
"send.title" = "Send Zcash";
|
||||
|
|
|
@ -10,8 +10,10 @@ import Generated
|
|||
|
||||
struct ZashiBackModifier: ViewModifier {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
let disabled: Bool
|
||||
let hidden: Bool
|
||||
let invertedColors: Bool
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
if hidden {
|
||||
|
@ -30,13 +32,13 @@ struct ZashiBackModifier: ViewModifier {
|
|||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.frame(width: 10, height: 10)
|
||||
.tint(Asset.Colors.primary.color)
|
||||
.tint(invertedColors ? Asset.Colors.secondary.color : Asset.Colors.primary.color)
|
||||
|
||||
Text(L10n.General.back.uppercased())
|
||||
.foregroundColor(
|
||||
disabled
|
||||
? Asset.Colors.shade72.color
|
||||
: Asset.Colors.primary.color
|
||||
: invertedColors ? Asset.Colors.secondary.color : Asset.Colors.primary.color
|
||||
)
|
||||
.font(.custom(FontFamily.Inter.regular.name, size: 14))
|
||||
}
|
||||
|
@ -49,7 +51,11 @@ struct ZashiBackModifier: ViewModifier {
|
|||
}
|
||||
|
||||
extension View {
|
||||
public func zashiBack(_ disabled: Bool = false, hidden: Bool = false) -> some View {
|
||||
modifier(ZashiBackModifier(disabled: disabled, hidden: hidden))
|
||||
public func zashiBack(
|
||||
_ disabled: Bool = false,
|
||||
hidden: Bool = false,
|
||||
invertedColors: Bool = false
|
||||
) -> some View {
|
||||
modifier(ZashiBackModifier(disabled: disabled, hidden: hidden, invertedColors: invertedColors))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue