mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-11-29 08:29:22 +00:00
Fix composer control overlap at large text sizes (#1841)
* Fix composer control overlap at large text sizes At accessibility XXXL, the composer icons outgrew their fixed 36-point frames, causing attachment/send accessibility-bounds overlap in the 280-point Matrix iOS simulator fixture. All six frames used by the attachment, send and microphone controls in ContentComposerView now use a .title2-relative @ScaledMetric with a 36-point default, so their allocations follow the icons' scaling. Automatic regression tests cover iOS composer interactions, selected-language layouts and photo-picker callbacks, plus macOS controls. * Preserve the 36-point minimum for composer controls Keep all six composer control frames at least 36 points while preserving growth at larger Dynamic Type sizes. * Test the composer minimum size and report UI test failures Add extra-small Dynamic Type coverage for 36-point control allocations in both themes using the existing test host. Print assertion errors and failed test cases from the saved runner log, and update the coverage documentation. * Simplify composer sizing regression tests Move the shared frame sizing into a modifier and test icon containment and the 36-point minimum in the existing iOS target. Remove the dedicated composer hosts, runners, model injection and associated package, project and CI changes.
This commit is contained in:
1 parent
782f63d735
commit
abf932acfd
2 files changed
+85
-6
No files matched your search
@@ -261,7 +261,7 @@ private extension ContentComposerView {
|
||||
Image(systemName: "camera.circle.fill")
|
||||
.font(.bitchatSystem(size: 24))
|
||||
.foregroundColor(composerAccentColor)
|
||||
.frame(width: 36, height: 36)
|
||||
.modifier(ComposerActionFrame())
|
||||
.contentShape(Circle())
|
||||
.onTapGesture {
|
||||
mediaPickerMode = .photoLibrary
|
||||
@@ -282,7 +282,7 @@ private extension ContentComposerView {
|
||||
Image(systemName: "photo.circle.fill")
|
||||
.font(.bitchatSystem(size: 24))
|
||||
.foregroundColor(composerAccentColor)
|
||||
.frame(width: 36, height: 36)
|
||||
.modifier(ComposerActionFrame())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityLabel(Strings.choosePhoto)
|
||||
@@ -301,10 +301,10 @@ private extension ContentComposerView {
|
||||
.opacity(hasText ? 1 : 0)
|
||||
.allowsHitTesting(hasText)
|
||||
}
|
||||
.frame(width: 36, height: 36)
|
||||
.modifier(ComposerActionFrame())
|
||||
} else {
|
||||
sendButtonView(enabled: hasText)
|
||||
.frame(width: 36, height: 36)
|
||||
.modifier(ComposerActionFrame())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ private extension ContentComposerView {
|
||||
.font(.bitchatSystem(size: 24))
|
||||
.foregroundColor(micColor)
|
||||
.modifier(PulsingOpacityModifier(active: busyTalker != nil && !voiceRecordingVM.state.isActive))
|
||||
.frame(width: 36, height: 36)
|
||||
.modifier(ComposerActionFrame())
|
||||
.contentShape(Circle())
|
||||
.overlay(
|
||||
Color.clear
|
||||
@@ -385,7 +385,7 @@ private extension ContentComposerView {
|
||||
Image(systemName: "arrow.up.circle.fill")
|
||||
.font(.bitchatSystem(size: 24))
|
||||
.foregroundColor(enabled ? activeColor : Color.gray)
|
||||
.frame(width: 36, height: 36)
|
||||
.modifier(ComposerActionFrame())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.disabled(!enabled)
|
||||
@@ -494,3 +494,11 @@ private struct AutocompleteKeyboardNavigationModifier: ViewModifier {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
struct ComposerActionFrame: ViewModifier {
|
||||
// Match the .title2 scaling used by the composer's size-24 icons.
|
||||
@ScaledMetric(relativeTo: .title2) private var scaledSize: CGFloat = 36
|
||||
func body(content: Content) -> some View {
|
||||
content.frame(width: max(36, scaledSize), height: max(36, scaledSize))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#if os(iOS)
|
||||
import XCTest
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
@testable import bitchat
|
||||
|
||||
@MainActor
|
||||
final class ComposerActionFrameTests: XCTestCase {
|
||||
private func measure<V: View>(_ view: V, at size: DynamicTypeSize) -> CGSize {
|
||||
let host = UIHostingController(rootView: view.environment(\.dynamicTypeSize, size))
|
||||
_ = host.view
|
||||
host.view.setNeedsLayout()
|
||||
host.view.layoutIfNeeded()
|
||||
return host.sizeThatFits(in: CGSize(width: 500, height: 500))
|
||||
}
|
||||
|
||||
func testSizingAcrossDynamicType() {
|
||||
for size in DynamicTypeSize.allCases {
|
||||
let frame = measure(
|
||||
Color.clear.modifier(ComposerActionFrame()),
|
||||
at: size
|
||||
)
|
||||
|
||||
XCTAssertGreaterThanOrEqual(frame.width, 36)
|
||||
XCTAssertGreaterThanOrEqual(frame.height, 36)
|
||||
|
||||
if size <= .large {
|
||||
XCTAssertEqual(frame.width, 36, accuracy: 0.5)
|
||||
XCTAssertEqual(frame.height, 36, accuracy: 0.5)
|
||||
}
|
||||
|
||||
for symbol in [
|
||||
"camera.circle.fill",
|
||||
"mic.circle.fill",
|
||||
"arrow.up.circle.fill"
|
||||
] {
|
||||
let icon = Image(systemName: symbol)
|
||||
.font(.bitchatSystem(size: 24))
|
||||
let natural = measure(icon.fixedSize(), at: size)
|
||||
let allocation = measure(
|
||||
icon.modifier(ComposerActionFrame()),
|
||||
at: size
|
||||
)
|
||||
let context = "\(symbol) at \(size)"
|
||||
|
||||
XCTAssertGreaterThanOrEqual(
|
||||
allocation.width + 0.5,
|
||||
natural.width,
|
||||
"Frame must contain \(context)"
|
||||
)
|
||||
XCTAssertGreaterThanOrEqual(
|
||||
allocation.height + 0.5,
|
||||
natural.height,
|
||||
"Frame must contain \(context)"
|
||||
)
|
||||
|
||||
if size == .accessibility5 {
|
||||
XCTAssertGreaterThan(
|
||||
natural.width, 36,
|
||||
"Fixture must exercise an enlarged icon"
|
||||
)
|
||||
XCTAssertGreaterThan(
|
||||
natural.height, 36,
|
||||
"Fixture must exercise an enlarged icon"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user