IceCubesApp/Packages/Account/Sources/Account/AccountDetailView.swift

397 lines
13 KiB
Swift
Raw Normal View History

2023-01-17 10:36:01 +00:00
import DesignSystem
import EmojiText
import Env
2022-11-29 11:18:06 +00:00
import Models
import Network
2024-01-06 18:27:26 +00:00
import StatusKit
2023-01-17 10:36:01 +00:00
import SwiftUI
2022-11-29 11:18:06 +00:00
2023-09-19 07:18:20 +00:00
@MainActor
2023-01-17 10:36:01 +00:00
public struct AccountDetailView: View {
@Environment(\.openURL) private var openURL
2022-12-20 19:33:45 +00:00
@Environment(\.redactionReasons) private var reasons
2024-01-03 12:40:53 +00:00
@Environment(\.openWindow) private var openWindow
2023-01-22 05:38:30 +00:00
@Environment(StreamWatcher.self) private var watcher
@Environment(CurrentAccount.self) private var currentAccount
@Environment(CurrentInstance.self) private var currentInstance
2023-09-19 07:18:20 +00:00
@Environment(UserPreferences.self) private var preferences
2023-09-18 19:03:52 +00:00
@Environment(Theme.self) private var theme
@Environment(Client.self) private var client
@Environment(RouterPath.self) private var routerPath
2023-01-17 10:36:01 +00:00
@State private var viewModel: AccountDetailViewModel
2022-12-27 12:49:54 +00:00
@State private var isCurrentUser: Bool = false
@State private var showBlockConfirmation: Bool = false
2023-01-27 19:36:40 +00:00
2023-01-10 07:24:05 +00:00
@State private var isEditingAccount: Bool = false
@State private var isEditingFilters: Bool = false
@State private var isEditingRelationshipNote: Bool = false
2024-02-14 11:48:14 +00:00
@State private var displayTitle: Bool = false
2023-01-17 10:36:01 +00:00
@Binding var scrollToTopSignal: Int
/// When coming from a URL like a mention tap in a status.
public init(accountId: String, scrollToTopSignal: Binding<Int>) {
_viewModel = .init(initialValue: .init(accountId: accountId))
_scrollToTopSignal = scrollToTopSignal
2022-11-29 11:18:06 +00:00
}
2023-01-17 10:36:01 +00:00
/// When the account is already fetched by the parent caller.
public init(account: Account, scrollToTopSignal: Binding<Int>) {
_viewModel = .init(initialValue: .init(account: account))
_scrollToTopSignal = scrollToTopSignal
2022-12-17 12:37:46 +00:00
}
2023-02-12 15:29:41 +00:00
2022-11-29 11:18:06 +00:00
public var body: some View {
2022-12-27 08:11:12 +00:00
ScrollViewReader { proxy in
2023-02-12 15:13:57 +00:00
List {
ScrollToView()
.onAppear { displayTitle = false }
.onDisappear { displayTitle = true }
makeHeaderView(proxy: proxy)
.applyAccountDetailsRowStyle(theme: theme)
.padding(.bottom, -20)
familiarFollowers
.applyAccountDetailsRowStyle(theme: theme)
featuredTagsView
.applyAccountDetailsRowStyle(theme: theme)
2023-02-12 15:29:41 +00:00
2023-02-12 15:13:57 +00:00
Picker("", selection: $viewModel.selectedTab) {
ForEach(isCurrentUser ? AccountDetailViewModel.Tab.currentAccountTabs : AccountDetailViewModel.Tab.accountTabs,
2023-03-13 12:38:28 +00:00
id: \.self)
{ tab in
2024-01-08 17:22:44 +00:00
if tab == .boosts {
Image("Rocket")
.tag(tab)
.accessibilityLabel(tab.accessibilityLabel)
} else {
Image(systemName: tab.iconName)
.tag(tab)
.accessibilityLabel(tab.accessibilityLabel)
}
}
2023-02-12 15:13:57 +00:00
}
.pickerStyle(.segmented)
.padding(.layoutPadding)
.applyAccountDetailsRowStyle(theme: theme)
2023-02-12 15:13:57 +00:00
.id("status")
2023-01-17 10:36:01 +00:00
2024-01-08 17:22:44 +00:00
if viewModel.selectedTab == .statuses {
pinnedPostsView
}
2024-01-08 17:22:44 +00:00
StatusesListView(fetcher: viewModel,
client: client,
routerPath: routerPath)
2022-11-29 11:18:06 +00:00
}
2023-02-12 17:14:34 +00:00
.environment(\.defaultMinListRowHeight, 1)
2023-02-12 15:13:57 +00:00
.listStyle(.plain)
#if !os(visionOS)
2024-02-14 11:48:14 +00:00
.scrollContentBackground(.hidden)
.background(theme.primaryBackgroundColor)
#endif
2024-02-14 11:48:14 +00:00
.onChange(of: scrollToTopSignal) {
withAnimation {
proxy.scrollTo(ScrollToView.Constants.scrollToTop, anchor: .top)
}
}
2022-11-29 11:18:06 +00:00
}
.onAppear {
guard reasons != .placeholder else { return }
isCurrentUser = currentAccount.account?.id == viewModel.accountId
viewModel.isCurrentUser = isCurrentUser
viewModel.client = client
// Avoid capturing non-Sendable `self` just to access the view model.
2023-09-16 12:15:03 +00:00
let viewModel = viewModel
Task {
2023-01-17 20:08:05 +00:00
await withTaskGroup(of: Void.self) { group in
group.addTask { await viewModel.fetchAccount() }
group.addTask {
if await viewModel.statuses.isEmpty {
await viewModel.fetchNewestStatuses(pullToRefresh: false)
2023-01-17 20:08:05 +00:00
}
}
if !viewModel.isCurrentUser {
group.addTask { await viewModel.fetchFamilliarFollowers() }
}
}
2022-12-20 15:08:09 +00:00
}
}
.refreshable {
Task {
SoundEffectManager.shared.playSound(.pull)
HapticManager.shared.fireHaptic(.dataRefresh(intensity: 0.3))
2022-12-20 15:08:09 +00:00
await viewModel.fetchAccount()
await viewModel.fetchNewestStatuses(pullToRefresh: true)
HapticManager.shared.fireHaptic(.dataRefresh(intensity: 0.7))
SoundEffectManager.shared.playSound(.refresh)
2022-12-20 15:08:09 +00:00
}
2022-12-18 19:30:19 +00:00
}
.onChange(of: watcher.latestEvent?.id) {
if let latestEvent = watcher.latestEvent,
2023-01-17 10:36:01 +00:00
viewModel.accountId == currentAccount.account?.id
{
viewModel.handleEvent(event: latestEvent, currentAccount: currentAccount)
}
}
.onChange(of: isEditingAccount) { _, newValue in
if !newValue {
2023-01-10 07:24:05 +00:00
Task {
await viewModel.fetchAccount()
await preferences.refreshServerPreferences()
}
}
}
2023-01-10 07:24:05 +00:00
.sheet(isPresented: $isEditingAccount, content: {
EditAccountView()
})
.sheet(isPresented: $isEditingFilters, content: {
FiltersListView()
})
.sheet(isPresented: $isEditingRelationshipNote, content: {
EditRelationshipNoteView(accountDetailViewModel: viewModel)
})
2022-12-20 08:37:07 +00:00
.edgesIgnoringSafeArea(.top)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
2023-01-04 17:37:58 +00:00
toolbarContent
}
2022-12-18 19:30:19 +00:00
}
2023-01-17 10:36:01 +00:00
2022-12-18 19:30:19 +00:00
@ViewBuilder
2022-12-27 08:11:12 +00:00
private func makeHeaderView(proxy: ScrollViewProxy?) -> some View {
switch viewModel.accountState {
2022-12-18 19:30:19 +00:00
case .loading:
AccountDetailHeaderView(viewModel: viewModel,
2022-12-20 16:11:12 +00:00
account: .placeholder(),
2023-02-12 15:13:57 +00:00
scrollViewProxy: proxy)
2022-12-18 19:30:19 +00:00
.redacted(reason: .placeholder)
2023-09-18 16:55:11 +00:00
.allowsHitTesting(false)
2022-12-18 19:30:19 +00:00
case let .data(account):
AccountDetailHeaderView(viewModel: viewModel,
2022-12-20 16:11:12 +00:00
account: account,
2023-02-12 15:13:57 +00:00
scrollViewProxy: proxy)
2022-12-18 19:30:19 +00:00
case let .error(error):
Text("Error: \(error.localizedDescription)")
}
}
2023-01-22 05:38:30 +00:00
2022-12-21 19:26:38 +00:00
@ViewBuilder
private var featuredTagsView: some View {
2023-02-19 10:35:46 +00:00
if !viewModel.featuredTags.isEmpty {
2022-12-21 19:26:38 +00:00
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 4) {
2022-12-21 19:53:23 +00:00
if !viewModel.featuredTags.isEmpty {
ForEach(viewModel.featuredTags) { tag in
Button {
routerPath.navigate(to: .hashTag(tag: tag.name, account: viewModel.accountId))
2022-12-21 19:53:23 +00:00
} label: {
VStack(alignment: .leading, spacing: 0) {
Text("#\(tag.name)")
.font(.scaledCallout)
Text("account.detail.featured-tags-n-posts \(tag.statusesCountInt)")
2022-12-21 19:53:23 +00:00
.font(.caption2)
}
}.buttonStyle(.bordered)
}
2022-12-21 19:26:38 +00:00
}
}
.padding(.leading, .layoutPadding)
2022-12-21 19:26:38 +00:00
}
}
}
2023-01-17 10:36:01 +00:00
@ViewBuilder
private var familiarFollowers: some View {
if !viewModel.familiarFollowers.isEmpty {
2022-12-23 15:21:31 +00:00
VStack(alignment: .leading, spacing: 2) {
Text("account.detail.familiar-followers")
.font(.scaledHeadline)
.padding(.leading, .layoutPadding)
Profile tab accessibility uplift (#1274) * Combine `joinedAtView` into one accessibility element Previously, the calendar image was visible with a nonsensical label. We use the `.combine` operator here to maintain the proper string formatting of the date. * Improve the accessibility of the AccountDetailHeaderView Previously, this image had no description and no indication that it had an associated interaction. Now, we wrap it in a button that performs the tap gesture action, and remove the element altogether if there is no avatar image set. This commit also handles the checkmark for supporter users * Tweak accessibility of Profile CustomInfoLabels This commit: - Reverses the order of title and value - Sets the value as an `accessibilityValue` - Adds a hint indicating what the button does, as they perform slightly different actions * Make Profile tab header image into a Button This element has an action associated with it (quicklook), so it makes more sense to have it as a button, and hide it if the user does not have an image set. Without the action it would have been considered decorative and should be hidden. * Change accessibilityLabel of Profile tab nav bar item to ‘Options’ “More” is considered overly generic. This commit also adds two additional user input label options * Add accessibility labels for the Profile tab `Picker` Previously, these labels were the default accessibility label provided by the SF symbol, that almost, but not quite, made sense * Remove StatusRowView swipe actions if VoiceOver is running These swipe actions are automagically added to the accessibility element’s custom actions, in addition to the ones already there, which means that there is a significant (and confusing) amount of doubling up going on. * Fix typo in StatusRowView.accessibilityActions * Add accessibilityLabels to all StatusRowActionsView actions * Provide explicit combined accessibility label for unfocused StatusRowView Previously, this was a synthesized label, which read the elements in their traversal order, and didn’t provide any context for which of the three numbers corresponded to replies, boosts or favourites. Now, we create an explicit combined label when the post isn’t being viewed by itself. * Improve accessibility of StatusRow(Reblog|Reply)View They are now combined elements and don’t vend the icon as its own element. * Add missing punctuation to accessibility hints * Remove interaction from Profile tab @username and profile note elements These elements open the profile photo url, which is already provided explicitly through the profile photo * Prefer spoiler warning for StatusRowView accessibility label …but place the full, unredacted content in an `AccessibilityCustomContent` field for easy access. Additionally, if VoiceOver is running, an action to expand the warning is also available. * Represent `FollowButton` elements as Toggles to accessibility Since these buttons have two states (though arguable in the case of following, but handled here by not changing the representation if a request is pending), it makes sense to handle them as toggles, so they will be read as “Following, On, <Trait>” * Remove errant comment * Add “Verified” accessibilityValue to profile fields * Fix bug StatusRowView default action bug affecting VoiceOver users Previously, the default (‘Activate’) action for VoiceOver users would be to share a link to the toot, rather than navigate to its detail. It’s hard to say exactly what caused this, but the root was the inclusion of the `contextMenu` in the `accessibilityActions`. Now, double-tapping on a a non-focused `StatusRowView` will take you to the toot detail. * Add header trait to Profile tab display name and familiar followers These stand out as being header-like in presentation and represent the beginning of specific parts of the screen. * Add conditional accessibility modifier to Profile tab user-defined fields that opens the correct link * Add accessibility container that contextualises the user-defined fields When VoiceOver users first enter a user-defined field, the container label will be read out before the element’s spoken description. * Improve StatusRowView combined accessibility label It will now start with: “X boosted Y”, “X replied to @Y”, or “X…” depending on the context of the toot. * Change familiar follows thumbnail to a Button; add display name as accessibility label Previously, this button had no context, and would just be a series of images with nothing to allow users to disambiguate them. * Revert changes from ZStack with tap gesture to Button Using a Button for this purpose caused high weirdness in tap zones. Basically everything down to the familiar followers triggered both image buttons. * Add image alt text to StatusRowView and StatusRowMediaPreviewView Previously, there was no way for the intended audience for the alt text to find said text. There is a tap gesture on each image in the focused status row, but this is not advertised to the user. Now, the first image’s alt text is read as part of the non-focused, combined representation, and each image has its own alt text attributed in the focused representation. * Add Profile tab accessibility labels to indicate private/bot/muted/blocked accounts Previously, the icon did not have any accessible representation (an empty text string). * Add header trait to Profile “pinned post” * Use the Account.Field.name for the user input label * Replace spaces with commas in StatusRowView.combinedAccessibilityLabel
2023-03-19 15:27:18 +00:00
.accessibilityAddTraits(.isHeader)
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 0) {
ForEach(viewModel.familiarFollowers) { account in
Profile tab accessibility uplift (#1274) * Combine `joinedAtView` into one accessibility element Previously, the calendar image was visible with a nonsensical label. We use the `.combine` operator here to maintain the proper string formatting of the date. * Improve the accessibility of the AccountDetailHeaderView Previously, this image had no description and no indication that it had an associated interaction. Now, we wrap it in a button that performs the tap gesture action, and remove the element altogether if there is no avatar image set. This commit also handles the checkmark for supporter users * Tweak accessibility of Profile CustomInfoLabels This commit: - Reverses the order of title and value - Sets the value as an `accessibilityValue` - Adds a hint indicating what the button does, as they perform slightly different actions * Make Profile tab header image into a Button This element has an action associated with it (quicklook), so it makes more sense to have it as a button, and hide it if the user does not have an image set. Without the action it would have been considered decorative and should be hidden. * Change accessibilityLabel of Profile tab nav bar item to ‘Options’ “More” is considered overly generic. This commit also adds two additional user input label options * Add accessibility labels for the Profile tab `Picker` Previously, these labels were the default accessibility label provided by the SF symbol, that almost, but not quite, made sense * Remove StatusRowView swipe actions if VoiceOver is running These swipe actions are automagically added to the accessibility element’s custom actions, in addition to the ones already there, which means that there is a significant (and confusing) amount of doubling up going on. * Fix typo in StatusRowView.accessibilityActions * Add accessibilityLabels to all StatusRowActionsView actions * Provide explicit combined accessibility label for unfocused StatusRowView Previously, this was a synthesized label, which read the elements in their traversal order, and didn’t provide any context for which of the three numbers corresponded to replies, boosts or favourites. Now, we create an explicit combined label when the post isn’t being viewed by itself. * Improve accessibility of StatusRow(Reblog|Reply)View They are now combined elements and don’t vend the icon as its own element. * Add missing punctuation to accessibility hints * Remove interaction from Profile tab @username and profile note elements These elements open the profile photo url, which is already provided explicitly through the profile photo * Prefer spoiler warning for StatusRowView accessibility label …but place the full, unredacted content in an `AccessibilityCustomContent` field for easy access. Additionally, if VoiceOver is running, an action to expand the warning is also available. * Represent `FollowButton` elements as Toggles to accessibility Since these buttons have two states (though arguable in the case of following, but handled here by not changing the representation if a request is pending), it makes sense to handle them as toggles, so they will be read as “Following, On, <Trait>” * Remove errant comment * Add “Verified” accessibilityValue to profile fields * Fix bug StatusRowView default action bug affecting VoiceOver users Previously, the default (‘Activate’) action for VoiceOver users would be to share a link to the toot, rather than navigate to its detail. It’s hard to say exactly what caused this, but the root was the inclusion of the `contextMenu` in the `accessibilityActions`. Now, double-tapping on a a non-focused `StatusRowView` will take you to the toot detail. * Add header trait to Profile tab display name and familiar followers These stand out as being header-like in presentation and represent the beginning of specific parts of the screen. * Add conditional accessibility modifier to Profile tab user-defined fields that opens the correct link * Add accessibility container that contextualises the user-defined fields When VoiceOver users first enter a user-defined field, the container label will be read out before the element’s spoken description. * Improve StatusRowView combined accessibility label It will now start with: “X boosted Y”, “X replied to @Y”, or “X…” depending on the context of the toot. * Change familiar follows thumbnail to a Button; add display name as accessibility label Previously, this button had no context, and would just be a series of images with nothing to allow users to disambiguate them. * Revert changes from ZStack with tap gesture to Button Using a Button for this purpose caused high weirdness in tap zones. Basically everything down to the familiar followers triggered both image buttons. * Add image alt text to StatusRowView and StatusRowMediaPreviewView Previously, there was no way for the intended audience for the alt text to find said text. There is a tap gesture on each image in the focused status row, but this is not advertised to the user. Now, the first image’s alt text is read as part of the non-focused, combined representation, and each image has its own alt text attributed in the focused representation. * Add Profile tab accessibility labels to indicate private/bot/muted/blocked accounts Previously, the icon did not have any accessible representation (an empty text string). * Add header trait to Profile “pinned post” * Use the Account.Field.name for the user input label * Replace spaces with commas in StatusRowView.combinedAccessibilityLabel
2023-03-19 15:27:18 +00:00
Button {
routerPath.navigate(to: .accountDetailWithAccount(account: account))
} label: {
AvatarView(account.avatar, config: .badge)
Profile tab accessibility uplift (#1274) * Combine `joinedAtView` into one accessibility element Previously, the calendar image was visible with a nonsensical label. We use the `.combine` operator here to maintain the proper string formatting of the date. * Improve the accessibility of the AccountDetailHeaderView Previously, this image had no description and no indication that it had an associated interaction. Now, we wrap it in a button that performs the tap gesture action, and remove the element altogether if there is no avatar image set. This commit also handles the checkmark for supporter users * Tweak accessibility of Profile CustomInfoLabels This commit: - Reverses the order of title and value - Sets the value as an `accessibilityValue` - Adds a hint indicating what the button does, as they perform slightly different actions * Make Profile tab header image into a Button This element has an action associated with it (quicklook), so it makes more sense to have it as a button, and hide it if the user does not have an image set. Without the action it would have been considered decorative and should be hidden. * Change accessibilityLabel of Profile tab nav bar item to ‘Options’ “More” is considered overly generic. This commit also adds two additional user input label options * Add accessibility labels for the Profile tab `Picker` Previously, these labels were the default accessibility label provided by the SF symbol, that almost, but not quite, made sense * Remove StatusRowView swipe actions if VoiceOver is running These swipe actions are automagically added to the accessibility element’s custom actions, in addition to the ones already there, which means that there is a significant (and confusing) amount of doubling up going on. * Fix typo in StatusRowView.accessibilityActions * Add accessibilityLabels to all StatusRowActionsView actions * Provide explicit combined accessibility label for unfocused StatusRowView Previously, this was a synthesized label, which read the elements in their traversal order, and didn’t provide any context for which of the three numbers corresponded to replies, boosts or favourites. Now, we create an explicit combined label when the post isn’t being viewed by itself. * Improve accessibility of StatusRow(Reblog|Reply)View They are now combined elements and don’t vend the icon as its own element. * Add missing punctuation to accessibility hints * Remove interaction from Profile tab @username and profile note elements These elements open the profile photo url, which is already provided explicitly through the profile photo * Prefer spoiler warning for StatusRowView accessibility label …but place the full, unredacted content in an `AccessibilityCustomContent` field for easy access. Additionally, if VoiceOver is running, an action to expand the warning is also available. * Represent `FollowButton` elements as Toggles to accessibility Since these buttons have two states (though arguable in the case of following, but handled here by not changing the representation if a request is pending), it makes sense to handle them as toggles, so they will be read as “Following, On, <Trait>” * Remove errant comment * Add “Verified” accessibilityValue to profile fields * Fix bug StatusRowView default action bug affecting VoiceOver users Previously, the default (‘Activate’) action for VoiceOver users would be to share a link to the toot, rather than navigate to its detail. It’s hard to say exactly what caused this, but the root was the inclusion of the `contextMenu` in the `accessibilityActions`. Now, double-tapping on a a non-focused `StatusRowView` will take you to the toot detail. * Add header trait to Profile tab display name and familiar followers These stand out as being header-like in presentation and represent the beginning of specific parts of the screen. * Add conditional accessibility modifier to Profile tab user-defined fields that opens the correct link * Add accessibility container that contextualises the user-defined fields When VoiceOver users first enter a user-defined field, the container label will be read out before the element’s spoken description. * Improve StatusRowView combined accessibility label It will now start with: “X boosted Y”, “X replied to @Y”, or “X…” depending on the context of the toot. * Change familiar follows thumbnail to a Button; add display name as accessibility label Previously, this button had no context, and would just be a series of images with nothing to allow users to disambiguate them. * Revert changes from ZStack with tap gesture to Button Using a Button for this purpose caused high weirdness in tap zones. Basically everything down to the familiar followers triggered both image buttons. * Add image alt text to StatusRowView and StatusRowMediaPreviewView Previously, there was no way for the intended audience for the alt text to find said text. There is a tap gesture on each image in the focused status row, but this is not advertised to the user. Now, the first image’s alt text is read as part of the non-focused, combined representation, and each image has its own alt text attributed in the focused representation. * Add Profile tab accessibility labels to indicate private/bot/muted/blocked accounts Previously, the icon did not have any accessible representation (an empty text string). * Add header trait to Profile “pinned post” * Use the Account.Field.name for the user input label * Replace spaces with commas in StatusRowView.combinedAccessibilityLabel
2023-03-19 15:27:18 +00:00
.padding(.leading, -4)
.accessibilityLabel(account.safeDisplayName)
}
.accessibilityAddTraits(.isImage)
.buttonStyle(.plain)
}
}
.padding(.leading, .layoutPadding + 4)
}
}
.padding(.top, 2)
.padding(.bottom, 12)
}
}
2023-01-17 10:36:01 +00:00
2023-01-03 17:22:08 +00:00
@ViewBuilder
private var pinnedPostsView: some View {
if !viewModel.pinned.isEmpty {
2023-02-12 17:14:34 +00:00
Label("account.post.pinned", systemImage: "pin.fill")
Profile tab accessibility uplift (#1274) * Combine `joinedAtView` into one accessibility element Previously, the calendar image was visible with a nonsensical label. We use the `.combine` operator here to maintain the proper string formatting of the date. * Improve the accessibility of the AccountDetailHeaderView Previously, this image had no description and no indication that it had an associated interaction. Now, we wrap it in a button that performs the tap gesture action, and remove the element altogether if there is no avatar image set. This commit also handles the checkmark for supporter users * Tweak accessibility of Profile CustomInfoLabels This commit: - Reverses the order of title and value - Sets the value as an `accessibilityValue` - Adds a hint indicating what the button does, as they perform slightly different actions * Make Profile tab header image into a Button This element has an action associated with it (quicklook), so it makes more sense to have it as a button, and hide it if the user does not have an image set. Without the action it would have been considered decorative and should be hidden. * Change accessibilityLabel of Profile tab nav bar item to ‘Options’ “More” is considered overly generic. This commit also adds two additional user input label options * Add accessibility labels for the Profile tab `Picker` Previously, these labels were the default accessibility label provided by the SF symbol, that almost, but not quite, made sense * Remove StatusRowView swipe actions if VoiceOver is running These swipe actions are automagically added to the accessibility element’s custom actions, in addition to the ones already there, which means that there is a significant (and confusing) amount of doubling up going on. * Fix typo in StatusRowView.accessibilityActions * Add accessibilityLabels to all StatusRowActionsView actions * Provide explicit combined accessibility label for unfocused StatusRowView Previously, this was a synthesized label, which read the elements in their traversal order, and didn’t provide any context for which of the three numbers corresponded to replies, boosts or favourites. Now, we create an explicit combined label when the post isn’t being viewed by itself. * Improve accessibility of StatusRow(Reblog|Reply)View They are now combined elements and don’t vend the icon as its own element. * Add missing punctuation to accessibility hints * Remove interaction from Profile tab @username and profile note elements These elements open the profile photo url, which is already provided explicitly through the profile photo * Prefer spoiler warning for StatusRowView accessibility label …but place the full, unredacted content in an `AccessibilityCustomContent` field for easy access. Additionally, if VoiceOver is running, an action to expand the warning is also available. * Represent `FollowButton` elements as Toggles to accessibility Since these buttons have two states (though arguable in the case of following, but handled here by not changing the representation if a request is pending), it makes sense to handle them as toggles, so they will be read as “Following, On, <Trait>” * Remove errant comment * Add “Verified” accessibilityValue to profile fields * Fix bug StatusRowView default action bug affecting VoiceOver users Previously, the default (‘Activate’) action for VoiceOver users would be to share a link to the toot, rather than navigate to its detail. It’s hard to say exactly what caused this, but the root was the inclusion of the `contextMenu` in the `accessibilityActions`. Now, double-tapping on a a non-focused `StatusRowView` will take you to the toot detail. * Add header trait to Profile tab display name and familiar followers These stand out as being header-like in presentation and represent the beginning of specific parts of the screen. * Add conditional accessibility modifier to Profile tab user-defined fields that opens the correct link * Add accessibility container that contextualises the user-defined fields When VoiceOver users first enter a user-defined field, the container label will be read out before the element’s spoken description. * Improve StatusRowView combined accessibility label It will now start with: “X boosted Y”, “X replied to @Y”, or “X…” depending on the context of the toot. * Change familiar follows thumbnail to a Button; add display name as accessibility label Previously, this button had no context, and would just be a series of images with nothing to allow users to disambiguate them. * Revert changes from ZStack with tap gesture to Button Using a Button for this purpose caused high weirdness in tap zones. Basically everything down to the familiar followers triggered both image buttons. * Add image alt text to StatusRowView and StatusRowMediaPreviewView Previously, there was no way for the intended audience for the alt text to find said text. There is a tap gesture on each image in the focused status row, but this is not advertised to the user. Now, the first image’s alt text is read as part of the non-focused, combined representation, and each image has its own alt text attributed in the focused representation. * Add Profile tab accessibility labels to indicate private/bot/muted/blocked accounts Previously, the icon did not have any accessible representation (an empty text string). * Add header trait to Profile “pinned post” * Use the Account.Field.name for the user input label * Replace spaces with commas in StatusRowView.combinedAccessibilityLabel
2023-03-19 15:27:18 +00:00
.accessibilityAddTraits(.isHeader)
2023-02-12 17:14:34 +00:00
.font(.scaledFootnote)
2023-12-04 14:49:44 +00:00
.foregroundStyle(.secondary)
2023-02-12 17:14:34 +00:00
.fontWeight(.semibold)
.listRowInsets(.init(top: 0,
leading: 12,
bottom: 0,
trailing: .layoutPadding))
.listRowSeparator(.hidden)
2024-02-14 11:48:14 +00:00
#if !os(visionOS)
2023-02-12 17:14:34 +00:00
.listRowBackground(theme.primaryBackgroundColor)
2024-02-14 11:48:14 +00:00
#endif
2023-01-03 17:22:08 +00:00
ForEach(viewModel.pinned) { status in
StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath))
2023-01-03 17:22:08 +00:00
}
2023-02-12 17:14:34 +00:00
Rectangle()
2024-02-14 11:48:14 +00:00
#if os(visionOS)
2024-02-06 18:19:53 +00:00
.fill(Color.clear)
2024-02-14 11:48:14 +00:00
#else
2023-02-12 17:14:34 +00:00
.fill(theme.secondaryBackgroundColor)
2024-02-14 11:48:14 +00:00
#endif
2023-02-12 17:14:34 +00:00
.frame(height: 12)
.listRowInsets(.init())
.listRowSeparator(.hidden)
Timeline & Timeline detail accessibility uplift (#1323) * Improve accessibility of StatusPollView Previously, this view did not provide the proper context to indicate that it represented a poll. Now, we’ve added - A container that will stay “Active poll” or “Poll results” when the cursor first hits one of the options; - A prefix to say “Option X of Y” before each option; - A Selected trait on the selected option(s), if present - Consolidating and adding an `.updatesFrequently` trait to the footer view with the countdown. * Add poll description in StatusRowView combinedAccessibilityLabel This largely duplicates the logic in `StatusPollView`. * Improve accessibility of media attachments Previously, the media attachments without alt text would not show up in the consolidated `StatusRowView`, nor would they be meaningfully explained on the status detail screen. Now, they are presented with their attachment type. * Change accessibilityRepresentation of AppAcountsSelectorView * Change Notifications tab title view accessibility representation to Menu Previously it would present as a button * Hide layout `Rectangle`s from accessibility * Consolidate `StatusRowDetailView` accessibility representation * Improve readability of Poll accessibility label * Ensure poll options don’t present as interactive when the poll is finished * Improve accessibility of StatusRowCardView Previously, it would present as four separate elements, including an image without a description, all interactive, none with an interactive trait. Now, it presents as a single element with the `.link` trait * Improve accessibility of StatusRowHeaderView Previously, it had no traits and no actions except inherited ones. Now it presents as a button, triggering its primary action. It also has custom actions corresponding to its context menu * Avoid applying the StatusRowView custom actions to every view when contained * Provide context for the application name * Add pauses to StatusRowView combinedAccessibilityLabel * Hide `TimelineView.scrollToTopView` from accessibility * Set appropriate font style on Notification header After the change the Text needed a `.headline` style to match the prior appearance. * Fix bug in accessibilityRepresentation of TimelineView nav bar title Previously, it would not display the proper label for .remoteLocal filter options. * Ensure that pop-up button nav bar titles are interactive * Ensure TextView responds to Environment.sizeCategory This resolves #1309 * Fix button --------- Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
2023-03-28 16:48:58 +00:00
.accessibilityHidden(true)
2023-01-03 17:22:08 +00:00
}
}
2023-01-17 10:36:01 +00:00
2023-01-04 17:37:58 +00:00
@ToolbarContentBuilder
private var toolbarContent: some ToolbarContent {
ToolbarItem(placement: .principal) {
if let account = viewModel.account, displayTitle {
VStack {
Text(account.displayName ?? "").font(.headline)
Text("account.detail.featured-tags-n-posts \(account.statusesCount ?? 0)")
.font(.footnote)
.foregroundStyle(.secondary)
}
}
}
ToolbarItemGroup(placement: .navigationBarTrailing) {
if !viewModel.isCurrentUser {
Button {
if let account = viewModel.account {
2024-01-09 12:28:57 +00:00
#if targetEnvironment(macCatalyst) || os(visionOS)
2024-01-03 12:40:53 +00:00
openWindow(value: WindowDestinationEditor.mentionStatusEditor(account: account, visibility: preferences.postVisibility))
#else
routerPath.presentedSheet = .mentionStatusEditor(account: account,
visibility: preferences.postVisibility)
#endif
}
} label: {
Image(systemName: "arrowshape.turn.up.left")
}
}
2023-07-19 05:46:25 +00:00
2023-01-04 17:37:58 +00:00
Menu {
AccountDetailContextMenu(showBlockConfirmation: $showBlockConfirmation, viewModel: viewModel)
2023-03-13 12:38:28 +00:00
if !viewModel.isCurrentUser {
Button {
isEditingRelationshipNote = true
} label: {
Label("account.relation.note.edit", systemImage: "pencil")
}
}
2023-03-13 12:38:28 +00:00
if isCurrentUser {
Button {
isEditingAccount = true
} label: {
Label("account.action.edit-info", systemImage: "pencil")
}
2023-09-16 12:15:03 +00:00
Button {
if let url = URL(string: "https://\(client.server)/settings/privacy") {
openURL(url)
}
} label: {
Label("account.action.privacy-settings", systemImage: "lock")
}
2023-01-17 10:36:01 +00:00
if currentInstance.isFiltersSupported {
Button {
isEditingFilters = true
} label: {
Label("account.action.edit-filters", systemImage: "line.3.horizontal.decrease.circle")
2023-01-04 17:37:58 +00:00
}
}
2023-01-17 10:36:01 +00:00
Button {
routerPath.presentedSheet = .accountPushNotficationsSettings
} label: {
Label("settings.push.navigation-title", systemImage: "bell")
2023-01-04 17:37:58 +00:00
}
2023-03-13 12:38:28 +00:00
if let account = viewModel.account {
Divider()
2023-03-13 12:38:28 +00:00
Button {
if let url = URL(string: "https://mastometrics.com/auth/login?username=\(account.acct)@\(client.server)&instance=\(client.server)&auto=true") {
openURL(url)
}
} label: {
Label("Mastometrics", systemImage: "chart.xyaxis.line")
}
Divider()
}
2023-03-13 12:38:28 +00:00
2023-03-08 18:02:31 +00:00
Button {
routerPath.presentedSheet = .settings
} label: {
Label("settings.title", systemImage: "gear")
}
2023-01-04 17:37:58 +00:00
}
} label: {
2023-02-12 15:13:57 +00:00
Image(systemName: "ellipsis.circle")
Profile tab accessibility uplift (#1274) * Combine `joinedAtView` into one accessibility element Previously, the calendar image was visible with a nonsensical label. We use the `.combine` operator here to maintain the proper string formatting of the date. * Improve the accessibility of the AccountDetailHeaderView Previously, this image had no description and no indication that it had an associated interaction. Now, we wrap it in a button that performs the tap gesture action, and remove the element altogether if there is no avatar image set. This commit also handles the checkmark for supporter users * Tweak accessibility of Profile CustomInfoLabels This commit: - Reverses the order of title and value - Sets the value as an `accessibilityValue` - Adds a hint indicating what the button does, as they perform slightly different actions * Make Profile tab header image into a Button This element has an action associated with it (quicklook), so it makes more sense to have it as a button, and hide it if the user does not have an image set. Without the action it would have been considered decorative and should be hidden. * Change accessibilityLabel of Profile tab nav bar item to ‘Options’ “More” is considered overly generic. This commit also adds two additional user input label options * Add accessibility labels for the Profile tab `Picker` Previously, these labels were the default accessibility label provided by the SF symbol, that almost, but not quite, made sense * Remove StatusRowView swipe actions if VoiceOver is running These swipe actions are automagically added to the accessibility element’s custom actions, in addition to the ones already there, which means that there is a significant (and confusing) amount of doubling up going on. * Fix typo in StatusRowView.accessibilityActions * Add accessibilityLabels to all StatusRowActionsView actions * Provide explicit combined accessibility label for unfocused StatusRowView Previously, this was a synthesized label, which read the elements in their traversal order, and didn’t provide any context for which of the three numbers corresponded to replies, boosts or favourites. Now, we create an explicit combined label when the post isn’t being viewed by itself. * Improve accessibility of StatusRow(Reblog|Reply)View They are now combined elements and don’t vend the icon as its own element. * Add missing punctuation to accessibility hints * Remove interaction from Profile tab @username and profile note elements These elements open the profile photo url, which is already provided explicitly through the profile photo * Prefer spoiler warning for StatusRowView accessibility label …but place the full, unredacted content in an `AccessibilityCustomContent` field for easy access. Additionally, if VoiceOver is running, an action to expand the warning is also available. * Represent `FollowButton` elements as Toggles to accessibility Since these buttons have two states (though arguable in the case of following, but handled here by not changing the representation if a request is pending), it makes sense to handle them as toggles, so they will be read as “Following, On, <Trait>” * Remove errant comment * Add “Verified” accessibilityValue to profile fields * Fix bug StatusRowView default action bug affecting VoiceOver users Previously, the default (‘Activate’) action for VoiceOver users would be to share a link to the toot, rather than navigate to its detail. It’s hard to say exactly what caused this, but the root was the inclusion of the `contextMenu` in the `accessibilityActions`. Now, double-tapping on a a non-focused `StatusRowView` will take you to the toot detail. * Add header trait to Profile tab display name and familiar followers These stand out as being header-like in presentation and represent the beginning of specific parts of the screen. * Add conditional accessibility modifier to Profile tab user-defined fields that opens the correct link * Add accessibility container that contextualises the user-defined fields When VoiceOver users first enter a user-defined field, the container label will be read out before the element’s spoken description. * Improve StatusRowView combined accessibility label It will now start with: “X boosted Y”, “X replied to @Y”, or “X…” depending on the context of the toot. * Change familiar follows thumbnail to a Button; add display name as accessibility label Previously, this button had no context, and would just be a series of images with nothing to allow users to disambiguate them. * Revert changes from ZStack with tap gesture to Button Using a Button for this purpose caused high weirdness in tap zones. Basically everything down to the familiar followers triggered both image buttons. * Add image alt text to StatusRowView and StatusRowMediaPreviewView Previously, there was no way for the intended audience for the alt text to find said text. There is a tap gesture on each image in the focused status row, but this is not advertised to the user. Now, the first image’s alt text is read as part of the non-focused, combined representation, and each image has its own alt text attributed in the focused representation. * Add Profile tab accessibility labels to indicate private/bot/muted/blocked accounts Previously, the icon did not have any accessible representation (an empty text string). * Add header trait to Profile “pinned post” * Use the Account.Field.name for the user input label * Replace spaces with commas in StatusRowView.combinedAccessibilityLabel
2023-03-19 15:27:18 +00:00
.accessibilityLabel("accessibility.tabs.profile.options.label")
.accessibilityInputLabels([
LocalizedStringKey("accessibility.tabs.profile.options.label"),
LocalizedStringKey("accessibility.tabs.profile.options.inputLabel1"),
2023-03-19 15:28:06 +00:00
LocalizedStringKey("accessibility.tabs.profile.options.inputLabel2"),
Profile tab accessibility uplift (#1274) * Combine `joinedAtView` into one accessibility element Previously, the calendar image was visible with a nonsensical label. We use the `.combine` operator here to maintain the proper string formatting of the date. * Improve the accessibility of the AccountDetailHeaderView Previously, this image had no description and no indication that it had an associated interaction. Now, we wrap it in a button that performs the tap gesture action, and remove the element altogether if there is no avatar image set. This commit also handles the checkmark for supporter users * Tweak accessibility of Profile CustomInfoLabels This commit: - Reverses the order of title and value - Sets the value as an `accessibilityValue` - Adds a hint indicating what the button does, as they perform slightly different actions * Make Profile tab header image into a Button This element has an action associated with it (quicklook), so it makes more sense to have it as a button, and hide it if the user does not have an image set. Without the action it would have been considered decorative and should be hidden. * Change accessibilityLabel of Profile tab nav bar item to ‘Options’ “More” is considered overly generic. This commit also adds two additional user input label options * Add accessibility labels for the Profile tab `Picker` Previously, these labels were the default accessibility label provided by the SF symbol, that almost, but not quite, made sense * Remove StatusRowView swipe actions if VoiceOver is running These swipe actions are automagically added to the accessibility element’s custom actions, in addition to the ones already there, which means that there is a significant (and confusing) amount of doubling up going on. * Fix typo in StatusRowView.accessibilityActions * Add accessibilityLabels to all StatusRowActionsView actions * Provide explicit combined accessibility label for unfocused StatusRowView Previously, this was a synthesized label, which read the elements in their traversal order, and didn’t provide any context for which of the three numbers corresponded to replies, boosts or favourites. Now, we create an explicit combined label when the post isn’t being viewed by itself. * Improve accessibility of StatusRow(Reblog|Reply)View They are now combined elements and don’t vend the icon as its own element. * Add missing punctuation to accessibility hints * Remove interaction from Profile tab @username and profile note elements These elements open the profile photo url, which is already provided explicitly through the profile photo * Prefer spoiler warning for StatusRowView accessibility label …but place the full, unredacted content in an `AccessibilityCustomContent` field for easy access. Additionally, if VoiceOver is running, an action to expand the warning is also available. * Represent `FollowButton` elements as Toggles to accessibility Since these buttons have two states (though arguable in the case of following, but handled here by not changing the representation if a request is pending), it makes sense to handle them as toggles, so they will be read as “Following, On, <Trait>” * Remove errant comment * Add “Verified” accessibilityValue to profile fields * Fix bug StatusRowView default action bug affecting VoiceOver users Previously, the default (‘Activate’) action for VoiceOver users would be to share a link to the toot, rather than navigate to its detail. It’s hard to say exactly what caused this, but the root was the inclusion of the `contextMenu` in the `accessibilityActions`. Now, double-tapping on a a non-focused `StatusRowView` will take you to the toot detail. * Add header trait to Profile tab display name and familiar followers These stand out as being header-like in presentation and represent the beginning of specific parts of the screen. * Add conditional accessibility modifier to Profile tab user-defined fields that opens the correct link * Add accessibility container that contextualises the user-defined fields When VoiceOver users first enter a user-defined field, the container label will be read out before the element’s spoken description. * Improve StatusRowView combined accessibility label It will now start with: “X boosted Y”, “X replied to @Y”, or “X…” depending on the context of the toot. * Change familiar follows thumbnail to a Button; add display name as accessibility label Previously, this button had no context, and would just be a series of images with nothing to allow users to disambiguate them. * Revert changes from ZStack with tap gesture to Button Using a Button for this purpose caused high weirdness in tap zones. Basically everything down to the familiar followers triggered both image buttons. * Add image alt text to StatusRowView and StatusRowMediaPreviewView Previously, there was no way for the intended audience for the alt text to find said text. There is a tap gesture on each image in the focused status row, but this is not advertised to the user. Now, the first image’s alt text is read as part of the non-focused, combined representation, and each image has its own alt text attributed in the focused representation. * Add Profile tab accessibility labels to indicate private/bot/muted/blocked accounts Previously, the icon did not have any accessible representation (an empty text string). * Add header trait to Profile “pinned post” * Use the Account.Field.name for the user input label * Replace spaces with commas in StatusRowView.combinedAccessibilityLabel
2023-03-19 15:27:18 +00:00
])
2023-01-04 17:37:58 +00:00
}
.confirmationDialog("Block User", isPresented: $showBlockConfirmation) {
if let account = viewModel.account {
Button("account.action.block-user-\(account.username)", role: .destructive) {
Task {
do {
viewModel.relationship = try await client.post(endpoint: Accounts.block(id: account.id))
2024-02-14 11:48:14 +00:00
} catch {}
}
}
}
} message: {
Text("account.action.block-user-confirmation")
}
2023-01-04 17:37:58 +00:00
}
}
2022-12-17 12:37:46 +00:00
}
extension View {
func applyAccountDetailsRowStyle(theme: Theme) -> some View {
2023-02-21 06:23:42 +00:00
listRowInsets(.init())
.listRowSeparator(.hidden)
2024-02-14 11:48:14 +00:00
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
2024-02-14 11:48:14 +00:00
#endif
}
}
2022-12-17 12:37:46 +00:00
struct AccountDetailView_Previews: PreviewProvider {
static var previews: some View {
AccountDetailView(account: .placeholder(), scrollToTopSignal: .constant(0))
2022-11-29 11:18:06 +00:00
}
}