Put back UI tweaks

This commit is contained in:
Max Goedjen 2025-08-24 15:25:13 -07:00
parent be8ca815ce
commit 3e317b8e08
No known key found for this signature in database
2 changed files with 13 additions and 51 deletions

View File

@ -8,9 +8,7 @@ struct CopyableView: View {
var text: String var text: String
@State private var interactionState: InteractionState = .normal @State private var interactionState: InteractionState = .normal
@State private var expanded = false
@State private var showExpand = false
var content: some View { var content: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack { HStack {
@ -33,50 +31,17 @@ struct CopyableView: View {
} }
.padding(EdgeInsets(top: 20, leading: 20, bottom: 10, trailing: 20)) .padding(EdgeInsets(top: 20, leading: 20, bottom: 10, trailing: 20))
Divider() Divider()
textView Text(text)
.lineLimit(expanded ? nil : 5) .fixedSize(horizontal: false, vertical: true)
.overlay { .foregroundColor(primaryTextColor)
ViewThatFits { .padding(EdgeInsets(top: 10, leading: 20, bottom: 20, trailing: 20))
textView .multilineTextAlignment(.leading)
.hidden() .font(.system(.body, design: .monospaced))
.onAppear {
showExpand = false
}
Spacer()
.onAppear {
showExpand = true
}
}
}
.overlay(alignment: .bottomTrailing) {
if showExpand {
if #available(macOS 26.0, *) {
Button("Test", systemImage: "rectangle.expand.vertical") {
expanded = true
showExpand = false
}
.labelStyle(.iconOnly)
.buttonBorderShape(.circle)
.buttonStyle(.glass)
.padding()
} else {
}
}
}
} }
._background(interactionState: interactionState) ._background(interactionState: interactionState)
.frame(minWidth: 150, maxWidth: .infinity) .frame(minWidth: 150, maxWidth: .infinity)
} }
var textView: some View {
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))
}
var body: some View { var body: some View {
content content
.onHover { hovering in .onHover { hovering in
@ -84,10 +49,10 @@ struct CopyableView: View {
interactionState = hovering ? .hovering : .normal interactionState = hovering ? .hovering : .normal
} }
} }
.draggable(text, preview: { .onDrag({
content NSItemProvider(item: NSData(data: text.data(using: .utf8)!), typeIdentifier: UTType.utf8PlainText.identifier)
.lineLimit(3) }, preview: {
.frame(maxWidth: 300) content
._background(interactionState: .dragging) ._background(interactionState: .dragging)
}) })
.onTapGesture { .onTapGesture {
@ -205,7 +170,7 @@ struct CopyableView_Previews: PreviewProvider {
Group { Group {
CopyableView(title: "secret_detail_sha256_fingerprint_label", image: Image(systemName: "figure.wave"), text: "Hello world.") CopyableView(title: "secret_detail_sha256_fingerprint_label", image: Image(systemName: "figure.wave"), text: "Hello world.")
.padding() .padding()
CopyableView(title: "secret_detail_sha256_fingerprint_label", image: Image(systemName: "figure.wave"), text: "Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text.") CopyableView(title: "secret_detail_sha256_fingerprint_label", image: Image(systemName: "figure.wave"), text: "Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ")
.padding() .padding()
} }
} }

View File

@ -31,8 +31,7 @@ struct ToolbarButtonStyle: ButtonStyle {
configuration configuration
.label .label
.foregroundColor(.white) .foregroundColor(.white)
.padding(.vertical, 6) .padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 8))
.padding(.horizontal, 9)
.glassEffect(.regular.tint(glassTint), in: .capsule) .glassEffect(.regular.tint(glassTint), in: .capsule)
.onHover { hovering in .onHover { hovering in
self.hovering = hovering self.hovering = hovering
@ -42,8 +41,6 @@ struct ToolbarButtonStyle: ButtonStyle {
.label .label
.background(colorScheme == .light ? lightColor : darkColor) .background(colorScheme == .light ? lightColor : darkColor)
.foregroundColor(.white) .foregroundColor(.white)
.padding(.vertical, 6)
.padding(.horizontal, 8)
.clipShape(RoundedRectangle(cornerRadius: 5)) .clipShape(RoundedRectangle(cornerRadius: 5))
.overlay( .overlay(
RoundedRectangle(cornerRadius: 5) RoundedRectangle(cornerRadius: 5)