Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add share note functionality #1477

Merged
merged 8 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changed "Name" to "Display Name" on the Edit Profile View.
- Fixed side menu accessibility issues.
- Updated the copy on the 3 dots note menu.
- Added functionality to share notes link through the 3 dots note menu.

### Internal Changes
- Included the npub in the properties list sent to analytics.
Expand Down
11 changes: 10 additions & 1 deletion Nos/Views/Components/ActivityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ struct ActivityViewController: UIViewControllerRepresentable {

var activityItems: [Any]
var applicationActivities: [UIActivity]?
/// The completion handler to execute after the activity view controller is dismissed.
var completion: (() -> Void)?

func makeUIViewController(
context: UIViewControllerRepresentableContext<ActivityViewController>
) -> UIActivityViewController {
UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities)
let controller = UIActivityViewController(
activityItems: activityItems,
applicationActivities: applicationActivities
)
controller.completionWithItemsHandler = { _, _, _, _ in
completion?()
}
return controller
}

func updateUIViewController(
Expand Down
5 changes: 5 additions & 0 deletions Nos/Views/Components/Button/NoteOptionsButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct NoteOptionsButton: View {
copyMessageIdentifier()
}
Button(String(localized: .localizable.shareNote)) {
showingShare = true
analytics.sharedNoteLink()
}
if !note.isStub {
Expand Down Expand Up @@ -82,6 +83,10 @@ struct NoteOptionsButton: View {
}
}
.sheet(isPresented: $showingShare) {
let url = note.webLink
ActivityViewController(activityItems: [url]) {
showingShare = false
}
}
}
}
Expand Down
Loading