Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Examples/Gallery/Navigation/GlassNavigationBarExample.swift8// Module : Examples9// Repository : https://git.spboucher.ai/sp-glasskit10// Project Website : https://glass.spboucher.ai11// Created : 2026-12-0212// Last Modified : 2026-12-0213//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import SwiftUI42import SPGlassKit4344public struct GlassNavigationBarExample: GlassExample {45 public static let componentID = "glass-navigation-bar"46 @State private var notes = ["Quarterly review", "Trip to Lisbon", "A much longer note title that has to wrap or truncate gracefully"]47 @State private var isFlagged = false4849 public init() {}5051 public var body: some View {52 GlassNavigationBar(53 "Notes",54 subtitle: "\(notes.count) notes",55 titleDisplay: .large,56 leading: [57 GlassToolbarAction(id: "sort", title: "Sort", systemImage: "arrow.up.arrow.down") { notes.sort() },58 ],59 trailing: [60 GlassToolbarAction(id: "new", title: "New note", systemImage: "square.and.pencil", shortcut: KeyboardShortcut("n"), priority: .high) {61 notes.append("Untitled \(notes.count + 1)")62 },63 GlassToolbarAction(id: "shuffle", title: "Shuffle", systemImage: "shuffle") { notes.shuffle() },64 GlassToolbarAction(id: "clear", title: "Delete all", systemImage: "trash", role: .destructive, isEnabled: !notes.isEmpty, priority: .low) {65 notes.removeAll()66 },67 ]68 ) {69 List(notes, id: \.self) { note in70 NavigationLink(note, value: note)71 }72 .overlay {73 if notes.isEmpty { ContentUnavailableView("No notes", systemImage: "note.text") }74 }75 .navigationDestination(for: String.self) { note in76 ScrollView {77 Text(verbatim: note)78 .font(.title3)79 .frame(maxWidth: .infinity, alignment: .leading)80 .padding()81 }82 .glassNavigationBar(83 "Note",84 titleDisplay: .inline,85 trailing: [86 GlassToolbarAction(id: "flag", title: isFlagged ? "Remove flag" : "Flag", systemImage: isFlagged ? "flag.fill" : "flag") {87 isFlagged.toggle()88 },89 ]90 )91 }92 }93 }94}9596#Preview("GlassNavigationBar") { GlassNavigationBarExample().glassTheme(.ocean) }97