Skip to content

Commit

Permalink
✨ Add search bar to debug logger
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt authored and iujames committed Sep 17, 2024
1 parent 3943a4a commit b100618
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/AppcuesKit/Presentation/Debugger/Panel/DebugLogUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ internal enum DebugLogUI {
struct LoggerView: View {
@EnvironmentObject var logger: DebugLogger

@State private var searchText = ""

var filteredLog: [DebugLogger.Log] {
guard !searchText.isEmpty else { return logger.log }
return logger.log.filter { $0.message.localizedCaseInsensitiveContains(searchText) }
}

var body: some View {
List {
ForEach(logger.log.suffix(20).reversed()) { log in
ForEach(filteredLog.suffix(20).reversed()) { log in
NavigationLink(destination: DetailView(log: log)) {
VStack(alignment: .leading) {
Text("\(log.level.description): \(log.timestamp.description)")
Expand All @@ -28,6 +35,7 @@ internal enum DebugLogUI {
}
}
}
.searchableCompatible(text: $searchText)
.navigationBarTitle("", displayMode: .inline)
.navigationBarItems(trailing: ShareButton(text: logger.stringEncoded()))
}
Expand Down

0 comments on commit b100618

Please sign in to comment.