Skip to content

Commit 6d641e8

Browse files
authored
Auto open share sheet after download (#3295)
<!-- 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 4d5431b commit 6d641e8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Sources/App/WebView/DownloadManager/DownloadManagerView.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct DownloadManagerView: View {
66
@Environment(\.dismiss) private var dismiss
77

88
@StateObject var viewModel: DownloadManagerViewModel
9+
@State private var shareWrapper: ShareWrapper?
910

1011
init(viewModel: DownloadManagerViewModel) {
1112
self._viewModel = .init(wrappedValue: viewModel)
@@ -91,6 +92,12 @@ struct DownloadManagerView: View {
9192
.background(Color.asset(Asset.Colors.haPrimary))
9293
.clipShape(RoundedRectangle(cornerRadius: 12))
9394
.padding()
95+
.onAppear(perform: {
96+
shareWrapper = .init(url: url)
97+
})
98+
.sheet(item: $shareWrapper, onDismiss: {}, content: { data in
99+
ActivityViewController(shareWrapper: data)
100+
})
94101
}
95102
}
96103
}
@@ -126,3 +133,17 @@ struct DownloadManagerView: View {
126133
Text("Hey there")
127134
}
128135
}
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+
}

Sources/Shared/Resources/Swiftgen/Strings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public enum L10n {
465465
}
466466
public enum Watch {
467467
public enum MicButton {
468-
/// Tap to
468+
/// Tap to
469469
public static var title: String { return L10n.tr("Localizable", "assist.watch.mic_button.title") }
470470
}
471471
public enum NotReachable {

0 commit comments

Comments
 (0)