| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // LogView.swift
- // LoopFollow
- //
- // Created by Jonas Björkert on 2025-01-13.
- // Copyright © 2025 Jon Fawcett. All rights reserved.
- //
- import SwiftUI
- struct LogView: View {
- @ObservedObject var viewModel = LogViewModel()
- @Environment(\.presentationMode) var presentationMode
- var body: some View {
- NavigationView {
- VStack {
- Picker("Category", selection: $viewModel.selectedCategory) {
- Text("All").tag(LogManager.Category?.none)
- ForEach(LogManager.Category.allCases, id: \.self) { category in
- Text(category.rawValue).tag(LogManager.Category?.some(category))
- }
- }
- .pickerStyle(MenuPickerStyle())
- SearchBar(text: $viewModel.searchText)
- .padding([.leading, .trailing])
- ScrollView {
- LazyVStack(alignment: .leading, spacing: 2) {
- ForEach(viewModel.filteredLogEntries) { entry in
- Text(entry.text)
- .font(.system(size: 12, design: .monospaced))
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding(.vertical, 0)
- }
- }
- .padding(.horizontal)
- }
- }
- .navigationBarTitle("Today's Logs", displayMode: .inline)
- .toolbar {
- ToolbarItem(placement: .navigationBarTrailing) {
- Button("Done") {
- presentationMode.wrappedValue.dismiss()
- }
- }
- }
- .onAppear {
- viewModel.loadLogEntries()
- }
- }
- }
- }
|