listless

A simple list app for Apple platforms
Log | Files | Refs | README | LICENSE

ItemListView+Toolbar.swift (1598B)


      1 import SwiftUI
      2 
      3 extension ItemListView {
      4     @ToolbarContentBuilder
      5     var platformToolbar: some ToolbarContent {
      6         ToolbarItem(placement: .automatic) {
      7             Spacer()
      8         }
      9 
     10         ToolbarItemGroup(placement: .automatic) {
     11             HStack {
     12                 if syncMonitor.hasDiagnosticsIssue {
     13                     Button {
     14                         NSApp.sendAction(
     15                             #selector(AppDelegate.handleShowSyncDiagnostics),
     16                             to: nil, from: nil
     17                         )
     18                     } label: {
     19                         Label("Sync Issues", systemImage: "exclamationmark.icloud")
     20                     }
     21                     .help("View sync diagnostics")
     22 
     23                     Divider()
     24                 }
     25 
     26                 Button {
     27                     createNewItem()
     28                 } label: {
     29                     Label("New Item", systemImage: "plus")
     30                 }
     31                 .help("Create a new item")
     32 
     33                 Button {
     34                     _ = deleteSelectedItem()
     35                 } label: {
     36                     Label("Delete", systemImage: "trash")
     37                 }
     38                 .disabled(!canDeleteSelectionFromList)
     39                 .help("Delete selected item")
     40 
     41                 Divider()
     42 
     43                 Button {
     44                     clearCompletedItems()
     45                 } label: {
     46                     Label("Clear Completed", systemImage: "tray")
     47                 }
     48                 .disabled(completedItems.isEmpty)
     49                 .help("Clear all completed items")
     50             }
     51         }
     52     }
     53 }