diff --git a/Example/ExampleApp.xcodeproj/project.pbxproj b/Example/ExampleApp.xcodeproj/project.pbxproj index 5039c951a..37793c64a 100644 --- a/Example/ExampleApp.xcodeproj/project.pbxproj +++ b/Example/ExampleApp.xcodeproj/project.pbxproj @@ -78,6 +78,9 @@ 84AEF01B2D3DD9F1006E43E5 /* SendStableCoinRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AEF01A2D3DD9F1006E43E5 /* SendStableCoinRouter.swift */; }; 84AEF01D2D3DDA0A006E43E5 /* SendStableCoinPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AEF01C2D3DDA0A006E43E5 /* SendStableCoinPresenter.swift */; }; 84AEF01F2D3DE7A0006E43E5 /* UpgradeToSmartAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AEF01E2D3DE7A0006E43E5 /* UpgradeToSmartAccountView.swift */; }; + 84AEF0222D3DE7C8006E43E5 /* UpgradeToSmartAccountPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AEF0212D3DE7C8006E43E5 /* UpgradeToSmartAccountPresenter.swift */; }; + 84AEF0242D3DE7D4006E43E5 /* UpgradeToSmartAccountModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AEF0232D3DE7D4006E43E5 /* UpgradeToSmartAccountModule.swift */; }; + 84AEF0262D3DE7E0006E43E5 /* UpgradeToSmartAccountRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AEF0252D3DE7E0006E43E5 /* UpgradeToSmartAccountRouter.swift */; }; 84B8154E2991099000FAD54E /* BuildConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B8154D2991099000FAD54E /* BuildConfiguration.swift */; }; 84B8155B2992A18D00FAD54E /* NotifyMessageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B8155A2992A18D00FAD54E /* NotifyMessageViewModel.swift */; }; 84CA52172C88965C0069BB33 /* ReownRouter in Frameworks */ = {isa = PBXBuildFile; productRef = 84CA52162C88965C0069BB33 /* ReownRouter */; }; @@ -391,6 +394,9 @@ 84AEF01A2D3DD9F1006E43E5 /* SendStableCoinRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendStableCoinRouter.swift; sourceTree = ""; }; 84AEF01C2D3DDA0A006E43E5 /* SendStableCoinPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendStableCoinPresenter.swift; sourceTree = ""; }; 84AEF01E2D3DE7A0006E43E5 /* UpgradeToSmartAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeToSmartAccountView.swift; sourceTree = ""; }; + 84AEF0212D3DE7C8006E43E5 /* UpgradeToSmartAccountPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeToSmartAccountPresenter.swift; sourceTree = ""; }; + 84AEF0232D3DE7D4006E43E5 /* UpgradeToSmartAccountModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeToSmartAccountModule.swift; sourceTree = ""; }; + 84AEF0252D3DE7E0006E43E5 /* UpgradeToSmartAccountRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeToSmartAccountRouter.swift; sourceTree = ""; }; 84B8154D2991099000FAD54E /* BuildConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuildConfiguration.swift; sourceTree = ""; }; 84B8155A2992A18D00FAD54E /* NotifyMessageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotifyMessageViewModel.swift; sourceTree = ""; }; 84CE641C27981DED00142511 /* DApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -855,6 +861,17 @@ path = SendStableCoin; sourceTree = ""; }; + 84AEF0202D3DE7B1006E43E5 /* UpgradeToSmartAccount */ = { + isa = PBXGroup; + children = ( + 84AEF01E2D3DE7A0006E43E5 /* UpgradeToSmartAccountView.swift */, + 84AEF0212D3DE7C8006E43E5 /* UpgradeToSmartAccountPresenter.swift */, + 84AEF0232D3DE7D4006E43E5 /* UpgradeToSmartAccountModule.swift */, + 84AEF0252D3DE7E0006E43E5 /* UpgradeToSmartAccountRouter.swift */, + ); + path = UpgradeToSmartAccount; + sourceTree = ""; + }; 84B815592991217F00FAD54E /* PushMessages */ = { isa = PBXGroup; children = ( @@ -1206,7 +1223,7 @@ 84B815592991217F00FAD54E /* PushMessages */, 84D88C802CE751EE003A6C16 /* CATransactionModal */, 84AEF0172D3DD8D3006E43E5 /* SendStableCoin */, - 84AEF01E2D3DE7A0006E43E5 /* UpgradeToSmartAccountView.swift */, + 84AEF0202D3DE7B1006E43E5 /* UpgradeToSmartAccount */, ); path = Wallet; sourceTree = ""; @@ -1998,6 +2015,7 @@ C56EE250293F566D004840D1 /* ScanTargetView.swift in Sources */, C56EE28F293F5757004840D1 /* MigrationConfigurator.swift in Sources */, A5A0844029D2F626000B9B17 /* DefaultCryptoProvider.swift in Sources */, + 84AEF0262D3DE7E0006E43E5 /* UpgradeToSmartAccountRouter.swift in Sources */, 847BD1DD2989494F00076C90 /* TabPage.swift in Sources */, A50D53C42ABA055700A4FD8B /* NotifyPreferencesInteractor.swift in Sources */, A50D53C22ABA055700A4FD8B /* NotifyPreferencesPresenter.swift in Sources */, @@ -2033,6 +2051,7 @@ A74D32BA2A1E25AD00CB8536 /* QueryParameters.swift in Sources */, C56EE270293F56D7004840D1 /* String.swift in Sources */, A51811A12A52E83100A52B15 /* SettingsRouter.swift in Sources */, + 84AEF0222D3DE7C8006E43E5 /* UpgradeToSmartAccountPresenter.swift in Sources */, C56EE279293F56D7004840D1 /* Color.swift in Sources */, 847BD1E6298A806800076C90 /* NotificationsRouter.swift in Sources */, 848BD1DE2D34DF8F007C2AEF /* EOASigner.swift in Sources */, @@ -2090,6 +2109,7 @@ A50B6A382B06697B00162B01 /* ProfilingService.swift in Sources */, A5B4F7C52ABB20AE0099AF7C /* SubscriptionRouter.swift in Sources */, C55D3496295DFA750004314A /* WelcomeInteractor.swift in Sources */, + 84AEF0242D3DE7D4006E43E5 /* UpgradeToSmartAccountModule.swift in Sources */, C5B2F6FC297055B0000DBA0E /* SOLSigner.swift in Sources */, A518119F2A52E83100A52B15 /* SettingsModule.swift in Sources */, 84D88C842CE754CC003A6C16 /* CATransactionModule.swift in Sources */, diff --git a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinModule.swift b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinModule.swift index 1e1583d3f..13fa7555e 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinModule.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinModule.swift @@ -9,7 +9,7 @@ final class SendStableCoinModule { importAccount: ImportAccount ) -> UIViewController { let router = SendStableCoinRouter(app: app) - let presenter = SendStableCoinPresenter() + let presenter = SendStableCoinPresenter(router: router, importAccount: importAccount) let view = SendStableCoinView(presenter: presenter).environmentObject(presenter) let viewController = SceneViewController(viewModel: presenter, content: view) router.viewController = viewController diff --git a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinPresenter.swift b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinPresenter.swift index 5ae940428..56122f6b9 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinPresenter.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinPresenter.swift @@ -17,7 +17,7 @@ final class SendStableCoinPresenter: ObservableObject, SceneViewModel { init(router: SendStableCoinRouter, importAccount: ImportAccount) { self.router = router - + self.importAccount = importAccount } func set(network: L2) { @@ -28,9 +28,3 @@ final class SendStableCoinPresenter: ObservableObject, SceneViewModel { router.presentUpgradeToSmartAccount(importAccount: importAccount, network: selectedNetwork) } } - - -UpgradeToSmartAccountPresenter -UpgradeToSmartAccountView -UpgradeToSmartAccountModule -UpgradeToSmartAccountRouter diff --git a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinRouter.swift b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinRouter.swift index 6e5a10aef..c31512df4 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinRouter.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinRouter.swift @@ -18,5 +18,7 @@ final class SendStableCoinRouter { func presentUpgradeToSmartAccount(importAccount: ImportAccount, network: L2) { + UpgradeToSmartAccountModule.create(app: app, importAccount: importAccount, network: network) + .present(from: viewController) } } diff --git a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinView.swift b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinView.swift index fbc41e35b..5481a0b6a 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/SendStableCoin/SendStableCoinView.swift @@ -26,7 +26,7 @@ struct SendStableCoinView: View { } Spacer() Button(action: { - // TODO: handle upgrade to smart account + presenter.upgradeToSmartAccount() }) { Text("Upgrade to Smart Account") .foregroundColor(.blue) diff --git a/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountModule.swift b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountModule.swift new file mode 100644 index 000000000..b1cd0ea96 --- /dev/null +++ b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountModule.swift @@ -0,0 +1,27 @@ +import Foundation +import UIKit + +final class UpgradeToSmartAccountModule { + @discardableResult + static func create( + app: Application, + importAccount: ImportAccount, + network: L2 + ) -> UIViewController { + let router = UpgradeToSmartAccountRouter(app: app) + let presenter = UpgradeToSmartAccountPresenter( + router: router, + importAccount: importAccount, + network: network + ) + + // Build the SwiftUI view, injecting the presenter + let view = UpgradeToSmartAccountView(presenter: presenter) + + // Wrap it in your SceneViewController or whichever container + let viewController = SceneViewController(viewModel: presenter, content: view) + router.viewController = viewController + + return viewController + } +} diff --git a/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountPresenter.swift b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountPresenter.swift new file mode 100644 index 000000000..82f46449e --- /dev/null +++ b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountPresenter.swift @@ -0,0 +1,30 @@ +import Foundation +import ReownWalletKit + +final class UpgradeToSmartAccountPresenter: ObservableObject, SceneViewModel { + @Published var selectedNetwork: L2 + @Published var doNotAskAgain = false + + let router: UpgradeToSmartAccountRouter + let importAccount: ImportAccount + + init(router: UpgradeToSmartAccountRouter, + importAccount: ImportAccount, + network: L2) { + self.router = router + self.importAccount = importAccount + self.selectedNetwork = network + } + + /// Called when user taps the 'Sign & Upgrade' button + func signAndUpgrade() { + // TODO: Implement any logic needed before upgrading + // For now, just dismiss or call into router if needed + router.dismiss() + } + + /// Called when user taps the 'Cancel' or 'X' button + func cancel() { + router.dismiss() + } +} diff --git a/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountRouter.swift b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountRouter.swift new file mode 100644 index 000000000..c6828be23 --- /dev/null +++ b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountRouter.swift @@ -0,0 +1,18 @@ +import Foundation +import UIKit + +final class UpgradeToSmartAccountRouter { + weak var viewController: UIViewController? + private let app: Application + + init(app: Application) { + self.app = app + } + + /// Dismiss this screen + func dismiss() { + DispatchQueue.main.async { [weak self] in + self?.viewController?.dismiss(animated: true) + } + } +} diff --git a/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountView.swift b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountView.swift new file mode 100644 index 000000000..e77a33464 --- /dev/null +++ b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountView.swift @@ -0,0 +1,134 @@ +import SwiftUI + +struct UpgradeToSmartAccountView: View { + @ObservedObject var presenter: UpgradeToSmartAccountPresenter + + var body: some View { + VStack(spacing: 0) { + // Top Header + HStack { + Text("Upgrade to Smart Account") + .font(.headline) + .foregroundColor(.white) + Spacer() + Button(action: { + presenter.cancel() + }) { + Image(systemName: "xmark") + .foregroundColor(.white) + } + } + .padding() + + // Explanation text + Text("To upgrade your account, you need to sign a transaction with your wallet.") + .font(.subheadline) + .foregroundColor(.gray) + .multilineTextAlignment(.center) + .padding(.horizontal, 16) + .padding(.bottom, 16) + + // Features card + VStack(alignment: .leading, spacing: 12) { + Text("Get access to advanced features") + .font(.body).bold() + + Label("Sponsored Transactions", systemImage: "checkmark.circle.fill") + .foregroundColor(.green) + Label("Bundle Transactions", systemImage: "checkmark.circle.fill") + .foregroundColor(.green) + + Text("and more in the future...") + .foregroundColor(.gray) + } + .padding() + .background(Color("grey-section")) + .cornerRadius(16) + .padding(.horizontal, 16) + .padding(.bottom, 16) + + // Wallet/Network/Fees card + VStack(alignment: .leading, spacing: 8) { + HStack { + Text("Wallet") + .foregroundColor(.gray) + Spacer() + Text(presenter.importAccount.account.address) + .font(.system(.body, design: .monospaced)) + } + Divider() + HStack { + Text("Network") + .foregroundColor(.gray) + Spacer() + Text(presenter.selectedNetwork.rawValue) + .foregroundColor(.blue) + } + Divider() + HStack { + Text("Fees") + .foregroundColor(.gray) + Spacer() + Text("FREE") + .foregroundColor(.green) + } + Divider() + HStack { + Text("Sponsored By") + .foregroundColor(.gray) + Spacer() + Text("reown") // Example sponsor + } + } + .padding() + .background(Color("grey-section")) + .cornerRadius(16) + .padding(.horizontal, 16) + .padding(.bottom, 16) + + // Do once toggle + Toggle("Do it once and don't ask me again.", isOn: $presenter.doNotAskAgain) + .toggleStyle(SwitchToggleStyle(tint: .blue)) + .padding(.horizontal, 16) + .padding(.bottom, 16) + .foregroundColor(.white) + + Spacer() + + // Bottom actions row + HStack { + Button(action: { + presenter.cancel() + }) { + Text("Cancel") + .foregroundColor(.white) + } + .padding(.horizontal, 24) + .padding(.vertical, 12) + .background(Color(.systemGray3).opacity(0.3)) + .cornerRadius(12) + + Spacer() + + Button(action: { + presenter.signAndUpgrade() + }) { + Text("Sign & Upgrade") + .fontWeight(.semibold) + .foregroundColor(.white) + .padding(.horizontal, 24) + .padding(.vertical, 12) + .background( + LinearGradient(gradient: Gradient(colors: [.purple, .blue]), + startPoint: .leading, + endPoint: .trailing) + ) + .cornerRadius(12) + } + } + .padding(.horizontal, 16) + .padding(.bottom, 16) + } + .background(Color.black.edgesIgnoringSafeArea(.all)) // Example dark background + } +} diff --git a/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccountView.swift b/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccountView.swift deleted file mode 100644 index 57be8e8ec..000000000 --- a/Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccountView.swift +++ /dev/null @@ -1,3 +0,0 @@ -// - -import Foundation