From b1006185a0c44c76f9294b39a0be300299fdd567 Mon Sep 17 00:00:00 2001 From: Matt Hayashida Date: Thu, 14 Mar 2024 11:02:45 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20search=20bar=20to=20debug=20l?= =?UTF-8?q?ogger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Debugger/Panel/DebugLogUI.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/AppcuesKit/Presentation/Debugger/Panel/DebugLogUI.swift b/Sources/AppcuesKit/Presentation/Debugger/Panel/DebugLogUI.swift index ef81a34c7..35867629e 100644 --- a/Sources/AppcuesKit/Presentation/Debugger/Panel/DebugLogUI.swift +++ b/Sources/AppcuesKit/Presentation/Debugger/Panel/DebugLogUI.swift @@ -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)") @@ -28,6 +35,7 @@ internal enum DebugLogUI { } } } + .searchableCompatible(text: $searchText) .navigationBarTitle("", displayMode: .inline) .navigationBarItems(trailing: ShareButton(text: logger.stringEncoded())) }