[fix] adapt iOS keyboard switch widths to localized text

This commit is contained in:
dijunkun
2026-11-01 02:49:59 +08:00
parent 4e2e5b74dd
commit 86d3a8cf72
2 changed files with 5 additions and 2 deletions
@@ -323,6 +323,7 @@ final class RemoteKeyboardInputBar: UIView {
let computerButton = UIButton(type: .system)
computerButton.setTitle(NSLocalizedString("电脑键盘", comment: ""), for: .normal)
computerButton.titleLabel?.font = .systemFont(ofSize: 15, weight: .medium)
computerButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
computerButton.accessibilityLabel = NSLocalizedString("切换到电脑键盘", comment: "")
computerButton.addTarget(self, action: #selector(switchToComputer), for: .touchUpInside)
@@ -337,7 +338,8 @@ final class RemoteKeyboardInputBar: UIView {
row.translatesAutoresizingMaskIntoConstraints = false
addSubview(row)
NSLayoutConstraint.activate([
computerButton.widthAnchor.constraint(equalToConstant: 80),
// Keep the minimum touch width while allowing longer translations.
computerButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 80),
dismissButton.widthAnchor.constraint(equalToConstant: RemoteKeyboardDismissButton.sideLength),
row.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 4),
row.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor, constant: -4),
@@ -855,7 +855,8 @@ private struct RemoteComputerKeyboard: View {
switchKeyboard()
}
.font(.system(size: 15, weight: .medium))
.frame(width: 80, height: 44)
.fixedSize(horizontal: true, vertical: false)
.frame(minWidth: 80, minHeight: 44)
.accessibilityLabel(NSLocalizedString("切换到系统键盘", comment: ""))
if verticalSizeClass == .compact {
pageTabs