field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

TeraContextPicker.swift (1354B)


      1 import SwiftUI
      2 
      3 struct TeraContextPicker: View {
      4   @ObservedObject var store: TeraTodayStore
      5   @Environment(\.dismiss) private var dismiss
      6 
      7   var body: some View {
      8     NavigationStack {
      9       List(store.contexts) { context in
     10         Button {
     11           store.selectContext(id: context.id)
     12           dismiss()
     13         } label: {
     14           HStack {
     15             VStack(alignment: .leading, spacing: 4) {
     16               Text(context.label)
     17                 .foregroundStyle(.primary)
     18               if let locality = context.locality {
     19                 Text(locality)
     20                   .font(.caption)
     21                   .foregroundStyle(.secondary)
     22               }
     23             }
     24             Spacer()
     25             if context.id == store.selectedContextID {
     26               Image(systemName: "checkmark")
     27                 .accessibilityHidden(true)
     28             }
     29           }
     30         }
     31         .accessibilityLabel(context.label)
     32         .accessibilityValue(context.id == store.selectedContextID ? "Selected" : "")
     33         .accessibilityIdentifier("radroots.context.\(context.id)")
     34       }
     35       .navigationTitle("Local network")
     36       .toolbar {
     37         ToolbarItem(placement: .confirmationAction) {
     38           Button("Done") { dismiss() }
     39         }
     40       }
     41     }
     42     .presentationDetents([.medium, .large])
     43     .accessibilityIdentifier("radroots.context.picker")
     44   }
     45 }