mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-25 14:32:20 +01:00
b2f594f174
* 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>
158 lines
5.8 KiB
Swift
158 lines
5.8 KiB
Swift
import Account
|
|
import AppAccount
|
|
import Conversations
|
|
import DesignSystem
|
|
import Env
|
|
import Explore
|
|
import LinkPresentation
|
|
import Lists
|
|
import Models
|
|
import Status
|
|
import SwiftUI
|
|
import Timeline
|
|
|
|
@MainActor
|
|
extension View {
|
|
func withAppRouter() -> some View {
|
|
navigationDestination(for: RouterDestination.self) { destination in
|
|
switch destination {
|
|
case let .accountDetail(id):
|
|
AccountDetailView(accountId: id)
|
|
case let .accountDetailWithAccount(account):
|
|
AccountDetailView(account: account)
|
|
case let .accountSettingsWithAccount(account, appAccount):
|
|
AccountSettingsView(account: account, appAccount: appAccount)
|
|
case let .statusDetail(id):
|
|
StatusDetailView(statusId: id)
|
|
case let .statusDetailWithStatus(status):
|
|
StatusDetailView(status: status)
|
|
case let .remoteStatusDetail(url):
|
|
StatusDetailView(remoteStatusURL: url)
|
|
case let .conversationDetail(conversation):
|
|
ConversationDetailView(conversation: conversation)
|
|
case let .hashTag(tag, accountId):
|
|
TimelineView(timeline: .constant(.hashtag(tag: tag, accountId: accountId)), scrollToTopSignal: .constant(0), canFilterTimeline: false)
|
|
case let .list(list):
|
|
TimelineView(timeline: .constant(.list(list: list)), scrollToTopSignal: .constant(0), canFilterTimeline: false)
|
|
case let .following(id):
|
|
AccountsListView(mode: .following(accountId: id))
|
|
case let .followers(id):
|
|
AccountsListView(mode: .followers(accountId: id))
|
|
case let .favoritedBy(id):
|
|
AccountsListView(mode: .favoritedBy(statusId: id))
|
|
case let .rebloggedBy(id):
|
|
AccountsListView(mode: .rebloggedBy(statusId: id))
|
|
case let .accountsList(accounts):
|
|
AccountsListView(mode: .accountsList(accounts: accounts))
|
|
case .trendingTimeline:
|
|
TimelineView(timeline: .constant(.trending), scrollToTopSignal: .constant(0), canFilterTimeline: false)
|
|
case let .tagsList(tags):
|
|
TagsListView(tags: tags)
|
|
}
|
|
}
|
|
}
|
|
|
|
func withSheetDestinations(sheetDestinations: Binding<SheetDestination?>) -> some View {
|
|
sheet(item: sheetDestinations) { destination in
|
|
switch destination {
|
|
case let .replyToStatusEditor(status):
|
|
StatusEditorView(mode: .replyTo(status: status))
|
|
.withEnvironments()
|
|
case let .newStatusEditor(visibility):
|
|
StatusEditorView(mode: .new(visibility: visibility))
|
|
.withEnvironments()
|
|
case let .editStatusEditor(status):
|
|
StatusEditorView(mode: .edit(status: status))
|
|
.withEnvironments()
|
|
case let .quoteStatusEditor(status):
|
|
StatusEditorView(mode: .quote(status: status))
|
|
.withEnvironments()
|
|
case let .mentionStatusEditor(account, visibility):
|
|
StatusEditorView(mode: .mention(account: account, visibility: visibility))
|
|
.withEnvironments()
|
|
case let .listEdit(list):
|
|
ListEditView(list: list)
|
|
.withEnvironments()
|
|
case let .listAddAccount(account):
|
|
ListAddAccountView(account: account)
|
|
.withEnvironments()
|
|
case .addAccount:
|
|
AddAccountView()
|
|
.withEnvironments()
|
|
case .addRemoteLocalTimeline:
|
|
AddRemoteTimelineView()
|
|
.withEnvironments()
|
|
case let .statusEditHistory(status):
|
|
StatusEditHistoryView(statusId: status)
|
|
.withEnvironments()
|
|
case .settings:
|
|
SettingsTabs(popToRootTab: .constant(.settings))
|
|
.withEnvironments()
|
|
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
|
|
case .accountPushNotficationsSettings:
|
|
if let subscription = PushNotificationsService.shared.subscriptions.first(where: { $0.account.token == AppAccountsManager.shared.currentAccount.oauthToken }) {
|
|
PushNotificationsView(subscription: subscription)
|
|
.withEnvironments()
|
|
} else {
|
|
EmptyView()
|
|
}
|
|
case let .report(status):
|
|
ReportView(status: status)
|
|
.withEnvironments()
|
|
case let .shareImage(image, status):
|
|
ActivityView(image: image, status: status)
|
|
}
|
|
}
|
|
}
|
|
|
|
func withEnvironments() -> some View {
|
|
environmentObject(CurrentAccount.shared)
|
|
.environmentObject(UserPreferences.shared)
|
|
.environmentObject(CurrentInstance.shared)
|
|
.environmentObject(Theme.shared)
|
|
.environmentObject(AppAccountsManager.shared)
|
|
.environmentObject(PushNotificationsService.shared)
|
|
.environmentObject(AppAccountsManager.shared.currentClient)
|
|
}
|
|
}
|
|
|
|
struct ActivityView: UIViewControllerRepresentable {
|
|
let image: UIImage
|
|
let status: Status
|
|
|
|
class LinkDelegate: NSObject, UIActivityItemSource {
|
|
let image: UIImage
|
|
let status: Status
|
|
|
|
init(image: UIImage, status: Status) {
|
|
self.image = image
|
|
self.status = status
|
|
}
|
|
|
|
func activityViewControllerLinkMetadata(_: UIActivityViewController) -> LPLinkMetadata? {
|
|
let imageProvider = NSItemProvider(object: image)
|
|
let metadata = LPLinkMetadata()
|
|
metadata.imageProvider = imageProvider
|
|
metadata.title = status.reblog?.content.asRawText ?? status.content.asRawText
|
|
return metadata
|
|
}
|
|
|
|
func activityViewControllerPlaceholderItem(_: UIActivityViewController) -> Any {
|
|
image
|
|
}
|
|
|
|
func activityViewController(_: UIActivityViewController,
|
|
itemForActivityType _: UIActivity.ActivityType?) -> Any?
|
|
{
|
|
nil
|
|
}
|
|
}
|
|
|
|
func makeUIViewController(context _: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {
|
|
return UIActivityViewController(activityItems: [image, LinkDelegate(image: image, status: status)],
|
|
applicationActivities: nil)
|
|
}
|
|
|
|
func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext<ActivityView>) {}
|
|
}
|