Skip to content

Commit

Permalink
Several small Fixes (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
GhenadieVP committed Jun 9, 2023
1 parent 868303b commit 762e90a
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 168 deletions.
22 changes: 22 additions & 0 deletions Sources/Core/DesignSystem/Components/WarningView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Resources
import SwiftUI

public struct WarningView: View {
public let text: String

public init(text: String) {
self.text = text
}

public var body: some View {
HStack(spacing: .medium3) {
Image(asset: AssetResource.warningError)
.resizable()
.frame(.smallest)
Text(text)
.textStyle(.body1Header)
.foregroundColor(.app.alert)
.multilineTextAlignment(.leading)
}
}
}
44 changes: 24 additions & 20 deletions Sources/Core/Resources/Generated/L10n.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -808,26 +808,6 @@ public enum L10n {
public static let subtitleWrongNetworkID = L10n.tr("Localizable", "dAppRequest_validationOutcome_subtitleWrongNetworkID", fallback: "Network mismatch")
}
}
public enum DisplayMnemonics {
/// Generated on
public static let labelDate = L10n.tr("Localizable", "displayMnemonics_labelDate", fallback: "Generated on")
/// Imported on
public static let labelDateOlympia = L10n.tr("Localizable", "displayMnemonics_labelDateOlympia", fallback: "Imported on")
/// Main Seed Phrase
public static let labelSeedPhraseKind = L10n.tr("Localizable", "displayMnemonics_labelSeedPhraseKind", fallback: "Main Seed Phrase")
/// Legacy Seed Phrase
public static let labelSeedPhraseKindOlympia = L10n.tr("Localizable", "displayMnemonics_labelSeedPhraseKindOlympia", fallback: "Legacy Seed Phrase")
/// Seed Phrases
public static let seedPhrases = L10n.tr("Localizable", "displayMnemonics_seedPhrases", fallback: "Seed Phrases")
public enum CautionAlert {
/// A seed phrase provides full control of its Accounts. Do not view in a public area. Back up the seed phrase words securely. Screenshots are disabled.
public static let message = L10n.tr("Localizable", "displayMnemonics_cautionAlert_message", fallback: "A seed phrase provides full control of its Accounts. Do not view in a public area. Back up the seed phrase words securely. Screenshots are disabled.")
/// Reveal Seed Phrase
public static let revealButtonLabel = L10n.tr("Localizable", "displayMnemonics_cautionAlert_revealButtonLabel", fallback: "Reveal Seed Phrase")
/// Use Caution
public static let title = L10n.tr("Localizable", "displayMnemonics_cautionAlert_title", fallback: "Use Caution")
}
}
public enum EditPersona {
/// Add a Field
public static let addAField = L10n.tr("Localizable", "editPersona_addAField", fallback: "Add a Field")
Expand Down Expand Up @@ -1338,6 +1318,30 @@ public enum L10n {
/// Use iCloud Backup Data
public static let useICloudBackup = L10n.tr("Localizable", "restoreFromBackup_useICloudBackup", fallback: "Use iCloud Backup Data")
}
public enum RevealSeedPhrase {
/// Reveal Seed Phrase
public static let title = L10n.tr("Localizable", "revealSeedPhrase_title", fallback: "Reveal Seed Phrase")
/// For your safety, make sure no one is looking at your screen. Taking a screen shot has been disabled.
public static let warning = L10n.tr("Localizable", "revealSeedPhrase_warning", fallback: "For your safety, make sure no one is looking at your screen. Taking a screen shot has been disabled.")
}
public enum SeedPhrases {
/// A Seed Phrase provides full access to your accounts and funds. When viewing, ensure you’re in a safe environment and no one is looking at your screen.
public static let message = L10n.tr("Localizable", "seedPhrases_message", fallback: "A Seed Phrase provides full access to your accounts and funds. When viewing, ensure you’re in a safe environment and no one is looking at your screen.")
/// Seed Phrases
public static let title = L10n.tr("Localizable", "seedPhrases_title", fallback: "Seed Phrases")
/// You are responsible for the security of your Seed Phrase
public static let warning = L10n.tr("Localizable", "seedPhrases_warning", fallback: "You are responsible for the security of your Seed Phrase")
public enum SeedPhrase {
/// Connected to %d accounts
public static func multipleConnectedAccounts(_ p1: Int) -> String {
return L10n.tr("Localizable", "seedPhrases_seedPhrase_multipleConnectedAccounts", p1, fallback: "Connected to %d accounts")
}
/// Connected to 1 account
public static let oneConnectedAccount = L10n.tr("Localizable", "seedPhrases_seedPhrase_oneConnectedAccount", fallback: "Connected to 1 account")
/// Reveal Seed Phrase
public static let reveal = L10n.tr("Localizable", "seedPhrases_seedPhrase_reveal", fallback: "Reveal Seed Phrase")
}
}
public enum Settings {
/// App Settings
public static let appSettings = L10n.tr("Localizable", "settings_appSettings", fallback: "App Settings")
Expand Down
18 changes: 10 additions & 8 deletions Sources/Core/Resources/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,16 @@ Install the Connector extension, open it to see the linking QR code, and tap con
"ledgerHardwareDevices_subtitleSelectLedger" = "Choose a Ledger device to use";
"ledgerHardwareDevices_subtitleAllLedgers" = "Here are all the Ledger devices you have added.";
"ledgerHardwareDevices_subtitleFailure" = "Could not find Ledger devices";
"displayMnemonics_cautionAlert_title" = "Use Caution";
"displayMnemonics_cautionAlert_revealButtonLabel" = "Reveal Seed Phrase";
"displayMnemonics_cautionAlert_message" = "A seed phrase provides full control of its Accounts. Do not view in a public area. Back up the seed phrase words securely. Screenshots are disabled.";
"displayMnemonics_labelSeedPhraseKindOlympia" = "Legacy Seed Phrase";
"displayMnemonics_labelSeedPhraseKind" = "Main Seed Phrase";
"displayMnemonics_labelDateOlympia" = "Imported on";
"displayMnemonics_labelDate" = "Generated on";
"displayMnemonics_seedPhrases" = "Seed Phrases";

"seedPhrases_title" = "Seed Phrases";
"seedPhrases_message" = "A Seed Phrase provides full access to your accounts and funds. When viewing, ensure you’re in a safe environment and no one is looking at your screen.";
"seedPhrases_warning" = "You are responsible for the security of your Seed Phrase";
"seedPhrases_seedPhrase_reveal" = "Reveal Seed Phrase";
"seedPhrases_seedPhrase_oneConnectedAccount" = "Connected to 1 account";
"seedPhrases_seedPhrase_multipleConnectedAccounts" = "Connected to %d accounts";

"revealSeedPhrase_warning" = "For your safety, make sure no one is looking at your screen. Taking a screen shot has been disabled.";
"revealSeedPhrase_title" = "Reveal Seed Phrase";

"generalSettings_resetWallet_title" = "Reset Wallet";
"generalSettings_resetWallet_subtitle" = "Clear all data in this Wallet";
Expand Down
12 changes: 1 addition & 11 deletions Sources/Features/AppFeature/App+Reducer.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import AppPreferencesClient
import DeviceFactorSourceClient
import EngineToolkit
import FeaturePrelude
import MainFeature
Expand Down Expand Up @@ -73,7 +72,6 @@ public struct App: Sendable, FeatureReducer {

@Dependency(\.continuousClock) var clock
@Dependency(\.errorQueue) var errorQueue
@Dependency(\.deviceFactorSourceClient) var deviceFactorSourceClient
@Dependency(\.appPreferencesClient) var appPreferencesClient

public init() {}
Expand Down Expand Up @@ -163,7 +161,7 @@ public struct App: Sendable, FeatureReducer {
return goToOnboarding(state: &state)

case .onboardingCoordinator(.delegate(.completed)):
return checkAccountRecoveryNeeded()
return goToMain(state: &state, accountRecoveryIsNeeded: false)

case let .splash(.delegate(.completed(loadProfileOutcome, accountRecoveryNeeded))):
switch loadProfileOutcome {
Expand Down Expand Up @@ -211,14 +209,6 @@ public struct App: Sendable, FeatureReducer {
return .none
}

func checkAccountRecoveryNeeded() -> EffectTask<Action> {
.task {
// When coming from onboarding flow, recovery check is allowed to fail
let isAccountRecoveryNeeded = await (try? deviceFactorSourceClient.isAccountRecoveryNeeded()) ?? true
return .internal(.toMain(isAccountRecoveryNeeded: isAccountRecoveryNeeded))
}
}

func goToMain(state: inout State, accountRecoveryIsNeeded: Bool) -> EffectTask<Action> {
state.root = .main(.init(home: .init(accountRecoveryIsNeeded: accountRecoveryIsNeeded)))
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct CreationOfAccount: Sendable, FeatureReducer {
self.isCreatingLedgerAccount = isCreatingLedgerAccount

if isCreatingLedgerAccount {
self.step = .step0_chooseLedger(.init(allowSelection: true))
self.step = .step0_chooseLedger(.init(allowSelection: true, context: .ledgerSelection))
} else {
self.step = .step1_derivePublicKeys(
.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension GeneralSettings {
.foregroundColor(.app.gray1)
.textStyle(.body1HighImportance)

Text("Export the Wallet development logs")
Text("Export and save debugging logs")
.foregroundColor(.app.gray2)
.textStyle(.body2Regular)
.fixedSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct ImportOlympiaLedgerAccountsAndFactorSources: Sendable, FeatureRedu
let accountsValidation = OlympiaAccountsValidation(validated: [], unvalidated: Set(hardwareAccounts.elements))
self.networkID = networkID
self.unmigrated = accountsValidation
self.chooseLedger = .init(allowSelection: true, showHeaders: false)
self.chooseLedger = .init(allowSelection: true, context: .ledgerSelection, showHeaders: false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ public struct LedgerHardwareDevices: Sendable, FeatureReducer {
// MARK: - State

public struct State: Sendable, Hashable {
public enum Context {
case settings
case ledgerSelection
}

public let allowSelection: Bool
public let showHeaders: Bool
public let context: Context

public var hasAConnectorExtension: Bool = false

Expand All @@ -31,8 +37,9 @@ public struct LedgerHardwareDevices: Sendable, FeatureReducer {

var pendingAction: ActionRequiringP2P? = nil

public init(allowSelection: Bool, showHeaders: Bool = true) {
public init(allowSelection: Bool, context: Context, showHeaders: Bool = true) {
self.allowSelection = allowSelection
self.context = context
self.showHeaders = showHeaders
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ extension LedgerHardwareDevices {
let ledgers: Loadable<IdentifiedArrayOf<LedgerHardwareWalletFactorSource>>
let selectedLedgerID: FactorSourceID?
let selectedLedgerControlRequirements: SelectedLedgerControlRequirements?
let context: State.Context

init(state: LedgerHardwareDevices.State) {
self.allowSelection = state.allowSelection
self.showHeaders = state.showHeaders
self.ledgers = state.$ledgers
self.selectedLedgerID = state.selectedLedgerID
self.context = state.context

if let id = state.selectedLedgerID, let selectedLedger = state.ledgers?[id: id] {
self.selectedLedgerControlRequirements = .init(selectedLedger: selectedLedger)
} else {
Expand Down Expand Up @@ -71,14 +74,21 @@ extension LedgerHardwareDevices {
ScrollView {
VStack(spacing: 0) {
Group {
Image(asset: AssetResource.iconHardwareLedger)
.frame(.medium)
.padding(.vertical, .medium2)

Text(viewStore.navigationTitle)
.textStyle(.sheetTitle)
.foregroundColor(.app.gray1)
.padding(.bottom, .medium1)
if viewStore.context == .settings {
Text(L10n.LedgerHardwareDevices.subtitleAllLedgers)
.textStyle(.body1HighImportance)
.foregroundColor(.app.gray2)
.padding(.vertical, .medium1)
} else {
Image(asset: AssetResource.iconHardwareLedger)
.frame(.medium)
.padding(.vertical, .medium2)

Text(viewStore.navigationTitle)
.textStyle(.sheetTitle)
.foregroundColor(.app.gray1)
.padding(.bottom, .medium1)
}

if viewStore.showHeaders {
if let subtitle = viewStore.subtitle {
Expand All @@ -89,12 +99,12 @@ extension LedgerHardwareDevices {
.padding(.bottom, .medium1)
}

// FIXME: Uncomment and implement
// Button(L10n.LedgerHardwareDevices.ledgerFactorSourceInfoCaption) {
// viewStore.send(.whatIsALedgerButtonTapped)
// }
// .buttonStyle(.info)
// .flushedLeft
// FIXME: Uncomment and implement
// Button(L10n.LedgerHardwareDevices.ledgerFactorSourceInfoCaption) {
// viewStore.send(.whatIsALedgerButtonTapped)
// }
// .buttonStyle(.info)
// .flushedLeft
}
}
.multilineTextAlignment(.center)
Expand All @@ -109,8 +119,11 @@ extension LedgerHardwareDevices {

Spacer(minLength: 0)
}
.padding(.horizontal, .medium1)
}
.frame(
minWidth: 0,
maxWidth: .infinity
)
.footer(visible: viewStore.allowSelection) {
WithControlRequirements(
viewStore.selectedLedgerControlRequirements,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ extension ProfileBackups.View {
Separator()

HStack {
Text("Cloud Backup Wallet data: ") // FIXME: strings
Text("Wallet backups in your iCloud account:") // FIXME: strings
.textStyle(.body1Header)
Spacer()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import ImportMnemonicFeature
extension DisplayMnemonic.State {
var viewState: DisplayMnemonic.ViewState {
.init(
isLoading: importMnemonic == nil,
navigationTitle: deviceFactorSource.labelSeedPhraseKind
isLoading: importMnemonic == nil
)
}
}
Expand All @@ -14,7 +13,6 @@ extension DisplayMnemonic.State {
extension DisplayMnemonic {
public struct ViewState: Equatable {
let isLoading: Bool
let navigationTitle: String
}

@MainActor
Expand All @@ -40,14 +38,18 @@ extension DisplayMnemonic {
action: { .child(.importMnemonic($0)) }
)
) { importMnemonicViewStore in
// We must have a NavigationView in order to display navigationTitle
NavigationView {
VStack(alignment: .leading, spacing: .medium2) {
WarningView(text: L10n.RevealSeedPhrase.warning)
.padding(.horizontal, .medium3)

ImportMnemonic.View(store: importMnemonicViewStore)
.navigationTitle(viewStore.navigationTitle)
}
.padding(.top, .medium3)
}
}
}
.navigationTitle(L10n.RevealSeedPhrase.title)
.navigationBarTitleDisplayMode(.inline)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,35 @@ extension DisplayMnemonics {
public var body: some SwiftUI.View {
WithViewStore(store, observe: \.viewState, send: { .view($0) }) { viewStore in
ScrollView {
VStack {
VStack(alignment: .leading, spacing: .medium1) {
Text(L10n.SeedPhrases.message)
.textStyle(.body1HighImportance)
.foregroundColor(.app.gray2)
.multilineTextAlignment(.leading)
.padding(.horizontal, .medium3)

WarningView(text: L10n.SeedPhrases.warning)
.padding(.horizontal, .medium3)

ForEachStore(
store.scope(
state: \.deviceFactorSources,
action: { .child(.row(id: $0, action: $1)) }
)
) {
DisplayMnemonicRow.View(store: $0)
) { store in
VStack(spacing: .small2) {
DisplayMnemonicRow.View(store: store)
Separator()
}
.padding([.top, .horizontal], .medium3)
}
.padding()
.background(.app.background)
}
.padding(.top, .medium3)
}
.navigationTitle(L10n.DisplayMnemonics.seedPhrases)
.background(.app.gray5)
.navigationTitle(L10n.SeedPhrases.title)
.toolbarBackground(.visible, for: .navigationBar)
.onFirstTask { @MainActor in
await viewStore.send(.onFirstTask).finish()
}
Expand All @@ -54,25 +70,15 @@ extension View {
)

return displayMnemonicSheet(with: destinationStore)
.useCautionAlert(with: destinationStore)
}

@MainActor
private func displayMnemonicSheet(with destinationStore: PresentationStoreOf<DisplayMnemonics.Destinations>) -> some View {
sheet(
navigationDestination(
store: destinationStore,
state: /DisplayMnemonics.Destinations.State.displayMnemonic,
action: DisplayMnemonics.Destinations.Action.displayMnemonic,
content: { DisplayMnemonic.View(store: $0) }
)
}

@MainActor
private func useCautionAlert(with destinationStore: PresentationStoreOf<DisplayMnemonics.Destinations>) -> some View {
alert(
store: destinationStore,
state: /DisplayMnemonics.Destinations.State.useCaution,
action: DisplayMnemonics.Destinations.Action.useCaution
destination: { DisplayMnemonic.View(store: $0) }
)
}
}
Expand Down
Loading

0 comments on commit 762e90a

Please sign in to comment.