field_ios

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

TeraVisibilityControls.swift (1954B)


      1 import SwiftUI
      2 
      3 struct TeraAuthorVisibilityMenu: View {
      4   let author: String
      5   @EnvironmentObject private var visibility: TeraVisibilityStore
      6   var body: some View {
      7     Menu {
      8       Button("Mute author on this account") { Task { await visibility.change(author: author, to: .muted) } }
      9       Button("Block author on this account", role: .destructive) { Task { await visibility.change(author: author, to: .blocked) } }
     10     } label: {
     11       Label("Author visibility", systemImage: "eye.slash")
     12     }
     13     .disabled(visibility.isWorking)
     14     .accessibilityIdentifier("tera.visibility.author")
     15   }
     16 }
     17 
     18 struct TeraVisibilitySettingsSection: View {
     19   @EnvironmentObject private var visibility: TeraVisibilityStore
     20   var body: some View {
     21     Section {
     22       if let policy = visibility.policy {
     23         if policy.entries.isEmpty {
     24           Text("No authors are hidden on this account.")
     25         }
     26         ForEach(policy.entries) { entry in
     27           VStack(alignment: .leading) {
     28             Text(entry.author).font(.caption.monospaced()).textSelection(.enabled)
     29             Text(entry.visibility == .blocked ? "Blocked" : "Muted")
     30             Button("Restore author to local results") {
     31               Task { await visibility.change(author: entry.author, to: .visible) }
     32             }
     33             .disabled(visibility.isWorking)
     34           }
     35         }
     36       }
     37       if let message = visibility.message {
     38         Text(message)
     39       }
     40       Button("Reload visibility preferences") { Task { await visibility.load() } }
     41         .disabled(visibility.isWorking)
     42     } header: { Text("Hidden authors") }
     43     footer: { Text("Mute and block hide an author's posts, replies, profile and media across this account's local views. These preferences are not published. They do not remove remote copies or prevent others from posting. Restore is an explicit local action.") }
     44     .task { await visibility.load() }
     45     .accessibilityIdentifier("tera.visibility.settings")
     46   }
     47 }