From 212af591f195f4b04e96ad6b90cf61f357a4901d Mon Sep 17 00:00:00 2001 From: david-swift Date: Mon, 6 May 2024 16:18:49 +0200 Subject: [PATCH] Polish demo app --- Tests/AlertDialogDemo.swift | 1 + Tests/Demo.swift | 52 +++++++++++++++++----------------- Tests/DialogDemo.swift | 1 + Tests/FormDemo.swift | 1 + Tests/IdleDemo.swift | 6 ++-- Tests/NavigationViewDemo.swift | 1 + Tests/Page.swift | 2 +- Tests/PopoverDemo.swift | 1 + Tests/ToastDemo.swift | 1 + Tests/ToolbarDemo.swift | 2 ++ Tests/ViewSwitcherDemo.swift | 1 + 11 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Tests/AlertDialogDemo.swift b/Tests/AlertDialogDemo.swift index 5a95b8d..98aff45 100644 --- a/Tests/AlertDialogDemo.swift +++ b/Tests/AlertDialogDemo.swift @@ -20,6 +20,7 @@ struct AlertDialogDemo: View { dialog = true } .style("pill") + .style("suggested-action") .frame(maxWidth: 100) .padding() } diff --git a/Tests/Demo.swift b/Tests/Demo.swift index d8e5bb0..9388e82 100644 --- a/Tests/Demo.swift +++ b/Tests/Demo.swift @@ -100,35 +100,35 @@ struct Demo: App { } } } content: { - StatusPage( - selection.label, - icon: selection.icon, - description: selection.description - ) { selection.view(app: app, window: window, toast: toast, pictureURL: pictureURL) } - .topToolbar { - HeaderBar { - Toggle(icon: .default(icon: .sidebarShow), isOn: $sidebarVisible) - .tooltip("Toggle Sidebar") - } end: { - if sidebarVisible { - Text("") - .transition(.crossfade) - } else { - menu - .transition(.crossfade) - } - } - .headerBarTitle { - if sidebarVisible { - Text("") - .transition(.crossfade) - } else { - WindowTitle(subtitle: "Demo", title: selection.label) - .transition(.crossfade) + ViewStack(element: selection) { selection in + StatusPage( + selection.label, + icon: selection.icon, + description: selection.description + ) { selection.view(app: app, window: window, toast: toast, pictureURL: pictureURL) } + .topToolbar { + HeaderBar { + Toggle(icon: .default(icon: .sidebarShow), isOn: $sidebarVisible) + .tooltip("Toggle Sidebar") + } end: { + if sidebarVisible { + Text("").transition(.crossfade) + } else { + menu.transition(.crossfade) + } + } + .headerBarTitle { + if sidebarVisible { + Text("") + .transition(.crossfade) + } else { + WindowTitle(subtitle: "Demo", title: selection.label) + .transition(.crossfade) + } } } + .toast("This is a toast!", signal: toast) } - .toast("This is a toast!", signal: toast) } .aboutDialog( visible: $about, diff --git a/Tests/DialogDemo.swift b/Tests/DialogDemo.swift index 5b436e5..fd9d452 100644 --- a/Tests/DialogDemo.swift +++ b/Tests/DialogDemo.swift @@ -22,6 +22,7 @@ struct DialogDemo: View { dialog = true } .style("pill") + .style("suggested-action") .frame(maxWidth: 100) .padding() } diff --git a/Tests/FormDemo.swift b/Tests/FormDemo.swift index b60472c..ca2cac4 100644 --- a/Tests/FormDemo.swift +++ b/Tests/FormDemo.swift @@ -19,6 +19,7 @@ struct FormDemo: View { app.showWindow("form-demo") } .style("suggested-action") + .style("pill") .frame(maxWidth: 100) } } diff --git a/Tests/IdleDemo.swift b/Tests/IdleDemo.swift index f7fb500..74fa02c 100644 --- a/Tests/IdleDemo.swift +++ b/Tests/IdleDemo.swift @@ -23,11 +23,9 @@ struct IdleDemo: View { .valign(.center) .frame(maxWidth: maxWidth) Button("Play") { + activeProcess = true + progress = 0 Task { - Idle { - activeProcess = true - progress = 0 - } Idle(delay: .seconds(delayFactor / max)) { progress += 1 let done = progress == max diff --git a/Tests/NavigationViewDemo.swift b/Tests/NavigationViewDemo.swift index d0e32ac..fc7aa58 100644 --- a/Tests/NavigationViewDemo.swift +++ b/Tests/NavigationViewDemo.swift @@ -19,6 +19,7 @@ struct NavigationViewDemo: View { app.showWindow("navigation") } .style("suggested-action") + .style("pill") .frame(maxWidth: 100) .padding() } diff --git a/Tests/Page.swift b/Tests/Page.swift index be63880..04d5a7f 100644 --- a/Tests/Page.swift +++ b/Tests/Page.swift @@ -10,7 +10,7 @@ import Adwaita import Foundation -enum Page: String, Identifiable, CaseIterable, Codable { +enum Page: String, Identifiable, CaseIterable, Codable, CustomStringConvertible { case welcome case counter diff --git a/Tests/PopoverDemo.swift b/Tests/PopoverDemo.swift index 732d51a..7f6fa1d 100644 --- a/Tests/PopoverDemo.swift +++ b/Tests/PopoverDemo.swift @@ -19,6 +19,7 @@ struct PopoverDemo: View { visible = true } .style("suggested-action") + .style("pill") .frame(maxWidth: 100) .popover(visible: $visible) { CounterDemo() diff --git a/Tests/ToastDemo.swift b/Tests/ToastDemo.swift index d811b2f..2967b65 100644 --- a/Tests/ToastDemo.swift +++ b/Tests/ToastDemo.swift @@ -19,6 +19,7 @@ struct ToastDemo: View { toast.signal() } .style("suggested-action") + .style("pill") .frame(maxWidth: 100) } } diff --git a/Tests/ToolbarDemo.swift b/Tests/ToolbarDemo.swift index 5b1e014..b1c5acd 100644 --- a/Tests/ToolbarDemo.swift +++ b/Tests/ToolbarDemo.swift @@ -19,6 +19,7 @@ struct ToolbarDemo: View { app.showWindow("toolbar-demo") } .style("suggested-action") + .style("pill") .frame(maxWidth: 100) } } @@ -34,6 +35,7 @@ struct ToolbarDemo: View { visible.toggle() } .style("suggested-action") + .style("pill") .frame(maxWidth: 100) .padding(15) } diff --git a/Tests/ViewSwitcherDemo.swift b/Tests/ViewSwitcherDemo.swift index a8b0b08..bb083c6 100644 --- a/Tests/ViewSwitcherDemo.swift +++ b/Tests/ViewSwitcherDemo.swift @@ -19,6 +19,7 @@ struct ViewSwitcherDemo: View { app.showWindow("switcher-demo") } .style("suggested-action") + .style("pill") .frame(maxWidth: 100) } }