Adapt complete Android phone UI and fix idle audio and microphone test gates
android-ci / android-arm64 (push) Successful in 17m35s
android-ci / android-arm64 (push) Successful in 17m35s
This commit is contained in:
1 parent
cec86d8e3d
commit
5e2a82b1bb
20 files changed
+976
-201
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { ComboBox } from "std-widgets.slint";
|
||||
import { ComboBox, ScrollView } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
|
||||
export component ActionButton inherits Rectangle {
|
||||
@@ -7,9 +7,10 @@ export component ActionButton inherits Rectangle {
|
||||
in property <bool> primary: false;
|
||||
in property <bool> destructive: false;
|
||||
callback clicked();
|
||||
min-height: Theme.touch-target;
|
||||
min-width: max(Theme.android ? 48px : 44px, label.preferred-width + 24px);
|
||||
preferred-height: Theme.touch-target;
|
||||
min-height: Theme.android ? max(Theme.touch-target, label.preferred-height + 16px) : Theme.touch-target;
|
||||
min-width: Theme.android ? 48px : max(44px, label.preferred-width + 24px);
|
||||
preferred-height: Theme.android ? max(Theme.touch-target, label.preferred-height + 16px) : Theme.touch-target;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
border-radius: primary ? self.height / 2 : 4px;
|
||||
background: primary ? (destructive ? Theme.error : Theme.tint) : (touch.has-hover || focus.has-focus ? Theme.bg : transparent);
|
||||
border-width: focus.has-focus || Theme.high-contrast ? 2px : 0px;
|
||||
@@ -19,7 +20,7 @@ export component ActionButton inherits Rectangle {
|
||||
accessible-label: text;
|
||||
accessible-enabled: enabled;
|
||||
accessible-action-default => { if root.enabled { root.clicked(); } }
|
||||
label := Text { text: root.text; color: root.primary ? (Theme.dark ? Theme.contrast : #fff) : (root.destructive ? Theme.error : Theme.fg); font-family: Theme.font-family; font-size: Theme.font-size; horizontal-alignment: center; vertical-alignment: center; overflow: elide; }
|
||||
label := Text { x: Theme.android ? 12px : 0px; width: parent.width - (Theme.android ? 24px : 0px); text: root.text; color: root.primary ? (Theme.dark ? Theme.contrast : #fff) : (root.destructive ? Theme.error : Theme.fg); font-family: Theme.font-family; font-size: Theme.font-size; horizontal-alignment: center; vertical-alignment: center; wrap: Theme.android ? word-wrap : no-wrap; overflow: elide; }
|
||||
focus := FocusScope {
|
||||
enabled: root.enabled;
|
||||
key-pressed(event) => { if event.text == "\n" || event.text == " " { root.clicked(); return accept; } return reject; }
|
||||
@@ -37,6 +38,7 @@ export component TextField inherits Rectangle {
|
||||
callback accepted();
|
||||
min-height: Theme.touch-target;
|
||||
preferred-height: Theme.touch-target;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
background: Theme.bg;
|
||||
border-radius: 4px;
|
||||
forward-focus: input;
|
||||
@@ -87,18 +89,48 @@ export component Choice inherits Rectangle {
|
||||
in property <bool> enabled: true;
|
||||
in property <string> label;
|
||||
callback selected(int);
|
||||
min-height: Theme.touch-target;
|
||||
preferred-height: Theme.touch-target;
|
||||
min-width: Theme.android ? 48px : 0px;
|
||||
min-height: Theme.android ? mobile.preferred-height : Theme.touch-target;
|
||||
preferred-height: Theme.android ? mobile.preferred-height : Theme.touch-target;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
forward-focus: input;
|
||||
// ComboBox normalizes its local model/index internally. Never let those writes sever
|
||||
// the caller's authoritative selected-index binding during a snapshot/model update.
|
||||
changed current-index => { input.current-index = root.current-index; }
|
||||
changed values => { input.current-index = root.current-index; }
|
||||
input := ComboBox {
|
||||
visible: !Theme.android;
|
||||
width: parent.width; height: parent.height;
|
||||
model: root.values;
|
||||
current-index: root.current-index;
|
||||
enabled: root.enabled;
|
||||
accessible-label: root.label;
|
||||
selected(value) => { root.selected(self.current-index); }
|
||||
}
|
||||
mobile := ActionButton {
|
||||
visible: Theme.android;
|
||||
width: parent.width; height: parent.height;
|
||||
text: root.current-index >= 0 && root.current-index < root.values.length ? root.values[root.current-index] : root.label;
|
||||
enabled: root.enabled && root.values.length > 0;
|
||||
background: Theme.bg; border-width: 1px; border-color: Theme.outline;
|
||||
accessible-label: root.label + ": " + self.text;
|
||||
clicked => { options.show(); }
|
||||
}
|
||||
options := PopupWindow {
|
||||
x: 0px; y: root.height;
|
||||
width: root.width; height: min(240px, root.values.length * Theme.touch-target + 16px);
|
||||
Rectangle {
|
||||
background: Theme.contrast; border-width: 1px; border-color: Theme.outline;
|
||||
ScrollView {
|
||||
width: parent.width; height: parent.height;
|
||||
VerticalLayout {
|
||||
padding: 8px; spacing: 4px; alignment: start;
|
||||
for value[index] in root.values: ActionButton {
|
||||
text: value; primary: root.current-index == index;
|
||||
clicked => { root.current-index = index; root.selected(index); options.close(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user