Skip to content

Commit bd8d425

Browse files
authored
Trucate download file name in the middle (home-assistant#3569)
<!-- Thank you for submitting a Pull Request and helping to improve Home Assistant. Please complete the following sections to help the processing and review of your changes. Please do not delete anything from this template. --> ## Summary <!-- Provide a brief summary of the changes you have made and most importantly what they aim to achieve --> ## Screenshots <!-- If this is a user-facing change not in the frontend, please include screenshots in light and dark mode. --> ## Link to pull request in Documentation repository <!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" --> Documentation: home-assistant/companion.home-assistant# ## Any other notes <!-- If there is any other information of note, like if this Pull Request is part of a bigger change, please include it here. -->
1 parent 08482dd commit bd8d425

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

HomeAssistant.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@
772772
429106872BA9D22500D452F9 /* AudioRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 429106862BA9D22500D452F9 /* AudioRecorder.swift */; };
773773
429106892BA9D5F700D452F9 /* AssistView+Build.swift in Sources */ = {isa = PBXBuildFile; fileRef = 429106882BA9D5F700D452F9 /* AssistView+Build.swift */; };
774774
4291068C2BA9D79500D452F9 /* AudioPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4291068B2BA9D79500D452F9 /* AudioPlayer.swift */; };
775+
4291CD962DBA70930024F891 /* ActivityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4291CD952DBA70930024F891 /* ActivityViewController.swift */; };
775776
429481E92DA93F4300A8B468 /* WebViewJavascriptCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 429481E82DA93F4300A8B468 /* WebViewJavascriptCommands.swift */; };
776777
429481EB2DA93FA000A8B468 /* WebViewJavascriptCommandsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 429481EA2DA93FA000A8B468 /* WebViewJavascriptCommandsTests.swift */; };
777778
429481ED2DA943E700A8B468 /* ListPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 429481EC2DA943E700A8B468 /* ListPicker.swift */; };
@@ -2208,6 +2209,7 @@
22082209
429106882BA9D5F700D452F9 /* AssistView+Build.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AssistView+Build.swift"; sourceTree = "<group>"; };
22092210
4291068B2BA9D79500D452F9 /* AudioPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioPlayer.swift; sourceTree = "<group>"; };
22102211
4291068D2BA9D93500D452F9 /* AssistService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssistService.swift; sourceTree = "<group>"; };
2212+
4291CD952DBA70930024F891 /* ActivityViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityViewController.swift; sourceTree = "<group>"; };
22112213
429481E82DA93F4300A8B468 /* WebViewJavascriptCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewJavascriptCommands.swift; sourceTree = "<group>"; };
22122214
429481EA2DA93FA000A8B468 /* WebViewJavascriptCommandsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewJavascriptCommandsTests.swift; sourceTree = "<group>"; };
22132215
429481EC2DA943E700A8B468 /* ListPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPicker.swift; sourceTree = "<group>"; };
@@ -4728,6 +4730,7 @@
47284730
42E6C0882CE4F4EC007CA622 /* DownloadManager */ = {
47294731
isa = PBXGroup;
47304732
children = (
4733+
4291CD952DBA70930024F891 /* ActivityViewController.swift */,
47314734
42E6C0892CE4F4FA007CA622 /* DownloadManagerView.swift */,
47324735
42E6C08B2CE4F7A8007CA622 /* DownloadManagerViewModel.swift */,
47334736
);
@@ -7683,6 +7686,7 @@
76837686
429821142CD0DD85005ECD39 /* BluetoothPermissionViewModel.swift in Sources */,
76847687
4251AA992C6B9D4C004CCC9D /* MagicItemCustomizationView.swift in Sources */,
76857688
1185DFB2271FF53800ED7D9A /* OnboardingAuthStepDuplicate.swift in Sources */,
7689+
4291CD962DBA70930024F891 /* ActivityViewController.swift in Sources */,
76867690
427FEE632D9EA1400047C00C /* OnboardingNavigationViewModel.swift in Sources */,
76877691
429481ED2DA943E700A8B468 /* ListPicker.swift in Sources */,
76887692
42F1DA5D2B4BF85F002729BC /* WindowScenesManager.swift in Sources */,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Foundation
2+
import SwiftUI
3+
4+
struct ShareWrapper: Identifiable {
5+
let id = UUID()
6+
let url: URL
7+
}
8+
9+
struct ActivityViewController: UIViewControllerRepresentable {
10+
let shareWrapper: ShareWrapper
11+
func makeUIViewController(context: Context) -> UIActivityViewController {
12+
UIActivityViewController(activityItems: [shareWrapper.url], applicationActivities: nil)
13+
}
14+
15+
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
16+
}

Sources/App/WebView/DownloadManager/DownloadManagerView.swift

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,19 @@ struct DownloadManagerView: View {
8585
} label: {
8686
Label(viewModel.fileName, systemSymbol: .folder)
8787
}
88+
.buttonStyle(.primaryButton)
8889
} else {
8990
ShareLink(viewModel.fileName, item: url)
91+
.lineLimit(1)
92+
.truncationMode(.middle)
9093
.padding()
9194
.foregroundStyle(.white)
9295
.background(Color.asset(Asset.Colors.haPrimary))
9396
.clipShape(RoundedRectangle(cornerRadius: CornerRadiusSizes.oneAndHalf))
9497
.padding()
95-
.onAppear(perform: {
98+
.onAppear {
9699
shareWrapper = .init(url: url)
97-
})
100+
}
98101
.sheet(item: $shareWrapper, onDismiss: {}, content: { data in
99102
ActivityViewController(shareWrapper: data)
100103
})
@@ -133,17 +136,3 @@ struct DownloadManagerView: View {
133136
Text("Hey there")
134137
}
135138
}
136-
137-
struct ShareWrapper: Identifiable {
138-
let id = UUID()
139-
let url: URL
140-
}
141-
142-
struct ActivityViewController: UIViewControllerRepresentable {
143-
let shareWrapper: ShareWrapper
144-
func makeUIViewController(context: Context) -> UIActivityViewController {
145-
UIActivityViewController(activityItems: [shareWrapper.url], applicationActivities: nil)
146-
}
147-
148-
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
149-
}

0 commit comments

Comments
 (0)