More UI tweaks and fixes (#697)

* Integrations to window

* Cleanup of presenting.

* Older name for copy

* For copyable view too
This commit is contained in:
Max Goedjen
2025-09-13 01:16:23 -07:00
committed by GitHub
parent 21fc834fd9
commit 67ec4fee12
11 changed files with 157 additions and 99 deletions

View File

@@ -32,7 +32,7 @@ struct ConfigurationItemView<Content: View>: View {
Spacer()
switch action {
case .copy(let string):
Button(.copyableClickToCopyButton, systemImage: "document.on.document") {
Button(.copyableClickToCopyButton, systemImage: "doc.on.doc") {
NSPasteboard.general.declareTypes([.string], owner: nil)
NSPasteboard.general.setString(string, forType: .string)
}

View File

@@ -21,46 +21,18 @@ struct IntegrationsView: View {
}
}
} detail: {
IntegrationsDetailView(selectedInstruction: $selectedInstruction)
.fauxToolbar {
Button(.setupDoneButton) {
dismiss()
}
.normalButton()
}
IntegrationsDetailView(selectedInstruction: $selectedInstruction)
}
.toolbar {
Button(.setupDoneButton) {
dismiss()
}
}
.hiddenToolbar()
.windowBackgroundStyle(.thinMaterial)
.onAppear {
selectedInstruction = instructions.gettingStarted
}
}
}
extension View {
func fauxToolbar<Content: View>(content: () -> Content) -> some View {
modifier(FauxToolbarModifier(toolbarContent: content()))
}
}
struct FauxToolbarModifier<ToolbarContent: View>: ViewModifier {
var toolbarContent: ToolbarContent
func body(content: Content) -> some View {
VStack(alignment: .leading, spacing: 0) {
content
Divider()
HStack {
Spacer()
toolbarContent
.padding(.top, 8)
.padding(.trailing, 16)
.padding(.bottom, 16)
}
}
.frame(minWidth: 400, minHeight: 400)
}

View File

@@ -0,0 +1,47 @@
import SwiftUI
struct WindowBackgroundStyleModifier: ViewModifier {
let shapeStyle: any ShapeStyle
func body(content: Content) -> some View {
if #available(macOS 15.0, *) {
content
.containerBackground(
shapeStyle, for: .window
)
} else {
content
}
}
}
extension View {
func windowBackgroundStyle(_ style: some ShapeStyle) -> some View {
modifier(WindowBackgroundStyleModifier(shapeStyle: style))
}
}
struct HiddenToolbarModifier: ViewModifier {
func body(content: Content) -> some View {
if #available(macOS 15.0, *) {
content
.toolbarBackgroundVisibility(.hidden, for: .automatic)
} else {
content
}
}
}
extension View {
func hiddenToolbar() -> some View {
modifier(HiddenToolbarModifier())
}
}

View File

@@ -6,9 +6,9 @@ import Brief
struct ContentView: View {
@Binding var showingCreation: Bool
@Binding var runningSetup: Bool
@Binding var hasRunSetup: Bool
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
@State var showingCreation = false
@State var runningSetup = true
@State var showingAgentInfo = false
@State var activeSecret: AnySecret?
@Environment(\.colorScheme) var colorScheme
@@ -35,6 +35,23 @@ struct ContentView: View {
toolbarItem(appPathNoticeView, id: "appPath")
toolbarItem(newItemView, id: "new")
}
.onAppear {
if !hasRunSetup {
runningSetup = true
}
}
.focusedSceneValue(\.showCreateSecret, .init(isEnabled: !runningSetup) {
showingCreation = true
})
.sheet(isPresented: $showingCreation) {
if let modifiable = storeList.modifiableStore {
CreateSecretView(store: modifiable) { created in
if let created {
activeSecret = created
}
}
}
}
.sheet(isPresented: $runningSetup) {
SetupView(setupComplete: $hasRunSetup)
}
@@ -114,15 +131,6 @@ extension ContentView {
showingCreation = true
}
.menuButton()
.sheet(isPresented: $showingCreation) {
if let modifiable = storeList.modifiableStore {
CreateSecretView(store: modifiable) { created in
if let created {
activeSecret = created
}
}
}
}
}
}

View File

@@ -79,7 +79,7 @@ struct CopyableView: View {
var copyButton: some View {
switch interactionState {
case .hovering:
Button(.copyableClickToCopyButton, systemImage: "document.on.document") {
Button(.copyableClickToCopyButton, systemImage: "doc.on.doc") {
withAnimation {
// Button will eat the click, so we set interaction state manually.
interactionState = .clicking