[#776] Alerts do not work as expected (#777)

- actions from alerts are now properly propagated
- dismissal of an alert is not clearing out the state
- qrcode icon is now a system one
- swiftgen paths updated
This commit is contained in:
Lukas Korba 2023-06-22 08:12:33 +02:00 committed by GitHub
parent 2aadd2870a
commit d972a7834b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 68 additions and 93 deletions

View File

@ -83,6 +83,13 @@ public struct BalanceBreakdownReducer: ReducerProtocol {
public var body: some ReducerProtocol<State, Action> {
Reduce { state, action in
switch action {
case .alert(.presented(let action)):
return EffectTask(value: action)
case .alert(.dismiss):
state.alert = nil
return .none
case .alert:
return .none

View File

@ -45,6 +45,13 @@ public struct ExportLogsReducer: ReducerProtocol {
public var body: some ReducerProtocol<State, Action> {
Reduce { state, action in
switch action {
case .alert(.presented(let action)):
return EffectTask(value: action)
case .alert(.dismiss):
state.alert = nil
return .none
case .alert:
return .none

View File

@ -108,7 +108,6 @@ public struct HomeReducer: ReducerProtocol {
case alert(PresentationAction<Action>)
case balanceBreakdown(BalanceBreakdownReducer.Action)
case debugMenuStartup
case dismissAlert
case foundTransactions
case onAppear
case onDisappear
@ -273,10 +272,14 @@ public struct HomeReducer: ReducerProtocol {
state.alert = AlertState.syncFailed(error, L10n.General.ok)
return .none
case .alert:
case .alert(.presented(let action)):
return EffectTask(value: action)
case .alert(.dismiss):
state.alert = nil
return .none
case .dismissAlert:
case .alert:
return .none
}
}
@ -345,7 +348,7 @@ extension AlertState where Action == HomeReducer.Action {
ButtonState(action: .retrySync) {
TextState(L10n.Home.SyncFailed.retry)
}
ButtonState(action: .dismissAlert) {
ButtonState(action: .alert(.dismiss)) {
TextState(secondaryButtonTitle)
}
} message: {

View File

@ -74,7 +74,6 @@ public struct ImportWalletReducer: ReducerProtocol {
public enum Action: Equatable {
case alert(PresentationAction<Action>)
case birthdayInputChanged(RedactableString)
case dismissAlert
case restoreWallet
case importPrivateOrViewingKey
case initializeSDK
@ -125,6 +124,13 @@ public struct ImportWalletReducer: ReducerProtocol {
}
return .none
case .alert(.presented(let action)):
return EffectTask(value: action)
case .alert(.dismiss):
state.alert = nil
return .none
case .alert:
return .none
@ -163,9 +169,6 @@ public struct ImportWalletReducer: ReducerProtocol {
case .initializeSDK:
return .none
case .dismissAlert:
return .none
}
}
}
@ -217,7 +220,7 @@ extension AlertState where Action == ImportWalletReducer.Action {
AlertState {
TextState(L10n.ImportWallet.Alert.Failed.title)
} actions: {
ButtonState(action: .dismissAlert) {
ButtonState(action: .alert(.dismiss)) {
TextState(L10n.General.ok)
}
} message: {

View File

@ -123,7 +123,7 @@ extension RootReducer {
return EffectTask(value: .destination(.deeplink(url)))
case .home, .initialization, .onboarding, .phraseDisplay, .phraseValidation, .sandbox, .updateStateAfterConfigUpdate, .alert,
.welcome, .binding, .nukeWalletFailed, .nukeWalletSucceeded, .debug, .walletConfigLoaded, .dismissAlert, .exportLogs:
.welcome, .binding, .nukeWalletFailed, .nukeWalletSucceeded, .debug, .walletConfigLoaded, .exportLogs:
return .none
}
@ -133,7 +133,7 @@ extension RootReducer {
}
private extension RootReducer {
public func process(
func process(
url: URL,
deeplink: DeeplinkClient,
derivationTool: DerivationToolClient

View File

@ -267,8 +267,11 @@ extension RootReducer {
state.alert = AlertState.initializationFailed(error)
return .none
case .alert(.presented(let action)):
return EffectTask(value: action)
case .home, .destination, .onboarding, .phraseDisplay, .phraseValidation, .sandbox,
.welcome, .binding, .debug, .exportLogs, .dismissAlert, .alert:
.welcome, .binding, .debug, .exportLogs, .alert:
return .none
}
}

View File

@ -75,7 +75,6 @@ public struct RootReducer: ReducerProtocol {
case alert(PresentationAction<Action>)
case binding(BindingAction<RootReducer.State>)
case debug(DebugAction)
case dismissAlert
case destination(DestinationAction)
case exportLogs(ExportLogsReducer.Action)
case home(HomeReducer.Action)
@ -269,7 +268,7 @@ extension AlertState where Action == RootReducer.Action {
ButtonState(role: .destructive, action: .initialization(.nukeWallet)) {
TextState(L10n.General.yes)
}
ButtonState(role: .cancel, action: .dismissAlert) {
ButtonState(role: .cancel, action: .alert(.dismiss)) {
TextState(L10n.General.no)
}
} message: {

View File

@ -80,6 +80,13 @@ public struct ScanReducer: ReducerProtocol {
public var body: some ReducerProtocolOf<Self> {
Reduce { state, action in
switch action {
case .alert(.presented(let action)):
return EffectTask(value: action)
case .alert(.dismiss):
state.alert = nil
return .none
case .alert:
return .none

View File

@ -143,6 +143,13 @@ public struct SettingsReducer: ReducerProtocol {
state.supportData = nil
return .none
case .alert(.presented(let action)):
return EffectTask(value: action)
case .alert(.dismiss):
state.alert = nil
return .none
case .alert:
return .none
}

View File

@ -49,7 +49,6 @@ public struct WalletEventsFlowReducer: ReducerProtocol {
public enum Action: Equatable {
case alert(PresentationAction<Action>)
case copyToPastboard(RedactableString)
case dismissAlert
case onAppear
case onDisappear
case openBlockExplorer(URL?)
@ -120,12 +119,16 @@ public struct WalletEventsFlowReducer: ReducerProtocol {
case .replyTo:
return .none
case .alert(.presented(let action)):
return EffectTask(value: action)
case .alert(.dismiss):
state.alert = nil
return .none
case .alert:
return .none
case .dismissAlert:
return .none
case .warnBeforeLeavingApp(let blockExplorerURL):
state.alert = AlertState.warnBeforeLeavingApp(blockExplorerURL)
return .none
@ -176,7 +179,7 @@ extension AlertState where Action == WalletEventsFlowReducer.Action {
ButtonState(action: .openBlockExplorer(blockExplorerURL)) {
TextState(L10n.WalletEvent.Alert.LeavingApp.Button.seeOnline)
}
ButtonState(role: .cancel, action: .dismissAlert) {
ButtonState(role: .cancel, action: .alert(.dismiss)) {
TextState(L10n.WalletEvent.Alert.LeavingApp.Button.nevermind)
}
} message: {

View File

@ -1,6 +0,0 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -1,56 +0,0 @@
{
"images" : [
{
"filename" : "qr_lighttheme.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "qr_darktheme.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "qr_lighttheme@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "qr_darktheme@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "qr_lighttheme@3x.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "qr_darktheme@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

View File

@ -33,9 +33,6 @@ public enum Asset {
public static let calloutBackupFlow1 = ImageAsset(name: "calloutBackupFlow1")
public static let calloutBackupSucceeded = ImageAsset(name: "calloutBackupSucceeded")
}
public enum Icons {
public static let qrCode = ImageAsset(name: "qrCode")
}
public static let welcomeScreenLogo = ImageAsset(name: "WelcomeScreenLogo")
}
public enum Colors {

View File

@ -32,9 +32,10 @@ public struct TransactionAddressTextField: View {
Button {
viewStore.send(.scanQR)
} label: {
Image(Asset.Assets.Icons.qrCode.name)
Image(systemName: "qrcode")
.resizable()
.frame(width: 25, height: 25)
.tint(Asset.Colors.Mfp.primary.color)
}
.padding(.trailing, 10)
}

View File

@ -81,7 +81,7 @@ struct TransactionAmountTextField_Previews: PreviewProvider {
titleAccessoryView: { EmptyView() },
inputPrefixView: { EmptyView() },
inputAccessoryView: {
Image(Asset.Assets.Icons.qrCode.name)
Image(systemName: "qrcode")
.resizable()
.frame(width: 30, height: 30)
}

View File

@ -815,9 +815,9 @@
inputFileListPaths = (
);
inputPaths = (
"$(SRCROOT)/secant/Resources/Colors.xcassets",
"$(SRCROOT)/secant/Resources/Assets/xcassets",
"$(SRCROOT)/secant/Resources/Localizable.strings",
"$(SRCROOT)/modules/Sources/Generated/Resources/Colors.xcassets",
"$(SRCROOT)/modules/Sources/Generated/Resources/Assets/xcassets",
"$(SRCROOT)/modules/Sources/Generated/Resources/Localizable.strings",
"$(SRCROOT)/swiftgen.yml",
);
name = SwiftGen;
@ -918,9 +918,9 @@
inputFileListPaths = (
);
inputPaths = (
"$(SRCROOT)/secant/Resources/Colors.xcassets",
"$(SRCROOT)/secant/Resources/Assets/xcassets",
"$(SRCROOT)/secant/Resources/Localizable.strings",
"$(SRCROOT)/modules/Sources/Generated/Resources/Colors.xcassets",
"$(SRCROOT)/modules/Sources/Generated/Resources/Assets/xcassets",
"$(SRCROOT)/modules/Sources/Generated/Resources/Localizable.strings",
"$(SRCROOT)/swiftgen.yml",
);
name = SwiftGen;