Complete Android lifecycle and phone UI fixes for external build handoff
This commit is contained in:
1 parent
cb1d682dfb
commit
3d2e76eddd
31 files changed
+790
-129
No files matched your search
+18
-6
@@ -222,13 +222,15 @@ export component ChatScreen inherits Rectangle {
|
||||
private property <bool> show-tools;
|
||||
private property <bool> show-emoji;
|
||||
private property <bool> show-search;
|
||||
private property <bool> typing: Theme.android && Theme.ime-inset > 0px;
|
||||
private property <length> caret-y;
|
||||
// Measure the allocated viewport; composer constraints must not size their own parent.
|
||||
private property <length> allocated-height;
|
||||
changed height => { allocated-height = self.height; }
|
||||
changed width => { ChatBridge.layout(max(16, (root.width - 32px) / 1px), max(16, (root.width - 40px) / 1px)); }
|
||||
VerticalLayout {
|
||||
spacing: 0px;
|
||||
if ChatBridge.tabs.length > 0: ScrollView {
|
||||
if ChatBridge.tabs.length > 0 && !root.typing: ScrollView {
|
||||
height: Theme.touch-target; vertical-stretch: 0;
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
@@ -239,7 +241,7 @@ export component ChatScreen inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
if !root.typing: HorizontalLayout {
|
||||
padding: 8px; spacing: 8px; height: 52px;
|
||||
Text { text: ChatBridge.title; color: Theme.fg; font-family: Theme.font-family; font-size: 18px; font-weight: 700; overflow: elide; vertical-alignment: center; horizontal-stretch: 1; }
|
||||
if ChatBridge.can-info: ActionButton { text: ChatBridge.tr("admin.info"); clicked => { ChatBridge.client-info(); } }
|
||||
@@ -250,7 +252,7 @@ export component ChatScreen inherits Rectangle {
|
||||
TextField { text <=> ChatBridge.search; placeholder: ChatBridge.tr("admin.search"); accepted => { ChatBridge.search-history(ChatBridge.search); } }
|
||||
ActionButton { text: ChatBridge.tr("admin.search"); clicked => { ChatBridge.search-history(ChatBridge.search); } }
|
||||
}
|
||||
if ChatBridge.has-older || ChatBridge.older-page || ChatBridge.loading: HorizontalLayout {
|
||||
if !root.typing && (ChatBridge.has-older || ChatBridge.older-page || ChatBridge.loading): HorizontalLayout {
|
||||
padding-left: 12px; padding-right: 12px; spacing: 8px;
|
||||
if ChatBridge.has-older: ActionButton { text: ChatBridge.tr("chat.history.older"); enabled: !ChatBridge.loading; clicked => { ChatBridge.history(false); } }
|
||||
if ChatBridge.older-page: ActionButton { text: ChatBridge.tr("chat.history.latest"); enabled: !ChatBridge.loading; clicked => { ChatBridge.history(true); } }
|
||||
@@ -280,7 +282,7 @@ export component ChatScreen inherits Rectangle {
|
||||
if ChatBridge.error != "": Text { text: ChatBridge.error; color: Theme.error; wrap: word-wrap; font-family: Theme.font-family; font-size: 13px; accessible-role: text; }
|
||||
composer := Rectangle {
|
||||
background: Theme.bg; border-radius: 8px; border-width: 1px; border-color: input.has-focus ? Theme.tint : Theme.outline;
|
||||
min-height: 92px; max-height: max(120px, root.allocated-height * 0.55); vertical-stretch: 0;
|
||||
min-height: 92px; max-height: Theme.android ? max(120px, root.allocated-height) : max(120px, root.allocated-height * 0.55); vertical-stretch: 0;
|
||||
VerticalLayout {
|
||||
padding: 8px; spacing: 4px;
|
||||
if ChatBridge.toolbar-visible && (!ChatBridge.toolbar-dynamic || input.has-focus || root.show-tools || root.show-emoji): HorizontalLayout {
|
||||
@@ -295,17 +297,23 @@ export component ChatScreen inherits Rectangle {
|
||||
Toggle { label: ChatBridge.tr("settings.chat.text_edit.rich_text"); checked <=> ChatBridge.hybrid; enabled: !ChatBridge.composing; toggled(value) => { ChatBridge.set-hybrid(value); } }
|
||||
}
|
||||
if root.show-tools: ListView {
|
||||
height: 160px;
|
||||
height: Theme.android ? clamp(root.allocated-height - 240px, 48px, 160px) : 160px;
|
||||
for tool in ChatBridge.tools: ActionButton { text: tool.label; enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.format(tool.id); root.show-tools = false; } }
|
||||
}
|
||||
if root.show-emoji: TextField { text <=> ChatBridge.emoji-search; placeholder: ChatBridge.tr("chat.emoji.search"); edited(value) => { ChatBridge.emoji(value); } }
|
||||
if ChatBridge.completions.length > 0: ListView {
|
||||
height: min(160px, ChatBridge.completions.length * Theme.touch-target);
|
||||
height: min(Theme.android ? clamp(root.allocated-height - 240px, 48px, 160px) : 160px, ChatBridge.completions.length * Theme.touch-target);
|
||||
for item[index] in ChatBridge.completions: ActionButton { text: item.label; primary: index == ChatBridge.completion-index; clicked => { ChatBridge.complete(index); root.show-emoji = false; } }
|
||||
}
|
||||
editor-scroll := ScrollView {
|
||||
content-width: max(self.visible-width, ChatBridge.editor-width * 1px);
|
||||
min-height: 48px; preferred-height: min(240px, editor-content.height); vertical-stretch: 1;
|
||||
changed visible-height => {
|
||||
if Theme.android && input.has-focus {
|
||||
if root.caret-y + self.content-y < 0px { self.content-y = -root.caret-y; }
|
||||
if root.caret-y + self.content-y > self.visible-height - 24px { self.content-y = min(0px, self.visible-height - root.caret-y - 24px); }
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
spacing: 0px;
|
||||
editor-content := Rectangle {
|
||||
@@ -322,6 +330,7 @@ export component ChatScreen inherits Rectangle {
|
||||
changed preedit-text => { ChatBridge.composing = self.preedit-text != ""; ChatBridge.composition-changed(ChatBridge.composing); }
|
||||
edited => { ChatBridge.draft-edited(self.text, self.anchor-position-byte-offset, self.cursor-position-byte-offset); }
|
||||
cursor-position-changed(point) => {
|
||||
root.caret-y = point.y + self.y;
|
||||
ChatBridge.selection-changed(self.anchor-position-byte-offset, self.cursor-position-byte-offset);
|
||||
if point.y + self.y + editor-scroll.content-y < 0px { editor-scroll.content-y = -point.y - self.y; }
|
||||
if point.y + self.y + editor-scroll.content-y > editor-scroll.visible-height - 24px { editor-scroll.content-y = editor-scroll.visible-height - point.y - self.y - 24px; }
|
||||
@@ -344,6 +353,9 @@ export component ChatScreen inherits Rectangle {
|
||||
if event.text == Key.Return || event.text == Key.Tab { ChatBridge.complete(ChatBridge.completion-index); return accept; }
|
||||
if event.text == Key.Escape { ChatBridge.command("dismiss-completion"); return accept; }
|
||||
}
|
||||
// Android's software keyboard needs an ordinary newline; sending
|
||||
// remains the explicit, composition-safe action below the editor.
|
||||
if Theme.android && event.text == Key.Return && !event.modifiers.shift && !event.modifiers.control && !event.modifiers.meta { return reject; }
|
||||
if event.text == Key.Return { if event.modifiers.shift { if ChatBridge.command("newline") { return accept; } } else { ChatBridge.send(); return accept; } }
|
||||
if event.text == Key.Tab { if ChatBridge.command(event.modifiers.shift ? "outdent" : "indent") { return accept; } }
|
||||
if (event.text == Key.UpArrow || event.text == Key.LeftArrow) && self.cursor-position-byte-offset == 0 { if ChatBridge.command(event.modifiers.shift ? "previous-block-select" : "previous-block") { return accept; } }
|
||||
|
||||
Reference in new issue
Block a user