Commit 07c7646a1e

07c7646a1edd8e6f16f3dae82da19a335ed2b146

parent: 71866044e3

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-22 21:17 UTC

iOS key bar: 44 pt buttons and a height that follows the text size

Ref #221

Layout: unified · split

Changed files (2)
Sources/OrgstarMobile/EditorScreen.swift +34 −5 · view
@@ -805,12 +805,20 @@ struct EditorTextView: UIViewRepresentable {
805 let palette: () -> Void 805 let palette: () -> Void
806 806
807 func makeUIView(context: Context) -> UITextView { 807 func makeUIView(context: Context) -> UITextView {
808 let bar = UIHostingController(rootView: KeyBar(editor: editor, palette: palette)) 808 let bar = UIHostingController(rootView: KeyBar(editor: editor, palette: palette).dynamicTypeSize(...KeyBar.largestSize))
809 bar.view.frame = CGRect(x: 0, y: 0, width: 400, height: 48) 809 bar.view.frame = CGRect(x: 0, y: 0, width: 400, height: 2 * KeyBar.padding + KeyBar.target)
810 bar.view.backgroundColor = .clear 810 bar.view.backgroundColor = .clear
811 bar.sizingOptions = [] 811 // As tall as its buttons: the input accessory takes the intrinsic height.
812 bar.sizingOptions = .intrinsicContentSize
813 bar.safeAreaRegions = []
814 bar.view.autoresizingMask = .flexibleHeight
812 view.inputAccessoryView = bar.view 815 view.inputAccessoryView = bar.view
813 context.coordinator.bar = bar 816 context.coordinator.bar = bar
817 // The bar's height follows the text size.
818 view.registerForTraitChanges([UITraitPreferredContentSizeCategory.self]) { (view: UITextView, _) in
819 view.inputAccessoryView?.invalidateIntrinsicContentSize()
820 view.reloadInputViews()
821 }
814 return view 822 return view
815 } 823 }
816 824
@@ -852,6 +860,12 @@ struct KeyBar: View {
852 ("Code", "chevron.left.forwardslash.chevron.right", "org.emphasize.code"), 860 ("Code", "chevron.left.forwardslash.chevron.right", "org.emphasize.code"),
853 ] 861 ]
854 862
863 /// The bar's buttons are at least 44 points square, scaled with the text size up to here.
864 static let largestSize = DynamicTypeSize.accessibility2
865 static let target: CGFloat = 44
866 static let padding: CGFloat = 4
867 @ScaledMetric(relativeTo: .body) private var size = KeyBar.target
868
855 var body: some View { 869 var body: some View {
856 ScrollView(.horizontal, showsIndicators: false) { 870 ScrollView(.horizontal, showsIndicators: false) {
857 HStack(spacing: 4) { 871 HStack(spacing: 4) {
@@ -870,14 +884,29 @@ struct KeyBar: View {
870 Button("Hide keyboard", systemImage: "keyboard.chevron.compact.down") { editor.textView.resignFirstResponder() } 884 Button("Hide keyboard", systemImage: "keyboard.chevron.compact.down") { editor.textView.resignFirstResponder() }
871 } 885 }
872 .labelStyle(.iconOnly) 886 .labelStyle(.iconOnly)
873 .buttonStyle(.bordered) 887 .buttonStyle(KeyStyle(size: size))
874 .padding(.horizontal, 8) 888 .padding(.horizontal, 8)
875 .padding(.vertical, 6) 889 .padding(.vertical, Self.padding)
876 } 890 }
877 .background(.bar) 891 .background(.bar)
878 } 892 }
879} 893}
880 894
895/// A key bar button: a tinted symbol on a capsule, at least `size` square.
896private struct KeyStyle: ButtonStyle {
897 let size: CGFloat
898
899 func makeBody(configuration: Configuration) -> some View {
900 configuration.label
901 .foregroundStyle(.tint)
902 .padding(.horizontal, 10)
903 .frame(minWidth: size, minHeight: size)
904 .background(.fill.tertiary, in: .capsule)
905 .opacity(configuration.isPressed ? 0.5 : 1)
906 .contentShape(.capsule)
907 }
908}
909
881/// A command's question: text with choices, a date, or fast selection by keys. 910/// A command's question: text with choices, a date, or fast selection by keys.
882struct PromptSheet: View { 911struct PromptSheet: View {
883 let prompt: Prompt 912 let prompt: Prompt
docs/manual/guide/14-ios.org +1 −1 · view
@@ -118,7 +118,7 @@ Table columns with width cookies narrow as on the Mac: =#+STARTUP: shrink= narro
118 118
119** The key bar 119** The key bar
120 120
121A bar above the on-screen keyboard has buttons for Org's keys. Each does what its Emacs key does at the caret, so the arrows promote and demote headings, indent list items, or move table columns, depending on where the caret is. Scroll the bar sideways for more. 121A bar above the on-screen keyboard has buttons for Org's keys. Each does what its Emacs key does at the caret, so the arrows promote and demote headings, indent list items, or move table columns, depending on where the caret is. Scroll the bar sideways for more. Its buttons are at least 44 points high and grow with the text size up to the second accessibility size.
122 122
123| Button | Key | 123| Button | Key |
124|----------------------+-------------| 124|----------------------+-------------|
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form