Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-3021] Close button placement on sheets #1067

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,23 @@ extension SlideUpPanel.State {

// MARK: - WithNavigationBar
public struct WithNavigationBar<Content: View>: View {
private let closeButtonLocation: ToolbarItemPlacement
private let closeAction: () -> Void
private let content: Content

public init(
_ closeButtonLocation: ToolbarItemPlacement = .primaryAction,
closeAction: @escaping () -> Void,
@ViewBuilder content: () -> Content
) {
self.init(
closeButtonLocation,
closeAction: closeAction,
content: content()
)
}

init(
_ closeButtonLocation: ToolbarItemPlacement = .primaryAction,
closeAction: @escaping () -> Void,
content: Content
) {
self.closeButtonLocation = closeButtonLocation
self.content = content
self.closeAction = closeAction
}
Expand All @@ -41,7 +36,7 @@ public struct WithNavigationBar<Content: View>: View {
content
.presentationDragIndicator(.visible)
.toolbar {
ToolbarItem(placement: closeButtonLocation) {
ToolbarItem(placement: .cancellationAction) {
CloseButton(action: closeAction)
}
}
Expand All @@ -64,10 +59,9 @@ extension View {
}

public func withNavigationBar(
_ closeButtonLocation: ToolbarItemPlacement = .primaryAction,
closeAction: @escaping () -> Void
) -> some View {
WithNavigationBar(closeButtonLocation, closeAction: closeAction, content: self)
WithNavigationBar(closeAction: closeAction, content: self)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private extension View {
return sheet(store: destinationStore.scope(state: \.reviewTransaction, action: \.reviewTransaction)) {
// FIXME: Should use DappInteractionClient instead to schedule a transaction
TransactionReview.View(store: $0)
.withNavigationBar(.topBarLeading) {
.withNavigationBar {
store.send(.view(.closeTransactionButtonTapped))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public extension AccountRecoveryScanInProgress {
}
.toolbar {
if viewStore.showToolbar {
ToolbarItem(placement: .automatic) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
store.send(.view(.closeButtonTapped))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension AddLedgerFactorSource {
.padding(.bottom, .large2)
}
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
viewStore.send(.closeButtonTapped)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct DetailsContainer<Contents: View>: View {
.navigationBarTitleDisplayMode(.inline)
.navigationBarInlineTitleFont(.app.secondaryHeader)
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton(action: closeButtonAction)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension CreateAccountCoordinator {
destinations(for: $0, shouldDisplayNavBar: viewStore.shouldDisplayNavBar)
.toolbar {
if viewStore.shouldDisplayNavBar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
store.send(.view(.closeButtonTapped))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension EditPersona {
.navigationTitle(viewStore.personaLabel)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton { viewStore.send(.closeButtonTapped) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension EditPersonaAddEntryKinds {
.navigationBarTitleDisplayMode(.inline)
.navigationBarInlineTitleFont(.app.secondaryHeader)
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton(action: { viewStore.send(.closeButtonTapped) })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension NewConnection {
}
}
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
store.send(.view(.closeButtonTapped))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension ConfirmSkippingBDFS {
.padding(.bottom, .medium2)
}
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
store.send(.view(.closeButtonTapped))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public struct ImportMnemonicsFlowCoordinator: Sendable, FeatureReducer {
let treatAsImplicitMain = !toImport.hasAnyBDFSExplicitlyMarkedMain
mnemonicsLeftToImport[id: firstBabylonDeviceFactorSource.id]?.isMainBDFS = treatAsImplicitMain
} else {
assertionFailure("DISCREPANCY, no babylon device factor source, invalid profile.")
loggerGlobal.notice("no mnemonics to import - probably you uninstalled the app with mnemonics still intact in Keychain")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension SelectBackup {
WithViewStore(store, observe: { $0 }, send: { .view($0) }) { viewStore in
coreView(store, with: viewStore)
.toolbar {
ToolbarItem(placement: .automatic) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
store.send(.view(.closeButtonTapped))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension ManualAccountRecoveryCoordinator.View {
}
.background(.app.white)
.toolbar {
ToolbarItem(placement: .automatic) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
store.send(.view(.closeButtonTapped))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension ImportOlympiaWalletCoordinator {
let scanQRStore = store.scope(state: \.scanQR, action: { .child(.scanQR($0)) })
ScanMultipleOlympiaQRCodes.View(store: scanQRStore)
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton {
store.send(.view(.closeButtonTapped))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension UnknownDappComponents {
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .cancellationAction) {
CloseButton { store.send(.view(.closeButtonTapped)) }
}
}
Expand Down
Loading