Skip to content

Commit

Permalink
Auto open share sheet after download (#3295)
Browse files Browse the repository at this point in the history
<!-- 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. -->
  • Loading branch information
bgoncal authored Dec 23, 2024
1 parent 4d5431b commit 6d641e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Sources/App/WebView/DownloadManager/DownloadManagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ struct DownloadManagerView: View {
@Environment(\.dismiss) private var dismiss

@StateObject var viewModel: DownloadManagerViewModel
@State private var shareWrapper: ShareWrapper?

init(viewModel: DownloadManagerViewModel) {
self._viewModel = .init(wrappedValue: viewModel)
Expand Down Expand Up @@ -91,6 +92,12 @@ struct DownloadManagerView: View {
.background(Color.asset(Asset.Colors.haPrimary))
.clipShape(RoundedRectangle(cornerRadius: 12))
.padding()
.onAppear(perform: {
shareWrapper = .init(url: url)
})
.sheet(item: $shareWrapper, onDismiss: {}, content: { data in
ActivityViewController(shareWrapper: data)
})
}
}
}
Expand Down Expand Up @@ -126,3 +133,17 @@ struct DownloadManagerView: View {
Text("Hey there")
}
}

struct ShareWrapper: Identifiable {
let id = UUID()
let url: URL
}

struct ActivityViewController: UIViewControllerRepresentable {
let shareWrapper: ShareWrapper
func makeUIViewController(context: Context) -> UIActivityViewController {
UIActivityViewController(activityItems: [shareWrapper.url], applicationActivities: nil)
}

func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
}
2 changes: 1 addition & 1 deletion Sources/Shared/Resources/Swiftgen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public enum L10n {
}
public enum Watch {
public enum MicButton {
/// Tap to
/// Tap to
public static var title: String { return L10n.tr("Localizable", "assist.watch.mic_button.title") }
}
public enum NotReachable {
Expand Down

0 comments on commit 6d641e8

Please sign in to comment.