Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Extract TransactionsSheetType to unify sheet presentation state#1838

Merged
DRadmir merged 1 commit intomainfrom
refactor/transactions-sheet-type
Mar 26, 2026
Merged

Extract TransactionsSheetType to unify sheet presentation state#1838
DRadmir merged 1 commit intomainfrom
refactor/transactions-sheet-type

Conversation

@DRadmir
Copy link
Copy Markdown
Contributor

@DRadmir DRadmir commented Mar 26, 2026

No description provided.

@DRadmir DRadmir self-assigned this Mar 26, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the sheet presentation logic by introducing a unified TransactionsSheetType enum, which replaces multiple state variables in TransactionsViewModel with a single isPresentingSheet property. This change simplifies the view logic in TransactionsNavigationStack by consolidating sheet modifiers. A review comment suggests further improving the readability of the view body by extracting the sheet's content logic into a separate private @ViewBuilder function.

Comment on lines +55 to 76
.sheet(item: $model.isPresentingSheet) { type in
switch type {
case .filter:
NavigationStack {
TransactionsFilterScene(model: $model.filterModel)
}
.presentationDetentsForCurrentDeviceSize(expandable: true)
.presentationDragIndicator(.visible)
.presentationBackground(Colors.grayBackground)
case .selectAsset(let selectType):
SelectAssetSceneNavigationStack(
model: SelectAssetViewModel(
wallet: model.wallet,
selectType: selectType,
searchService: assetSearchService,
assetsEnabler: assetsEnabler,
priceAlertService: priceAlertService,
activityService: activityService
)
)
)
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and maintainability, consider extracting the sheet's content view builder into a separate private @ViewBuilder function. This will make the body of your view cleaner and easier to read, especially since the switch statement contains non-trivial logic for each case.

For example, you could replace the closure with a method reference:

.sheet(item: $model.isPresentingSheet, content: sheetContent)

And then define the sheetContent method within your TransactionsNavigationStack struct:

@ViewBuilder
private func sheetContent(for type: TransactionsSheetType) -> some View {
    switch type {
    case .filter:
        NavigationStack {
            TransactionsFilterScene(model: $model.filterModel)
        }
        .presentationDetentsForCurrentDeviceSize(expandable: true)
        .presentationDragIndicator(.visible)
        .presentationBackground(Colors.grayBackground)
    case .selectAsset(let selectType):
        SelectAssetSceneNavigationStack(
            model: SelectAssetViewModel(
                wallet: model.wallet,
                selectType: selectType,
                searchService: assetSearchService,
                assetsEnabler: assetsEnabler,
                priceAlertService: priceAlertService,
                activityService: activityService
            )
        )
    }
}

@DRadmir DRadmir merged commit 3e2db76 into main Mar 26, 2026
1 check passed
@DRadmir DRadmir deleted the refactor/transactions-sheet-type branch March 26, 2026 17:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants