Skip to content

Commit

Permalink
Added empty view information (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldavidw authored Jun 23, 2024
1 parent 40db04a commit cf665a5
Showing 1 changed file with 61 additions and 35 deletions.
96 changes: 61 additions & 35 deletions Chronos/App/Tabs/Tokens/TokensTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,49 +74,75 @@ struct TokensTab: View {
}

var body: some View {
ZStack {
NavigationStack {
ScrollViewReader { _ in
List(tokenPairs) { tokenPair in
TokenRowView(tokenPair: tokenPair)
}
.listStyle(.plain)
NavigationStack {
ScrollViewReader { _ in
List(tokenPairs) { tokenPair in
TokenRowView(tokenPair: tokenPair)
}
.background(Color(red: 0.04, green: 0, blue: 0.11))
.navigationTitle("Tokens")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Menu {
ForEach(sortOptions, id: \.criteria) { option in
Button {
sortCriteria = option.criteria
} label: {
if sortCriteria == option.criteria {
Label(option.title, systemImage: "checkmark")
} else {
Text(option.title)
}
.listStyle(.plain)
}
.background(Color(red: 0.04, green: 0, blue: 0.11))
.navigationTitle("Tokens")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Menu {
ForEach(sortOptions, id: \.criteria) { option in
Button {
sortCriteria = option.criteria
} label: {
if sortCriteria == option.criteria {
Label(option.title, systemImage: "checkmark")
} else {
Text(option.title)
}
}
} label: {
Label("Sort Order", systemImage: "arrow.up.arrow.down")
}
.menuOrder(.fixed)
} label: {
Label("Sort Order", systemImage: "arrow.up.arrow.down")
}
.menuOrder(.fixed)

Button {
showTokenAddSheet.toggle()
} label: {
Image(systemName: "plus")
}
.sheet(isPresented: $showTokenAddSheet) {
AddTokenView()
.getSheetHeight()
.onPreferenceChange(SheetHeightPreferenceKey.self) { height in
self.detentHeight = height
Button {
showTokenAddSheet.toggle()
} label: {
Image(systemName: "plus")
}
}
.overlay(
Group {
if tokenPairs.isEmpty {
VStack {
Image(systemName: "qrcode.viewfinder")
.font(.system(size: 64))
.foregroundColor(.gray)
.opacity(0.8)

Text("No tokens found. Add one by pressing the + icon at the top right corner or the button below.")
.padding(.top, 4)
.multilineTextAlignment(.center)
.foregroundColor(.gray)
.opacity(0.8)

Button {
showTokenAddSheet.toggle()
} label: {
Text("Add Token")
.padding(.horizontal, 4)
.bold()
}
.presentationDetents([.height(self.detentHeight)])
.padding(.top, 4)
}
.padding(.horizontal, 24)
}
}
)
.sheet(isPresented: $showTokenAddSheet) {
AddTokenView()
.getSheetHeight()
.onPreferenceChange(SheetHeightPreferenceKey.self) { height in
self.detentHeight = height
}
.presentationDetents([.height(self.detentHeight)])
}
}
}
Expand Down

0 comments on commit cf665a5

Please sign in to comment.