native: share rows stack at accessibility sizes
The coordinator's ruling (b) on #180. At accessibility Dynamic Type sizes a person's row in the Share panel stacks: the address above the role (and ×), the address on up to three lines instead of one cut in the middle. Below them, and on the Mac, the row is as it was. Seen in the AX3 Share sheet snapshots (docs-phone-ax3, phone-share-sheet).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+37
−15
native/apple/Sources/DocsKit/DocsSharePanel.swift+37 −15
diff --git a/native/apple/Sources/DocsKit/DocsSharePanel.swift b/native/apple/Sources/DocsKit/DocsSharePanel.swift| index df3e435..004be92 100644 |
| --- a/native/apple/Sources/DocsKit/DocsSharePanel.swift |
| +++ b/native/apple/Sources/DocsKit/DocsSharePanel.swift |
| @@ -19,6 +19,7 @@ import UIKit |
| var focusOnAppear = true |
| let close: () -> Void |
| @Environment(\.locale) private var locale |
| + @Environment(\.dynamicTypeSize) private var typeSize |
| /// The avatars' and icons' circles: 28pt, growing with their letters |
| /// and symbols under Dynamic Type (iPhone and iPad; the Mac keeps 28). |
| @ScaledMetric(relativeTo: .footnote) private var circle: CGFloat = 28 |
| @@ -173,7 +174,7 @@ import UIKit |
| VStack(alignment: .leading, spacing: DocsSpacing.sp2) { |
| person(initial: me.map(Self.initial) ?? "?", mine: true) { |
| if let me, !me.isEmpty { |
| - Text(verbatim: me).lineLimit(1).truncationMode(.middle) |
| + Text(verbatim: me).lineLimit(addressLines).truncationMode(.middle) |
| Text("docs.share.panel.you", bundle: DocsResources.bundle).italic().foregroundStyle(OficinaPalette.textMuted) |
| } else { |
| Text("docs.share.panel.you", bundle: DocsResources.bundle).italic() |
| @@ -184,7 +185,7 @@ import UIKit |
| ForEach(model.information?.grants ?? []) { grant in |
| let remove = strings("docs.share.panel.remove").replacingOccurrences(of: "{address}", with: grant.address) |
| person(initial: Self.initial(grant.address), mine: false) { |
| - Text(verbatim: grant.address).lineLimit(1).truncationMode(.middle).textSelection(.enabled) |
| + Text(verbatim: grant.address).lineLimit(addressLines).truncationMode(.middle).textSelection(.enabled) |
| } trailing: { |
| Text(grant.role == "writer" ? "docs.share.panel.can_edit" : "docs.share.panel.can_read", bundle: DocsResources.bundle) |
| .foregroundStyle(OficinaPalette.textMuted) |
| @@ -205,19 +206,40 @@ import UIKit |
| } |
| } |
| - private func person<Name: View, Trailing: View>(initial: String, mine: Bool, @ViewBuilder name: () -> Name, |
| - @ViewBuilder trailing: () -> Trailing) -> some View { |
| - HStack(spacing: DocsSpacing.sp2) { |
| - Text(verbatim: initial) |
| - .font(DocsType.font(12, .semibold, ios: .footnote)) |
| - .frame(width: circle, height: circle) |
| - .foregroundStyle(mine ? OficinaPalette.onAccent : OficinaPalette.accent(.docs)) |
| - .background(Circle().fill(mine ? OficinaPalette.accent(.docs) : OficinaPalette.accentSoft(.docs))) |
| - .accessibilityHidden(true) |
| - HStack(spacing: DocsSpacing.sp1) { name() } |
| - .foregroundStyle(OficinaPalette.text) |
| - Spacer(minLength: DocsSpacing.sp2) |
| - trailing() |
| + /// At accessibility sizes a person's row stacks: the address, whole, |
| + /// above the role (the coordinator's ruling on #180). |
| + private var stacked: Bool { typeSize.isAccessibilitySize } |
| + private var addressLines: Int { stacked ? 3 : 1 } |
| + |
| + @ViewBuilder private func person<Name: View, Trailing: View>(initial: String, mine: Bool, @ViewBuilder name: () -> Name, |
| + @ViewBuilder trailing: () -> Trailing) -> some View { |
| + let avatar = Text(verbatim: initial) |
| + .font(DocsType.font(12, .semibold, ios: .footnote)) |
| + .frame(width: circle, height: circle) |
| + .foregroundStyle(mine ? OficinaPalette.onAccent : OficinaPalette.accent(.docs)) |
| + .background(Circle().fill(mine ? OficinaPalette.accent(.docs) : OficinaPalette.accentSoft(.docs))) |
| + .accessibilityHidden(true) |
| + Group { |
| + if stacked { |
| + HStack(alignment: .top, spacing: DocsSpacing.sp2) { |
| + avatar |
| + VStack(alignment: .leading, spacing: DocsSpacing.sp1) { |
| + HStack(spacing: DocsSpacing.sp1) { name() } |
| + .foregroundStyle(OficinaPalette.text) |
| + .fixedSize(horizontal: false, vertical: true) |
| + HStack(spacing: DocsSpacing.sp2) { trailing() } |
| + } |
| + Spacer(minLength: 0) |
| + } |
| + } else { |
| + HStack(spacing: DocsSpacing.sp2) { |
| + avatar |
| + HStack(spacing: DocsSpacing.sp1) { name() } |
| + .foregroundStyle(OficinaPalette.text) |
| + Spacer(minLength: DocsSpacing.sp2) |
| + trailing() |
| + } |
| + } |
| } |
| .font(.callout) |
| .frame(minHeight: rowHeight) |