Skip to content

Commit

Permalink
Add connected sheet to wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-lsvk committed Nov 9, 2023
1 parent 37856b4 commit 34fb779
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
C56EE28F293F5757004840D1 /* MigrationConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C56EE283293F5757004840D1 /* MigrationConfigurator.swift */; };
C56EE2A3293F6BAF004840D1 /* UIPasteboardWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C56EE2A2293F6BAF004840D1 /* UIPasteboardWrapper.swift */; };
C579FEB62AFA86CD008855EB /* Web3Modal in Frameworks */ = {isa = PBXBuildFile; productRef = C579FEB52AFA86CD008855EB /* Web3Modal */; };
C579FEBA2AFCDFA6008855EB /* ConnectedSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C579FEB92AFCDFA6008855EB /* ConnectedSheetView.swift */; };
C58099352A543CD000AB58F5 /* BlinkAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C58099342A543CD000AB58F5 /* BlinkAnimation.swift */; };
C5B2F6F629705293000DBA0E /* SessionRequestModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5B2F6F12970511B000DBA0E /* SessionRequestModule.swift */; };
C5B2F6F729705293000DBA0E /* SessionRequestRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5B2F6F32970511B000DBA0E /* SessionRequestRouter.swift */; };
Expand Down Expand Up @@ -638,6 +639,7 @@
C56EE287293F5757004840D1 /* AppearanceConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceConfigurator.swift; sourceTree = "<group>"; };
C56EE29F293F5C4F004840D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C56EE2A2293F6BAF004840D1 /* UIPasteboardWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIPasteboardWrapper.swift; sourceTree = "<group>"; };
C579FEB92AFCDFA6008855EB /* ConnectedSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectedSheetView.swift; sourceTree = "<group>"; };
C58099342A543CD000AB58F5 /* BlinkAnimation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlinkAnimation.swift; sourceTree = "<group>"; };
C5B2F6F12970511B000DBA0E /* SessionRequestModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionRequestModule.swift; sourceTree = "<group>"; };
C5B2F6F22970511B000DBA0E /* SessionRequestPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionRequestPresenter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1655,6 +1657,7 @@
C56EE25C293F56D6004840D1 /* Common */ = {
isa = PBXGroup;
children = (
C579FEB82AFCDF83008855EB /* Views */,
C56EE25D293F56D6004840D1 /* InputConfig.swift */,
84B8154D2991099000FAD54E /* BuildConfiguration.swift */,
C56EE267293F56D6004840D1 /* Style */,
Expand Down Expand Up @@ -1769,6 +1772,14 @@
path = Helpers;
sourceTree = "<group>";
};
C579FEB82AFCDF83008855EB /* Views */ = {
isa = PBXGroup;
children = (
C579FEB92AFCDFA6008855EB /* ConnectedSheetView.swift */,
);
path = Views;
sourceTree = "<group>";
};
C5B2F6F029705111000DBA0E /* SessionRequest */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2547,6 +2558,7 @@
A51811A12A52E83100A52B15 /* SettingsRouter.swift in Sources */,
C56EE279293F56D7004840D1 /* Color.swift in Sources */,
847BD1E6298A806800076C90 /* NotificationsRouter.swift in Sources */,
C579FEBA2AFCDFA6008855EB /* ConnectedSheetView.swift in Sources */,
C55D3483295DD7140004314A /* AuthRequestView.swift in Sources */,
C56EE243293F566D004840D1 /* ScanView.swift in Sources */,
84310D05298BC980000C15B6 /* MainInteractor.swift in Sources */,
Expand Down
38 changes: 38 additions & 0 deletions Example/WalletApp/Common/Views/ConnectedSheetView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import SwiftUI

struct ConnectedSheetView: View {
let title: String

var body: some View {
ZStack {
VStack {
Image("connected")

Spacer()
}

VStack(spacing: 8) {
Rectangle()
.foregroundColor(.clear)
.frame(width: 48, height: 4)
.background(Color(red: 0.02, green: 0.17, blue: 0.17).opacity(0.2))
.cornerRadius(100)
.padding(.top, 8)

Text(title)
.foregroundColor(.grey8)
.font(.system(size: 20, weight: .semibold, design: .rounded))
.padding(.top, 168)


Text("You can go back to your browser now")
.foregroundColor(Color(red: 0.47, green: 0.53, blue: 0.53))
.font(.system(size: 16, weight: .medium, design: .rounded))

Spacer()
}
}
.presentationDetents([.height(254)])
.presentationDragIndicator(.hidden)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "connected.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ final class AuthRequestPresenter: ObservableObject {
return interactor.formatted(request: request, account: importAccount.account)
}

@Published var showSignedSheet = false

private var disposeBag = Set<AnyCancellable>()

init(
Expand All @@ -35,14 +37,18 @@ final class AuthRequestPresenter: ObservableObject {
@MainActor
func onApprove() async throws {
try await interactor.approve(request: request, importAccount: importAccount)
router.dismiss()
showSignedSheet.toggle()
}

@MainActor
func onReject() async throws {
try await interactor.reject(request: request)
router.dismiss()
}

func onSignedSheetDismiss() {
router.dismiss()
}
}

// MARK: - Private functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ struct AuthRequestView: View {
Spacer()
}
}
.sheet(
isPresented: $presenter.showSignedSheet,
onDismiss: presenter.onSignedSheetDismiss
) {
ConnectedSheetView(title: "Request is signed")
}
.edgesIgnoringSafeArea(.all)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class SessionProposalPresenter: ObservableObject {

@Published var showError = false
@Published var errorMessage = "Error"
@Published var showConnectedSheet = false

private var disposeBag = Set<AnyCancellable>()

Expand All @@ -35,7 +36,7 @@ final class SessionProposalPresenter: ObservableObject {
func onApprove() async throws {
do {
try await interactor.approve(proposal: sessionProposal, account: importAccount.account)
router.dismiss()
showConnectedSheet.toggle()
} catch {
errorMessage = error.localizedDescription
showError.toggle()
Expand All @@ -52,6 +53,10 @@ final class SessionProposalPresenter: ObservableObject {
showError.toggle()
}
}

func onConnectedSheetDismiss() {
router.dismiss()
}
}

// MARK: - Private functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ struct SessionProposalView: View {
.alert(presenter.errorMessage, isPresented: $presenter.showError) {
Button("OK", role: .cancel) {}
}
.sheet(
isPresented: $presenter.showConnectedSheet,
onDismiss: presenter.onConnectedSheetDismiss
) {
ConnectedSheetView(title: "Connected")
}
.edgesIgnoringSafeArea(.all)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final class SessionRequestPresenter: ObservableObject {

@Published var showError = false
@Published var errorMessage = "Error"
@Published var showSignedSheet = false

private var disposeBag = Set<AnyCancellable>()

Expand All @@ -43,7 +44,7 @@ final class SessionRequestPresenter: ObservableObject {
func onApprove() async throws {
do {
try await interactor.approve(sessionRequest: sessionRequest, importAccount: importAccount)
router.dismiss()
showSignedSheet.toggle()
} catch {
errorMessage = error.localizedDescription
showError.toggle()
Expand All @@ -55,6 +56,10 @@ final class SessionRequestPresenter: ObservableObject {
try await interactor.reject(sessionRequest: sessionRequest)
router.dismiss()
}

func onSignedSheetDismiss() {
router.dismiss()
}
}

// MARK: - Private functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ struct SessionRequestView: View {
.alert(presenter.errorMessage, isPresented: $presenter.showError) {
Button("OK", role: .cancel) {}
}
.sheet(
isPresented: $presenter.showSignedSheet,
onDismiss: presenter.onSignedSheetDismiss
) {
ConnectedSheetView(title: "Request is signed")
}
}
.edgesIgnoringSafeArea(.all)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class WalletPresenter: ObservableObject {
@Published var showPairingLoading = false
@Published var showError = false
@Published var errorMessage = "Error"
@Published var showConnectedSheet = false

private var disposeBag = Set<AnyCancellable>()

Expand Down
30 changes: 30 additions & 0 deletions Example/WalletApp/PresentationLayer/Wallet/Wallet/WalletView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,36 @@ struct WalletView: View {
.alert(presenter.errorMessage, isPresented: $presenter.showError) {
Button("OK", role: .cancel) {}
}
.sheet(isPresented: $presenter.showConnectedSheet) {
ZStack {
VStack {
Image("connected")

Spacer()
}

VStack(spacing: 8) {
Rectangle()
.foregroundColor(.clear)
.frame(width: 48, height: 4)
.background(Color(red: 0.02, green: 0.17, blue: 0.17).opacity(0.2))
.cornerRadius(100)
.padding(.top, 8)

Text("Connected")
.foregroundColor(.grey8)
.font(.system(size: 20, weight: .semibold, design: .rounded))
.padding(.top, 168)


Text("You can go back to your browser now")
.foregroundColor(Color(red: 0.47, green: 0.53, blue: 0.53))
.font(.system(size: 16, weight: .medium, design: .rounded))

Spacer()
}
}
}
.onAppear {
presenter.onAppear()
}
Expand Down

0 comments on commit 34fb779

Please sign in to comment.