Skip to content

Commit

Permalink
Optimising Sunset Wallet View (#418)
Browse files Browse the repository at this point in the history
Update Sunset Wallet view to handle both cases:
- Shielding Sunset
- Wallet Sunset
  • Loading branch information
ramakser authored Sep 25, 2024
1 parent 42f78bd commit 448d99c
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 49 deletions.
18 changes: 6 additions & 12 deletions ConcordiumWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8941,11 +8941,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "ConcordiumWallet/Resources/Entitlements/Concordium ID.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 64;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 64;
DEVELOPMENT_TEAM = K762RM4LQ3;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "ConcordiumWallet/Resources/ConcordiumWalletTestNet-Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = "TestNet Seed Phrase Wallet";
Expand All @@ -8964,7 +8962,6 @@
PRODUCT_BUNDLE_IDENTIFIER = software.concordium.mobilewallet.seedphrase.testnet;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore software.concordium.mobilewallet.seedphrase.testnet";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG ENABLE_GTU_DROP";
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/ConcordiumWallet-Briding-Header-File.h";
SWIFT_VERSION = 5.0;
Expand All @@ -8979,11 +8976,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "ConcordiumWallet/Resources/Entitlements/Concordium ID.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 64;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 64;
DEVELOPMENT_TEAM = K762RM4LQ3;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "ConcordiumWallet/Resources/ConcordiumWalletTestNet-Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = "TestNet Seed Phrase Wallet";
Expand All @@ -9002,7 +8997,6 @@
PRODUCT_BUNDLE_IDENTIFIER = software.concordium.mobilewallet.seedphrase.testnet;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore software.concordium.mobilewallet.seedphrase.testnet";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = ENABLE_GTU_DROP;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/ConcordiumWallet-Briding-Header-File.h";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion ConcordiumWallet/Service/SeedAccountsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct SeedAccountsService {
private let mobileWallet: SeedMobileWalletProtocol
private let networkManager: NetworkManagerProtocol
private let storageManager: StorageManagerProtocol
private let keychainWrapper: KeychainWrapperProtocol
let keychainWrapper: KeychainWrapperProtocol

init(
mobileWallet: SeedMobileWalletProtocol,
Expand Down
13 changes: 10 additions & 3 deletions ConcordiumWallet/Views/AccountsView/AccountsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class AccountsCoordinator: Coordinator {
let accountsViewController = AccountsFactory.create(with: accountsPresenter)
navigationController.viewControllers = [accountsViewController]

if !isShieldedAmountAbsent() {
// if !isShieldedAmountAbsent() {
showShieldingSunsetFlow()
}
// }
}

private func isShieldedAmountAbsent() -> Bool {
Expand All @@ -68,8 +68,15 @@ class AccountsCoordinator: Coordinator {
.allSatisfy { $0 }
}

func userShowPrivateKey() {
let view = RevealPrivateKeyView(viewModel: RevealPrivateKeyViewModel(dependencyProvider: self.dependencyProvider))
navigationController.pushViewController(UIHostingController(rootView: view), animated: true)
}

func showShieldingSunsetFlow() {
navigationController.present(UIHostingController(rootView: UnshiedSunsetView()), animated: true)
navigationController.present(UIHostingController(rootView: UnshiedSunsetView(showCopyPrivateKeyFlow: { [weak self] in
self?.userShowPrivateKey()
})), animated: true)
}

func showCreateNewAccount(withDefaultValuesFrom account: AccountDataType? = nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import SwiftUI

final class RevealPrivateKeyViewModel: ObservableObject {
typealias DependencyProvider = MoreFlowCoordinatorDependencyProvider & IdentitiesFlowCoordinatorDependencyProvider
typealias DependencyProvider = IdentitiesFlowCoordinatorDependencyProvider

@Published var privateKey: String = ""

Expand All @@ -23,8 +23,8 @@ final class RevealPrivateKeyViewModel: ObservableObject {

func getPrivateKey() async {
do {
let pwHash = try await passwordDelegate.requestUserPassword(keychain: dependencyProvider.keychainWrapper())
let seedValue = try dependencyProvider.keychainWrapper().getValue(for: "RecoveryPhraseSeed", securedByPassword: pwHash).get()
let pwHash = try await passwordDelegate.requestUserPassword(keychain: dependencyProvider.seedAccountsService().keychainWrapper)
let seedValue = try dependencyProvider.seedAccountsService().keychainWrapper.getValue(for: "RecoveryPhraseSeed", securedByPassword: pwHash).get()
await MainActor.run {
withAnimation {
self.privateKey = seedValue
Expand Down
137 changes: 107 additions & 30 deletions ConcordiumWallet/Views/UnshiedSunset/UnshiedSunsetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,77 @@ import SwiftUI
struct UnshiedSunsetView: View {
@SwiftUI.Environment(\.openURL) var openURL
@SwiftUI.Environment(\.dismiss) var dismiss


var showCopyPrivateKeyFlow: () -> Void

enum Tab: Int {
case sunset, shielding
}

@State var currentTab: UnshiedSunsetView.Tab = .sunset

var body: some View {
VStack(spacing: 32) {
TabView(selection: $currentTab) {
SunsetWallet().tag(Tab.sunset)
UnshieldingGoingAwayView().tag(Tab.shielding)
}
.tabViewStyle(.page(indexDisplayMode: .always))
.padding(.top, 61)

VStack(spacing: 24) {
Button {
dismiss()
showCopyPrivateKeyFlow()
} label: {
Label("Copy your seed phrase", image: "ico_copy")
.font(Font.system(size: 14, weight: .regular))
.multilineTextAlignment(.center)
.foregroundColor(.black)
}
.opacity(currentTab == .shielding ? 0 : 1.0)
.animation(.bouncy, value: currentTab)

Check failure on line 43 in ConcordiumWallet/Views/UnshiedSunset/UnshiedSunsetView.swift

View workflow job for this annotation

GitHub Actions / Test

type 'Animation?' has no member 'bouncy'

Check failure on line 43 in ConcordiumWallet/Views/UnshiedSunset/UnshiedSunsetView.swift

View workflow job for this annotation

GitHub Actions / Test

type 'Animation?' has no member 'bouncy'

Button {
if let url = URL(string: "itms-apps://itunes.apple.com/app/id1593386457"), UIApplication.shared.canOpenURL(url) {
openURL(url)
}
} label: {
Text("Install CryptoX Concordium wallet")
.font(Font.system(size: 14, weight: .medium))
.multilineTextAlignment(.center)
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.frame(height: 48)
.contentShape(.rect)
}
.foregroundColor(.clear)
.background(Color(red: 0.27, green: 0.53, blue: 0.67))
.cornerRadius(8)

Button {
dismiss()
} label: {
Text("Continue with the old wallet")
.font(Font.system(size: 14, weight: .semibold))
.multilineTextAlignment(.center)
.foregroundColor(.black)
}
}
.padding(.horizontal, 32)
.onAppear(perform: {
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(Color(red: 0.27, green: 0.53, blue: 0.67))
UIPageControl.appearance().pageIndicatorTintColor = UIColor(Color(red: 0.27, green: 0.53, blue: 0.67)).withAlphaComponent(0.2)
})
}
}

func SunsetWallet() -> some View {
ScrollView {
VStack(spacing: 32) {
VStack(spacing: 12) {
Image("ico_unshield")
Text("Transaction Shielding\nis going away")
// Image("ico_unshield")
Text("This wallet is going\naway soon")
.font(Font.system(size: 30, weight: .regular))
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.27, green: 0.53, blue: 0.67))
Expand All @@ -26,7 +90,7 @@ struct UnshiedSunsetView: View {
.padding(.top, 24)

VStack(spacing: 24) {
Text("We recommend that you unshield any Shielded balance today. To do so move your account to the new CryptoX Concordium wallet.")
Text("To continue using Concordium, move your account to the new CryptoX wallet.")
.font(Font.system(size: 14, weight: .regular))
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.2, green: 0.2, blue: 0.2))
Expand All @@ -50,35 +114,48 @@ struct UnshiedSunsetView: View {
.foregroundColor(Color(red: 0.2, green: 0.2, blue: 0.2))
}
.padding(.horizontal, 16)
}
}
}

func UnshieldingGoingAwayView() -> some View {
ScrollView {
VStack(spacing: 32) {
VStack(spacing: 12) {
Image("ico_unshield")
Text("Transaction Shielding\nis going away")
.font(Font.system(size: 30, weight: .regular))
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.27, green: 0.53, blue: 0.67))
}
.padding(.horizontal, 16)
.padding(.top, 24)

VStack(spacing: 24) {
Button {
if let url = URL(string: "itms-apps://itunes.apple.com/app/id1593386457"), UIApplication.shared.canOpenURL(url) {
openURL(url)
}
} label: {
Text("Install CryptoX Concordium wallet")
.font(Font.system(size: 14, weight: .medium))
.multilineTextAlignment(.center)
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.frame(height: 48)
.contentShape(.rect)
}
.foregroundColor(.clear)
.background(Color(red: 0.27, green: 0.53, blue: 0.67))
.cornerRadius(8)

Button {
dismiss()
} label: {
Text("Continue with the old wallet")
.font(Font.system(size: 14, weight: .semibold))
.multilineTextAlignment(.center)
.foregroundColor(.black)
}
Text("We recommend that you unshield any Shielded balance today. To do so move your account to the new CryptoX Concordium wallet.")
.font(Font.system(size: 14, weight: .regular))
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.2, green: 0.2, blue: 0.2))
Text(
"""
1. Install the CryptoX Concordium wallet
2. Copy your seed phrase
3. Insert your seed phrase in the CryptoX wallet
"""
)
.font(Font.system(size: 14, weight: .bold))
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.2, green: 0.2, blue: 0.2))
Text("When that’s done, you will be able to unshield your Shielded balance through the CryptoX wallet, and you can safely delete this one.")
.font(Font.system(size: 14, weight: .regular))
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.2, green: 0.2, blue: 0.2))
Text("Don’t worry, your wallet will stay here on your device until you uninstall it, but we highly encourage you to migrate today.")
.font(Font.system(size: 14, weight: .regular))
.multilineTextAlignment(.center)
.foregroundColor(Color(red: 0.2, green: 0.2, blue: 0.2))
}
.padding(.horizontal, 32)
.padding(.horizontal, 16)
}
}
}
Expand Down

0 comments on commit 448d99c

Please sign in to comment.