UI tweaks. (#701)

This commit is contained in:
Max Goedjen 2025-09-13 17:03:20 -07:00 committed by GitHub
parent 0e1e6813a1
commit b308b10716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 21 deletions

View File

@ -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

View File

@ -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)
@ -31,17 +31,16 @@ struct CopyableView: View {
.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: {
.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,21 +170,36 @@ fileprivate struct BackgroundViewModifier: ViewModifier {
func backgroundColor(interactionState: InteractionState) -> Color {
guard appearsActive else { return Color.clear }
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, .dragging:
case .hovering:
return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.82)
case .clicking:
case .clicking, .dragging:
return .accentColor
}
}
}
}
#Preview {
VStack {
CopyableView(title: .secretDetailSha256FingerprintLabel, image: Image(systemName: "figure.wave"), text: "Hello world.")
CopyableView(title: .secretDetailSha256FingerprintLabel, image: Image(systemName: "figure.wave"), text: "Hello world.")
}
.padding()
}