Implement Android Room UI and customizable palette
android-ci / android-arm64 (push) Successful in 17m10s
android-ci / android-arm64 (push) Successful in 17m10s
This commit is contained in:
1 parent
057bfae87c
commit
87265a3e75
26 files changed
+825
-135
No files matched your search
@@ -11,8 +11,8 @@ export component ActionButton inherits Rectangle {
|
||||
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-radius: Theme.android || primary ? self.height / 2 : 4px;
|
||||
background: primary ? (destructive ? Theme.error : Theme.tint) : (Theme.android || touch.has-hover || focus.has-focus ? Theme.bg : transparent);
|
||||
border-width: focus.has-focus || Theme.high-contrast ? 2px : 0px;
|
||||
border-color: Theme.outline;
|
||||
opacity: enabled ? 1 : 0.45;
|
||||
@@ -20,7 +20,7 @@ export component ActionButton inherits Rectangle {
|
||||
accessible-label: text;
|
||||
accessible-enabled: enabled;
|
||||
accessible-action-default => { if root.enabled { root.clicked(); } }
|
||||
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; }
|
||||
label := Text { x: Theme.android ? 12px : 0px; width: parent.width - (Theme.android ? 24px : 0px); text: root.text; color: root.primary ? (Theme.android ? Theme.on-tint : (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; }
|
||||
@@ -31,6 +31,7 @@ export component ActionButton inherits Rectangle {
|
||||
export component TextField inherits Rectangle {
|
||||
in-out property <string> text;
|
||||
in property <string> placeholder;
|
||||
in property <string> label: placeholder;
|
||||
in property <bool> secret: false;
|
||||
in property <bool> enabled: true;
|
||||
out property <bool> has-focus: input.has-focus;
|
||||
@@ -59,7 +60,7 @@ export component TextField inherits Rectangle {
|
||||
selection-foreground-color: Theme.contrast;
|
||||
edited => { root.edited(self.text); }
|
||||
accepted => { root.accepted(); }
|
||||
accessible-label: root.placeholder;
|
||||
accessible-label: root.label;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,3 +135,52 @@ export component Choice inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Android Room controls share one stroke vocabulary and labelled 48dp hit targets.
|
||||
export component RoomIcon inherits Path {
|
||||
in property <string> name;
|
||||
in property <color> ink: Theme.fg;
|
||||
width: 24px; height: 24px;
|
||||
fill: transparent; stroke: ink; stroke-width: 1.8px;
|
||||
commands: name == "back" ? "M19 12H5 M12 5L5 12L12 19"
|
||||
: name == "more" ? "M5 11V13 M12 11V13 M19 11V13"
|
||||
: name == "close" ? "M6 6L18 18 M6 18L18 6"
|
||||
: name == "mic" ? "M9 5A3 3 0 0 1 15 5V12A3 3 0 0 1 9 12Z M5 10V12A7 7 0 0 0 19 12V10 M12 19V22 M9 22H15"
|
||||
: name == "mic-off" ? "M3 3L21 21 M9 9V12A3 3 0 0 0 14 14 M9 5A3 3 0 0 1 15 5V11 M5 10V12A7 7 0 0 0 17 17 M19 12V10 M12 19V22 M9 22H15"
|
||||
: name == "headphones" ? "M4 13V12A8 8 0 0 1 20 12V13 M4 12H3V20H7V12Z M20 12H21V20H17V12Z"
|
||||
: name == "sound-off" ? "M4 9H8L13 5V19L8 15H4Z M17 10L22 15 M17 15L22 10"
|
||||
: name == "chat" ? "M4 4H20V16H9L4 20Z M8 8H16 M8 12H13"
|
||||
: name == "users" ? "M9 12A4 4 0 1 0 9 4A4 4 0 0 0 9 12 M2 21V19A6 6 0 0 1 14 19V21 M17 4A4 4 0 0 1 17 12 M19 15A5 5 0 0 1 22 19V21"
|
||||
: name == "user" ? "M12 12A4 4 0 1 0 12 4A4 4 0 0 0 12 12 M5 21V19A7 7 0 0 1 19 19V21"
|
||||
: name == "settings" ? "M9 3L8 6L5 7L3 10L5 12L4 15L6 18L9 17L12 19L15 17L18 18L20 15L19 12L21 10L19 7L16 6L15 3Z M12 9A3 3 0 1 0 12 15A3 3 0 0 0 12 9"
|
||||
: name == "server" ? "M4 3H20V10H4Z M4 14H20V21H4Z M7 6V7 M7 17V18 M11 6H17 M11 17H17"
|
||||
: name == "screen" ? "M3 4H21V17H3Z M12 17V21 M8 21H16"
|
||||
: name == "down" ? "M6 9L12 15L18 9"
|
||||
: name == "chevron" ? "M9 5L16 12L9 19"
|
||||
: name == "leave" ? "M9 4H4V20H9 M13 7L18 12L13 17 M8 12H21"
|
||||
: name == "send" ? "M3 3L22 12L3 21L7 12Z M7 12H22"
|
||||
: name == "plus" ? "M12 5V19 M5 12H19"
|
||||
: name == "search" ? "M10 17A7 7 0 1 0 10 3A7 7 0 0 0 10 17 M15 15L21 21"
|
||||
: name == "palette" ? "M12 3A9 9 0 1 0 12 21H14A2 2 0 0 0 15 17A2 2 0 0 1 16 13H18A3 3 0 0 0 21 10A9 9 0 0 0 12 3 M7 7V9 M12 5V7 M17 7V9 M6 12V14"
|
||||
: name == "shield" ? "M12 3L20 6V12C20 17 12 21 12 21C12 21 4 17 4 12V6Z"
|
||||
: name == "bell" ? "M5 16H19L17 13V9A5 5 0 0 0 7 9V13Z M10 20H14"
|
||||
: "M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3 M12 10V16 M12 6V8";
|
||||
}
|
||||
|
||||
export component RoomIconButton inherits Rectangle {
|
||||
in property <string> icon;
|
||||
in property <string> label;
|
||||
in property <bool> enabled: true;
|
||||
in property <bool> primary: false;
|
||||
callback clicked();
|
||||
width: 48px; min-height: 48px; preferred-height: 48px; vertical-stretch: 0;
|
||||
border-radius: 12px;
|
||||
background: primary ? Theme.tint : (touch.has-hover || focus.has-focus ? Theme.bg : transparent);
|
||||
border-width: focus.has-focus || Theme.high-contrast ? 2px : 0px;
|
||||
border-color: Theme.outline; opacity: enabled ? 1 : 0.45;
|
||||
accessible-role: button; accessible-label: label; accessible-enabled: enabled;
|
||||
accessible-action-default => { if root.enabled { root.clicked(); } }
|
||||
RoomIcon { name: root.icon; ink: root.primary ? Theme.on-tint : Theme.fg; x: (parent.width - self.width)/2; y: (parent.height - self.height)/2; }
|
||||
focus := FocusScope { enabled: root.enabled; key-pressed(e) => { if e.text == " " || e.text == Key.Return { root.clicked(); return accept; } return reject; } }
|
||||
touch := TouchArea { enabled: root.enabled; clicked => { focus.focus(); root.clicked(); } }
|
||||
}
|
||||
Reference in new issue
Block a user