-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7762c33
commit 1693622
Showing
10 changed files
with
235 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...alletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountModule.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...etApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountPresenter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...alletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountRouter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
} |
134 changes: 134 additions & 0 deletions
134
.../WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccount/UpgradeToSmartAccountView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
3 changes: 0 additions & 3 deletions
3
Example/WalletApp/PresentationLayer/Wallet/UpgradeToSmartAccountView.swift
This file was deleted.
Oops, something went wrong.