mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-09-15 08:50:57 +00:00
UI tweaks. (#701)
This commit is contained in:
parent
0e1e6813a1
commit
b308b10716
@ -8,7 +8,7 @@ struct ContentView: View {
|
|||||||
|
|
||||||
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
|
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
|
||||||
@State var showingCreation = false
|
@State var showingCreation = false
|
||||||
@State var runningSetup = true
|
@State var runningSetup = false
|
||||||
@State var showingAgentInfo = false
|
@State var showingAgentInfo = false
|
||||||
@State var activeSecret: AnySecret?
|
@State var activeSecret: AnySecret?
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
@ -11,7 +11,7 @@ struct CopyableView: View {
|
|||||||
@State private var interactionState: InteractionState = .normal
|
@State private var interactionState: InteractionState = .normal
|
||||||
|
|
||||||
var content: some View {
|
var content: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading, spacing: 15) {
|
||||||
HStack {
|
HStack {
|
||||||
image
|
image
|
||||||
.renderingMode(.template)
|
.renderingMode(.template)
|
||||||
@ -28,20 +28,19 @@ struct CopyableView: View {
|
|||||||
}
|
}
|
||||||
copyButton
|
copyButton
|
||||||
}
|
}
|
||||||
.foregroundColor(secondaryTextColor)
|
.foregroundColor(secondaryTextColor)
|
||||||
.transition(.opacity)
|
.transition(.opacity)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.padding(EdgeInsets(top: 20, leading: 20, bottom: 10, trailing: 20))
|
|
||||||
Divider()
|
Divider()
|
||||||
|
.ignoresSafeArea()
|
||||||
Text(text)
|
Text(text)
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.foregroundColor(primaryTextColor)
|
.foregroundColor(primaryTextColor)
|
||||||
.padding(EdgeInsets(top: 10, leading: 20, bottom: 20, trailing: 20))
|
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
.font(.system(.body, design: .monospaced))
|
.font(.system(.body, design: .monospaced))
|
||||||
}
|
}
|
||||||
|
.safeAreaPadding(20)
|
||||||
._background(interactionState: interactionState)
|
._background(interactionState: interactionState)
|
||||||
.frame(minWidth: 150, maxWidth: .infinity)
|
.frame(minWidth: 150, maxWidth: .infinity)
|
||||||
}
|
}
|
||||||
@ -53,12 +52,12 @@ struct CopyableView: View {
|
|||||||
interactionState = hovering ? .hovering : .normal
|
interactionState = hovering ? .hovering : .normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onDrag({
|
.draggable(text) {
|
||||||
NSItemProvider(item: NSData(data: text.data(using: .utf8)!), typeIdentifier: UTType.utf8PlainText.identifier)
|
content
|
||||||
}, preview: {
|
.lineLimit(3)
|
||||||
content
|
.frame(maxWidth: 300)
|
||||||
._background(interactionState: .dragging)
|
._background(interactionState: .dragging)
|
||||||
})
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
copy()
|
copy()
|
||||||
withAnimation {
|
withAnimation {
|
||||||
@ -159,7 +158,8 @@ fileprivate struct BackgroundViewModifier: ViewModifier {
|
|||||||
// Very thin opacity lets user hover anywhere over the view, glassEffect doesn't allow.
|
// Very thin opacity lets user hover anywhere over the view, glassEffect doesn't allow.
|
||||||
.background(.white.opacity(0.01), in: RoundedRectangle(cornerRadius: 15))
|
.background(.white.opacity(0.01), in: RoundedRectangle(cornerRadius: 15))
|
||||||
.glassEffect(.regular.tint(backgroundColor(interactionState: interactionState)), 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 {
|
} else {
|
||||||
content
|
content
|
||||||
.background(backgroundColor(interactionState: interactionState))
|
.background(backgroundColor(interactionState: interactionState))
|
||||||
@ -170,13 +170,25 @@ fileprivate struct BackgroundViewModifier: ViewModifier {
|
|||||||
|
|
||||||
func backgroundColor(interactionState: InteractionState) -> Color {
|
func backgroundColor(interactionState: InteractionState) -> Color {
|
||||||
guard appearsActive else { return Color.clear }
|
guard appearsActive else { return Color.clear }
|
||||||
switch interactionState {
|
if #available(macOS 26.0, *) {
|
||||||
case .normal:
|
let base = colorScheme == .dark ? Color(white: 0.2) : Color(white: 1)
|
||||||
return colorScheme == .dark ? Color(white: 0.2) : Color(white: 0.885)
|
switch interactionState {
|
||||||
case .hovering, .dragging:
|
case .normal:
|
||||||
return colorScheme == .dark ? Color(white: 0.275) : Color(white: 0.82)
|
return base
|
||||||
case .clicking:
|
case .hovering:
|
||||||
return .accentColor
|
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 {
|
#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()
|
.padding()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user