From b308b10716fc09a4f228249fd930fd05c25957d2 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sat, 13 Sep 2025 17:03:20 -0700 Subject: [PATCH] UI tweaks. (#701) --- .../Secretive/Views/Views/ContentView.swift | 2 +- .../Secretive/Views/Views/CopyableView.swift | 55 ++++++++++++------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Sources/Secretive/Views/Views/ContentView.swift b/Sources/Secretive/Views/Views/ContentView.swift index 822c318..76c9226 100644 --- a/Sources/Secretive/Views/Views/ContentView.swift +++ b/Sources/Secretive/Views/Views/ContentView.swift @@ -8,7 +8,7 @@ struct ContentView: View { @AppStorage("defaultsHasRunSetup") var hasRunSetup = false @State var showingCreation = false - @State var runningSetup = true + @State var runningSetup = false @State var showingAgentInfo = false @State var activeSecret: AnySecret? @Environment(\.colorScheme) var colorScheme diff --git a/Sources/Secretive/Views/Views/CopyableView.swift b/Sources/Secretive/Views/Views/CopyableView.swift index 69ad500..e56ab20 100644 --- a/Sources/Secretive/Views/Views/CopyableView.swift +++ b/Sources/Secretive/Views/Views/CopyableView.swift @@ -11,7 +11,7 @@ struct CopyableView: View { @State private var interactionState: InteractionState = .normal var content: some View { - VStack(alignment: .leading) { + VStack(alignment: .leading, spacing: 15) { HStack { image .renderingMode(.template) @@ -28,20 +28,19 @@ struct CopyableView: View { } copyButton } - .foregroundColor(secondaryTextColor) - .transition(.opacity) + .foregroundColor(secondaryTextColor) + .transition(.opacity) } - } - .padding(EdgeInsets(top: 20, leading: 20, bottom: 10, trailing: 20)) Divider() + .ignoresSafeArea() Text(text) .fixedSize(horizontal: false, vertical: true) .foregroundColor(primaryTextColor) - .padding(EdgeInsets(top: 10, leading: 20, bottom: 20, trailing: 20)) .multilineTextAlignment(.leading) .font(.system(.body, design: .monospaced)) } + .safeAreaPadding(20) ._background(interactionState: interactionState) .frame(minWidth: 150, maxWidth: .infinity) } @@ -53,12 +52,12 @@ struct CopyableView: View { interactionState = hovering ? .hovering : .normal } } - .onDrag({ - NSItemProvider(item: NSData(data: text.data(using: .utf8)!), typeIdentifier: UTType.utf8PlainText.identifier) - }, preview: { - content + .draggable(text) { + content + .lineLimit(3) + .frame(maxWidth: 300) ._background(interactionState: .dragging) - }) + } .onTapGesture { copy() withAnimation { @@ -159,7 +158,8 @@ fileprivate struct BackgroundViewModifier: ViewModifier { // Very thin opacity lets user hover anywhere over the view, glassEffect doesn't allow. .background(.white.opacity(0.01), in: RoundedRectangle(cornerRadius: 15)) .glassEffect(.regular.tint(backgroundColor(interactionState: interactionState)), in: RoundedRectangle(cornerRadius: 15)) - + .mask(RoundedRectangle(cornerRadius: 15)) + .shadow(color: .black.opacity(0.1), radius: 5) } else { content .background(backgroundColor(interactionState: interactionState)) @@ -170,13 +170,25 @@ fileprivate struct BackgroundViewModifier: ViewModifier { func backgroundColor(interactionState: InteractionState) -> Color { guard appearsActive else { return Color.clear } - switch interactionState { - case .normal: - return colorScheme == .dark ? Color(white: 0.2) : Color(white: 0.885) - case .hovering, .dragging: - return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.82) - case .clicking: - return .accentColor + if #available(macOS 26.0, *) { + let base = colorScheme == .dark ? Color(white: 0.2) : Color(white: 1) + switch interactionState { + case .normal: + return base + case .hovering: + return base.mix(with: .accentColor, by: colorScheme == .dark ? 0.2 : 0.1) + case .clicking, .dragging: + return base.mix(with: .accentColor, by: 0.8) + } + } else { + switch interactionState { + case .normal: + return colorScheme == .dark ? Color(white: 0.2) : Color(white: 0.885) + case .hovering: + return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.82) + case .clicking, .dragging: + return .accentColor + } } } @@ -184,7 +196,10 @@ fileprivate struct BackgroundViewModifier: ViewModifier { } #Preview { - CopyableView(title: .secretDetailSha256FingerprintLabel, image: Image(systemName: "figure.wave"), text: "Hello world.") + VStack { + CopyableView(title: .secretDetailSha256FingerprintLabel, image: Image(systemName: "figure.wave"), text: "Hello world.") + CopyableView(title: .secretDetailSha256FingerprintLabel, image: Image(systemName: "figure.wave"), text: "Hello world.") + } .padding() }