From e75c264258bce6198cbec5c1a1237f560514880a Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 4 Oct 2024 10:37:10 +0200 Subject: [PATCH] Go multiline rather than truncate copiable Fixes #682 --- .../Library/Sources/AppUI/Views/Modules/IPView.swift | 6 +++--- .../Library/Sources/AppUI/Views/Theme/Theme+UI.swift | 4 +++- .../Library/Sources/AppUI/Views/Theme/Theme.swift | 9 +++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Passepartout/Library/Sources/AppUI/Views/Modules/IPView.swift b/Passepartout/Library/Sources/AppUI/Views/Modules/IPView.swift index 24b7a5fc..3ed8365e 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Modules/IPView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Modules/IPView.swift @@ -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() } diff --git a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift index 0a5245e9..bb44f878 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme+UI.swift @@ -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() } diff --git a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift index 9277c429..f8c8d2ce 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Theme/Theme.swift @@ -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)