2022-11-29 11:46:02 +01:00
|
|
|
import Account
|
2023-01-17 11:36:01 +01:00
|
|
|
import AppAccount
|
2023-01-25 13:02:28 +01:00
|
|
|
import Conversations
|
2022-12-20 09:37:07 +01:00
|
|
|
import DesignSystem
|
2023-01-17 11:36:01 +01:00
|
|
|
import Env
|
2023-03-13 13:38:28 +01:00
|
|
|
import Explore
|
2023-02-21 07:23:42 +01:00
|
|
|
import LinkPresentation
|
2023-01-02 19:23:44 +01:00
|
|
|
import Lists
|
2023-02-21 07:23:42 +01:00
|
|
|
import Models
|
2023-01-17 11:36:01 +01:00
|
|
|
import Status
|
|
|
|
import SwiftUI
|
|
|
|
import Timeline
|
2022-11-29 11:46:02 +01:00
|
|
|
|
2023-01-17 07:39:13 +01:00
|
|
|
@MainActor
|
2022-11-29 11:46:02 +01:00
|
|
|
extension View {
|
2023-01-17 15:14:50 +01:00
|
|
|
func withAppRouter() -> some View {
|
2023-02-21 18:52:30 +01:00
|
|
|
navigationDestination(for: RouterDestination.self) { destination in
|
2022-11-29 11:46:02 +01:00
|
|
|
switch destination {
|
|
|
|
case let .accountDetail(id):
|
2022-11-29 12:18:06 +01:00
|
|
|
AccountDetailView(accountId: id)
|
2022-12-17 13:37:46 +01:00
|
|
|
case let .accountDetailWithAccount(account):
|
|
|
|
AccountDetailView(account: account)
|
2023-01-25 21:18:34 +01:00
|
|
|
case let .accountSettingsWithAccount(account, appAccount):
|
|
|
|
AccountSettingsView(account: account, appAccount: appAccount)
|
2022-11-29 11:46:02 +01:00
|
|
|
case let .statusDetail(id):
|
|
|
|
StatusDetailView(statusId: id)
|
2023-02-10 18:21:05 +01:00
|
|
|
case let .statusDetailWithStatus(status):
|
|
|
|
StatusDetailView(status: status)
|
2023-01-06 12:14:05 +01:00
|
|
|
case let .remoteStatusDetail(url):
|
|
|
|
StatusDetailView(remoteStatusURL: url)
|
2023-02-10 18:21:05 +01:00
|
|
|
case let .conversationDetail(conversation):
|
|
|
|
ConversationDetailView(conversation: conversation)
|
2022-12-21 20:26:38 +01:00
|
|
|
case let .hashTag(tag, accountId):
|
Accessibility tweaks + Notifications and Messages tab uplift (#1292)
* Improve StatusRowView accessibility actions
Previously, there was no way to interact with links and hashtags.
Now, these are added to the Actions rotor
* Hide `topPaddingView`s from accessibility
* Fix accessible header rendering in non-filterable TimelineViews
Previously, all navigation title views were assumed to be popup buttons.
Now, we only change the representation for timelines that are filterable.
* Combine tagHeaderView text elements
Previously, these were two separate items
* Prefer shorter Quote action label
* Improve accessibility of StatusEmbeddedView
Previously, this element would be three different ones, and include all the actions on the `StatusRowView` proper. Now, it presents as one element with no actions.
* Add haptics to StatusRowView accessibility actions
* Improve accessibility of ConversationsListRow
This commit adds:
- A combined representation of the component views
- “Unread” as the first part of the label (if this is the case)
- All relevant actions as custom actions
- Reply as magic tap
* Remove StatusRowView accessibilityActions if viewModel.showActions is false
* Hide media attachments from accessibility if the view is not focused
* Combine NotificationRowView accessibility elements; add user actions
Previously, there was no real way to interact with these notifications.
Now, the notifications that show the actions row have the appropriate StatusRowView-derived actions, and new followers notifications have more actions that let you see each user’s profile.
* Prefer @Environment’s `accessibilityEnabled` over `isVoiceOverRunning`
This way we can cater for Voice Control, Full Keyboard Access and Switch Control as well.
---------
Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
2023-03-24 07:52:29 +01:00
|
|
|
TimelineView(timeline: .constant(.hashtag(tag: tag, accountId: accountId)), scrollToTopSignal: .constant(0), canFilterTimeline: false)
|
2023-01-02 19:23:44 +01:00
|
|
|
case let .list(list):
|
Accessibility tweaks + Notifications and Messages tab uplift (#1292)
* Improve StatusRowView accessibility actions
Previously, there was no way to interact with links and hashtags.
Now, these are added to the Actions rotor
* Hide `topPaddingView`s from accessibility
* Fix accessible header rendering in non-filterable TimelineViews
Previously, all navigation title views were assumed to be popup buttons.
Now, we only change the representation for timelines that are filterable.
* Combine tagHeaderView text elements
Previously, these were two separate items
* Prefer shorter Quote action label
* Improve accessibility of StatusEmbeddedView
Previously, this element would be three different ones, and include all the actions on the `StatusRowView` proper. Now, it presents as one element with no actions.
* Add haptics to StatusRowView accessibility actions
* Improve accessibility of ConversationsListRow
This commit adds:
- A combined representation of the component views
- “Unread” as the first part of the label (if this is the case)
- All relevant actions as custom actions
- Reply as magic tap
* Remove StatusRowView accessibilityActions if viewModel.showActions is false
* Hide media attachments from accessibility if the view is not focused
* Combine NotificationRowView accessibility elements; add user actions
Previously, there was no real way to interact with these notifications.
Now, the notifications that show the actions row have the appropriate StatusRowView-derived actions, and new followers notifications have more actions that let you see each user’s profile.
* Prefer @Environment’s `accessibilityEnabled` over `isVoiceOverRunning`
This way we can cater for Voice Control, Full Keyboard Access and Switch Control as well.
---------
Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
2023-03-24 07:52:29 +01:00
|
|
|
TimelineView(timeline: .constant(.list(list: list)), scrollToTopSignal: .constant(0), canFilterTimeline: false)
|
2022-12-23 18:47:19 +01:00
|
|
|
case let .following(id):
|
2022-12-28 10:08:41 +01:00
|
|
|
AccountsListView(mode: .following(accountId: id))
|
2022-12-23 18:47:19 +01:00
|
|
|
case let .followers(id):
|
2022-12-24 13:41:25 +01:00
|
|
|
AccountsListView(mode: .followers(accountId: id))
|
2023-01-24 06:35:43 +01:00
|
|
|
case let .favoritedBy(id):
|
|
|
|
AccountsListView(mode: .favoritedBy(statusId: id))
|
2022-12-24 13:41:25 +01:00
|
|
|
case let .rebloggedBy(id):
|
|
|
|
AccountsListView(mode: .rebloggedBy(statusId: id))
|
2023-02-13 07:00:42 +01:00
|
|
|
case let .accountsList(accounts):
|
|
|
|
AccountsListView(mode: .accountsList(accounts: accounts))
|
2023-03-02 20:15:07 +01:00
|
|
|
case .trendingTimeline:
|
Accessibility tweaks + Notifications and Messages tab uplift (#1292)
* Improve StatusRowView accessibility actions
Previously, there was no way to interact with links and hashtags.
Now, these are added to the Actions rotor
* Hide `topPaddingView`s from accessibility
* Fix accessible header rendering in non-filterable TimelineViews
Previously, all navigation title views were assumed to be popup buttons.
Now, we only change the representation for timelines that are filterable.
* Combine tagHeaderView text elements
Previously, these were two separate items
* Prefer shorter Quote action label
* Improve accessibility of StatusEmbeddedView
Previously, this element would be three different ones, and include all the actions on the `StatusRowView` proper. Now, it presents as one element with no actions.
* Add haptics to StatusRowView accessibility actions
* Improve accessibility of ConversationsListRow
This commit adds:
- A combined representation of the component views
- “Unread” as the first part of the label (if this is the case)
- All relevant actions as custom actions
- Reply as magic tap
* Remove StatusRowView accessibilityActions if viewModel.showActions is false
* Hide media attachments from accessibility if the view is not focused
* Combine NotificationRowView accessibility elements; add user actions
Previously, there was no real way to interact with these notifications.
Now, the notifications that show the actions row have the appropriate StatusRowView-derived actions, and new followers notifications have more actions that let you see each user’s profile.
* Prefer @Environment’s `accessibilityEnabled` over `isVoiceOverRunning`
This way we can cater for Voice Control, Full Keyboard Access and Switch Control as well.
---------
Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
2023-03-24 07:52:29 +01:00
|
|
|
TimelineView(timeline: .constant(.trending), scrollToTopSignal: .constant(0), canFilterTimeline: false)
|
2023-03-02 20:15:07 +01:00
|
|
|
case let .tagsList(tags):
|
|
|
|
TagsListView(tags: tags)
|
2022-11-29 11:46:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-21 07:23:42 +01:00
|
|
|
|
2023-02-21 18:52:30 +01:00
|
|
|
func withSheetDestinations(sheetDestinations: Binding<SheetDestination?>) -> some View {
|
2023-01-17 11:36:01 +01:00
|
|
|
sheet(item: sheetDestinations) { destination in
|
2022-12-20 09:37:07 +01:00
|
|
|
switch destination {
|
2022-12-26 08:24:55 +01:00
|
|
|
case let .replyToStatusEditor(status):
|
|
|
|
StatusEditorView(mode: .replyTo(status: status))
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2023-01-05 12:21:54 +01:00
|
|
|
case let .newStatusEditor(visibility):
|
2023-01-17 15:14:50 +01:00
|
|
|
StatusEditorView(mode: .new(visibility: visibility))
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2022-12-26 08:24:55 +01:00
|
|
|
case let .editStatusEditor(status):
|
|
|
|
StatusEditorView(mode: .edit(status: status))
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2022-12-27 07:51:44 +01:00
|
|
|
case let .quoteStatusEditor(status):
|
|
|
|
StatusEditorView(mode: .quote(status: status))
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2023-01-04 18:37:58 +01:00
|
|
|
case let .mentionStatusEditor(account, visibility):
|
|
|
|
StatusEditorView(mode: .mention(account: account, visibility: visibility))
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2023-01-02 19:23:44 +01:00
|
|
|
case let .listEdit(list):
|
|
|
|
ListEditView(list: list)
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2023-01-02 19:23:44 +01:00
|
|
|
case let .listAddAccount(account):
|
|
|
|
ListAddAccountView(account: account)
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2023-01-06 12:14:05 +01:00
|
|
|
case .addAccount:
|
|
|
|
AddAccountView()
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2023-01-06 17:14:34 +01:00
|
|
|
case .addRemoteLocalTimeline:
|
|
|
|
AddRemoteTimelineView()
|
2023-01-17 07:39:13 +01:00
|
|
|
.withEnvironments()
|
2023-07-19 07:44:35 +02:00
|
|
|
case .addTagGroup:
|
2023-07-19 07:46:25 +02:00
|
|
|
AddTagGroupView()
|
|
|
|
.withEnvironments()
|
2023-01-19 21:19:19 +01:00
|
|
|
case let .statusEditHistory(status):
|
|
|
|
StatusEditHistoryView(statusId: status)
|
|
|
|
.withEnvironments()
|
2023-01-26 07:34:29 +01:00
|
|
|
case .settings:
|
|
|
|
SettingsTabs(popToRootTab: .constant(.settings))
|
|
|
|
.withEnvironments()
|
2023-01-26 09:02:57 +01:00
|
|
|
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
|
2023-01-27 12:18:17 +01:00
|
|
|
case .accountPushNotficationsSettings:
|
|
|
|
if let subscription = PushNotificationsService.shared.subscriptions.first(where: { $0.account.token == AppAccountsManager.shared.currentAccount.oauthToken }) {
|
|
|
|
PushNotificationsView(subscription: subscription)
|
|
|
|
.withEnvironments()
|
|
|
|
} else {
|
|
|
|
EmptyView()
|
|
|
|
}
|
2023-02-13 21:12:18 +01:00
|
|
|
case let .report(status):
|
|
|
|
ReportView(status: status)
|
|
|
|
.withEnvironments()
|
2023-02-19 15:29:07 +01:00
|
|
|
case let .shareImage(image, status):
|
|
|
|
ActivityView(image: image, status: status)
|
2022-12-20 09:37:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-21 07:23:42 +01:00
|
|
|
|
2023-01-17 07:39:13 +01:00
|
|
|
func withEnvironments() -> some View {
|
2023-01-17 11:36:01 +01:00
|
|
|
environmentObject(CurrentAccount.shared)
|
2023-01-17 07:39:13 +01:00
|
|
|
.environmentObject(UserPreferences.shared)
|
|
|
|
.environmentObject(CurrentInstance.shared)
|
|
|
|
.environmentObject(Theme.shared)
|
|
|
|
.environmentObject(AppAccountsManager.shared)
|
2023-01-27 12:18:17 +01:00
|
|
|
.environmentObject(PushNotificationsService.shared)
|
2023-02-17 13:30:45 +01:00
|
|
|
.environmentObject(AppAccountsManager.shared.currentClient)
|
2023-01-17 07:39:13 +01:00
|
|
|
}
|
2022-11-29 11:46:02 +01:00
|
|
|
}
|
2023-02-19 15:29:07 +01:00
|
|
|
|
|
|
|
struct ActivityView: UIViewControllerRepresentable {
|
|
|
|
let image: UIImage
|
|
|
|
let status: Status
|
2023-02-21 07:23:42 +01:00
|
|
|
|
2023-02-19 15:29:07 +01:00
|
|
|
class LinkDelegate: NSObject, UIActivityItemSource {
|
|
|
|
let image: UIImage
|
|
|
|
let status: Status
|
2023-02-21 07:23:42 +01:00
|
|
|
|
2023-02-19 15:29:07 +01:00
|
|
|
init(image: UIImage, status: Status) {
|
|
|
|
self.image = image
|
|
|
|
self.status = status
|
|
|
|
}
|
2023-02-21 07:23:42 +01:00
|
|
|
|
|
|
|
func activityViewControllerLinkMetadata(_: UIActivityViewController) -> LPLinkMetadata? {
|
2023-02-19 15:29:07 +01:00
|
|
|
let imageProvider = NSItemProvider(object: image)
|
|
|
|
let metadata = LPLinkMetadata()
|
|
|
|
metadata.imageProvider = imageProvider
|
|
|
|
metadata.title = status.reblog?.content.asRawText ?? status.content.asRawText
|
|
|
|
return metadata
|
|
|
|
}
|
2023-02-21 07:23:42 +01:00
|
|
|
|
|
|
|
func activityViewControllerPlaceholderItem(_: UIActivityViewController) -> Any {
|
2023-02-19 15:29:07 +01:00
|
|
|
image
|
|
|
|
}
|
2023-02-21 07:23:42 +01:00
|
|
|
|
|
|
|
func activityViewController(_: UIActivityViewController,
|
|
|
|
itemForActivityType _: UIActivity.ActivityType?) -> Any?
|
|
|
|
{
|
2023-02-19 15:29:07 +01:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
}
|
2023-02-21 07:23:42 +01:00
|
|
|
|
|
|
|
func makeUIViewController(context _: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {
|
2023-02-19 15:29:07 +01:00
|
|
|
return UIActivityViewController(activityItems: [image, LinkDelegate(image: image, status: status)],
|
|
|
|
applicationActivities: nil)
|
|
|
|
}
|
2023-02-21 07:23:42 +01:00
|
|
|
|
|
|
|
func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext<ActivityView>) {}
|
2023-02-19 15:29:07 +01:00
|
|
|
}
|