Skip to content

Commit

Permalink
feat: Implemented search function (#51)
Browse files Browse the repository at this point in the history
* Added search

* bump version
  • Loading branch information
joeldavidw authored Jul 30, 2024
1 parent 5328387 commit 5eb9328
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
6 changes: 3 additions & 3 deletions Chronos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 9.0;
MARKETING_VERSION = 10.0;
PRODUCT_BUNDLE_IDENTIFIER = com.joeldavidw.ChronosDevDebug;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -910,7 +910,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 9.0;
MARKETING_VERSION = 10.0;
PRODUCT_BUNDLE_IDENTIFIER = com.joeldavidw.ChronosDevRelease;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1236,7 +1236,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 9.0;
MARKETING_VERSION = 10.0;
PRODUCT_BUNDLE_IDENTIFIER = com.joeldavidw.Chronos;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
50 changes: 24 additions & 26 deletions Chronos/App/MainAppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ struct MainAppView: View {
}

var body: some View {
ZStack {
if scenePhase != .active {
PrivacyView()
} else {
TabView(selection: $currentTab) {
TokensTab()
.tag("Tokens")
Expand All @@ -43,36 +45,32 @@ struct MainAppView: View {
Label("Settings", systemImage: "gearshape")
}
}
.onAppear {
if filteredVault.isEmpty {
stateService.resetAllStates()
loginStatus.loggedIn = false
}

if scenePhase != .active {
PrivacyView()
}
}
.onAppear {
if filteredVault.isEmpty {
stateService.resetAllStates()
loginStatus.loggedIn = false
}

if biometricsEnabled && statePasswordReminderEnabled {
if Date().timeIntervalSince1970 >= nextPasswordReminderTimestamp {
showPasswordReminder = true
if biometricsEnabled && statePasswordReminderEnabled {
if Date().timeIntervalSince1970 >= nextPasswordReminderTimestamp {
showPasswordReminder = true
}
}
}
}
.onChange(of: filteredVault) { _, newValue in
if newValue.isEmpty {
stateService.resetAllStates()
loginStatus.loggedIn = false
.onChange(of: filteredVault) { _, newValue in
if newValue.isEmpty {
stateService.resetAllStates()
loginStatus.loggedIn = false
}
}
}
.onChange(of: syncMonitor.syncStateSummary) { _, newValue in
if newValue == .succeeded {
iCloudSyncLastAttempt = Date().timeIntervalSince1970
.onChange(of: syncMonitor.syncStateSummary) { _, newValue in
if newValue == .succeeded {
iCloudSyncLastAttempt = Date().timeIntervalSince1970
}
}
.sheet(isPresented: $showPasswordReminder, content: {
PasswordReminderView()
})
}
.sheet(isPresented: $showPasswordReminder, content: {
PasswordReminderView()
})
}
}
16 changes: 11 additions & 5 deletions Chronos/App/Tabs/Tokens/TokensTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ struct TokensTab: View {
@State var detentHeight: CGFloat = 0
@State var sortCriteria: TokenSortOrder = .ISSUER_ASC

@State private var searchQuery = ""

let cryptoService = Container.shared.cryptoService()
let stateService = Container.shared.stateService()

Expand All @@ -53,6 +55,11 @@ struct TokensTab: View {
}
return TokenPair(id: encToken.id, token: decryptedToken, encToken: encToken)
}
.filter { tokenPair in
searchQuery.isEmpty ||
tokenPair.token.issuer.localizedCaseInsensitiveContains(searchQuery) ||
tokenPair.token.account.localizedCaseInsensitiveContains(searchQuery)
}
.sorted(by: { token1, token2 in
switch sortCriteria {
case .ISSUER_ASC:
Expand All @@ -71,15 +78,14 @@ struct TokensTab: View {

var body: some View {
NavigationStack {
ScrollViewReader { _ in
List(tokenPairs) { tokenPair in
TokenRowView(tokenPair: tokenPair)
}
.listStyle(.plain)
List(tokenPairs) { tokenPair in
TokenRowView(tokenPair: tokenPair)
}
.listStyle(.plain)
.background(Color(red: 0.04, green: 0, blue: 0.11))
.navigationTitle("Tokens")
.navigationBarTitleDisplayMode(.inline)
.searchable(text: $searchQuery, prompt: Text("Search tokens"))
.toolbar {
Menu {
ForEach(sortOptions, id: \.criteria) { option in
Expand Down

0 comments on commit 5eb9328

Please sign in to comment.