Skip to content

Commit

Permalink
fix: missing filter missing in the empty state (#2432)
Browse files Browse the repository at this point in the history
* feat: add custom modifier for plain text field

* refactor

* fix: display header with filter button in the empty state

* refactor into separate extensions
  • Loading branch information
ERussel authored Feb 20, 2025
1 parent 90fbea6 commit e9224ba
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ import SwiftUI

extension KeyDetailsView {
@ViewBuilder
func emptyState() -> some View {
func emptyKeysList() -> some View {
VStack(spacing: 0) {
// Main key cell
rootKeyHeader()
// Derived Keys header
listHeader()
Spacer()
// Empty state
emptyState()
Spacer()
}
}

@ViewBuilder
private func emptyState() -> some View {
VStack(spacing: 0) {
Localizable.KeyDetails.Label.EmptyState.header.text
.font(PrimaryFont.titleM.font)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,24 @@ extension KeyDetailsView {
EmptyView()
}
}

@ViewBuilder
func listHeader() -> some View {
HStack {
Localizable.KeyDetails.Label.derived.text
.font(PrimaryFont.bodyM.font)
Spacer().frame(maxWidth: .infinity)
Image(.switches)
.foregroundColor(
viewModel.isFilteringActive ? .accentPink300 : .textAndIconsTertiary
)
.frame(width: Heights.actionSheetButton)
.onTapGesture {
viewModel.onNetworkSelectionTap()
}
}
.foregroundColor(.textAndIconsTertiary)
.padding(.horizontal, Spacing.large)
.padding(.top, Spacing.medium)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,14 @@ extension KeyDetailsView {
@ViewBuilder
func derivedKeysList() -> some View {
ScrollView(showsIndicators: false) {
// Main key cell
rootKeyHeader()
// Derived Keys header
HStack {
Localizable.KeyDetails.Label.derived.text
.font(PrimaryFont.bodyM.font)
Spacer().frame(maxWidth: .infinity)
Image(.switches)
.foregroundColor(
viewModel.isFilteringActive ? .accentPink300 : .textAndIconsTertiary
)
.frame(width: Heights.actionSheetButton)
.onTapGesture {
viewModel.onNetworkSelectionTap()
}
VStack(spacing: 0) {
// Main key cell
rootKeyHeader()
// Derived Keys header
listHeader()
// List
derivedKeys()
}
.foregroundColor(.textAndIconsTertiary)
.padding(.horizontal, Spacing.large)
.padding(.top, Spacing.medium)
// List
derivedKeys()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ struct KeyDetailsView: View {
case .list:
derivedKeysList()
case .emptyState:
rootKeyHeader()
Spacer()
emptyState()
Spacer()
emptyKeysList()
}
}
.navigationBarHidden(true)
Expand Down

0 comments on commit e9224ba

Please sign in to comment.