Go multiline rather than truncate copiable

Fixes #682
This commit is contained in:
Davide De Rosa 2024-10-04 10:37:10 +02:00
parent 71149e87d3
commit e75c264258
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
3 changed files with 15 additions and 4 deletions

View File

@ -130,7 +130,7 @@ private extension IPView {
func row(forRoute route: Route, removeAction: @escaping () -> Void) -> some View {
ThemeRemovableItemRow(isEditing: true) {
ThemeCopiableText(value: route.localizedDescription)
ThemeCopiableText(value: route.localizedDescription, isMultiLine: true)
} removeAction: {
removeAction()
}
@ -226,8 +226,8 @@ private extension IPView {
])
module.ipv6 = IPSettings(subnet: nil)
.including(routes: [
.init(defaultWithGateway: .ip("::4", .v6)),
.init(.init(rawValue: "::1/24"), nil)
.init(defaultWithGateway: .ip("fe80::1032:2a6b:fec:f49e", .v6)),
.init(.init(rawValue: "fe80:1032:2a6b:fec::/24"), .init(rawValue: "fe80:1032:2a6b:fec::1"))
])
return module.preview()
}

View File

@ -386,6 +386,8 @@ struct ThemeCopiableText: View {
let value: String
var isMultiLine = false
var body: some View {
HStack {
if let title {
@ -394,7 +396,7 @@ struct ThemeCopiableText: View {
}
Text(value)
.foregroundStyle(title == nil ? theme.titleColor : theme.valueColor)
.themeTruncating()
.themeMultiLine(isMultiLine)
if title == nil {
Spacer()
}

View File

@ -178,6 +178,15 @@ extension View {
modifier(ThemeManualInputModifier())
}
@ViewBuilder
public func themeMultiLine(_ isMultiLine: Bool) -> some View {
if isMultiLine {
multilineTextAlignment(.leading)
} else {
themeTruncating()
}
}
public func themeTruncating(_ mode: Text.TruncationMode = .middle) -> some View {
lineLimit(1)
.truncationMode(mode)