Move phone screen connection status and warnings to the top bar

<details>
<summary>Prompts Used</summary>
On the main page, there's a triple-dot menu. Its icon is currently black-on-dark (this is true on both a light-mode device and a dark-mode device; the top bark has a dark background in both cases). Make that icon white instead.

We have a connection-status indicator on the main page, that says "Disconnected" or "Connected" or "Reconnecting". Let's move this onto the top-bar, as white text, right-aligned next to the triple-dot menu.

We have several problem-status warnings, eg for not having battery-optimization permission, that appear on the main page in the form of a large button below the screen preview. Let's convert all of thes into a yellow triangle ! icon that appears on the top bar, in between the connection-status indicator and the triple-dot menu. Tapping it will open a modal that shows the message that was previously shown, with a button to do the suggested action.

> All three changes are in, and the project builds and typechecks cleanly. Here's what I did:
>
> **White overflow icon** — The root cause is that NativeScript builds its toolbar programmatically, so the `theme` overlay in `NativeScriptToolbarStyle` (an XML-inflation-time attribute) never applied, and the overflow icon fell back to the light activity theme's dark `textColorSecondary`. I added an `actionOverflowButtonStyle` with a white `android:tint` to `AppThemeBase` in `App_Resources/Android/src/main/res/values/styles.xml`, so the icon is white on every page's bar (they all share the dark #424242 background), in both light and dark device themes.
>
> **Connection status in the top bar** — The ActionBar now has a custom titleView (`main-page.xml:5`): "Faceclaw" on the left, and a right-aligned white status label next to the menu. Since the old status string could be a whole sentence ("Reconnecting after ...", "Failed: ..."), the bar shows a short label derived from the connection phase — Connected / Connecting / Reconnecting / Disconnected / Charging / Disconnecting / Failed — and tapping it opens an alert with the full status message, so failure details aren't lost. The old status label below the controls is removed.
>
> **Warnings → ⚠️ icon + modal** — The three inline warning blocks (Even-app conflict, firmware, battery optimization) are gone from the page body in both portrait and landscape. A yellow warning-triangle emoji now sits between the status label and the overflow menu whenever any warning is active. Tapping it opens an in-page modal (same overlay pattern as the existing text-setting editor) titled "Attention needed", listing each active warning with its original message and action button, plus a Close button. The modal closes when you take an action, and auto-closes if the last warning clears while it's open. One side effect: the landscape layout previously showed the firmware warning without its install button — in the modal it now has the button like everything else.
>
> Worth an on-device check: the overflow-icon tint (theme change, so a full reinstall rather than hot reload), and that the titleView labels sit vertically centered against the toolbar height.
<hr>
Thanks. That all looks good, except there are some stylign issues on the warning modal. On a wide tablet, the modal is full-width, which is too wide. When the device is dark-mode, the "Attention needed" title is white-on-light-gray. The title and the warning text need some left/right padding between them and the edges of the modal.

> All three styling issues are fixed and the build is clean:
>
> - **Too wide on tablets**: the modal's width now comes from a `warningsModalWidth` getter in the view model — screen width minus the margins on phones, capped at 480 DIPs on tablets — and it's centered horizontally. It re-computes on orientation change along with the other layout metrics.
> - **White title in dark mode**: the theme's `.ns-dark .h2` rule was beating my `.warnings-modal Label` rule on specificity. I added a `.ns-dark .warnings-modal Label` selector so all text in the modal stays dark-on-light in both modes (the modal deliberately keeps its light look, matching the text-setting modal).
> - **Missing edge padding**: NativeScript ScrollViews don't apply their own padding to their content, so the `padding: 16` on the modal was silently doing nothing. It now lives on an inner `warnings-modal-content` StackLayout; the border/background/margin stay on the ScrollView.
>
> One note: the text-setting editor modal (`system-name-modal`) uses the same `h2`-on-light-background pattern, so its title likely has the same white-on-light problem in dark mode — I left it alone since you only flagged the warnings modal, but it'd be the same one-line fix if you want it.
</details>
This commit is contained in:
James Babcock committed 2026-08-25 23:09:21 -07:00
1 parent b33d858fbc
commit b99aa85964
4 files changed
+183 -36

No files matched your search

+53
View File
@@ -15,6 +15,29 @@ ActionItem {
color: #ffffff;
}
/* The main page's custom titleView: title left, connection status and the
* warning triangle right-aligned beside the overflow menu. */
.action-bar-title {
color: #ffffff;
font-size: 18;
font-weight: bold;
vertical-align: center;
}
.action-bar-status {
color: #ffffff;
font-size: 14;
margin-right: 12;
vertical-align: center;
}
/* The emoji brings its own yellow; the padding widens the tap target. */
.action-bar-warning {
font-size: 18;
padding: 4 6;
vertical-align: center;
}
TextField {
background-color: #ffffff;
color: #222222;
@@ -102,6 +125,36 @@ Button.-primary {
border-radius: 8;
}
/* Modal behind the action bar's warning triangle: the problem-status warnings
* that used to sit inline on the main page, each with its fix-it button.
* The width is set from the view model (near-full-width on phones, capped on
* tablets); the padding lives on the content stack because a ScrollView does
* not apply its own padding to its content. */
.warnings-modal {
margin: 16;
background-color: #f6f6f6;
color: #222222;
border-color: #222222;
border-width: 1;
border-radius: 8;
}
.warnings-modal-content {
padding: 16;
}
/* The modal stays light in dark mode; the .ns-dark pairing outguns the
* theme's dark-mode recolour of Label/.h2 so the title doesn't go
* white-on-light-gray. */
.warnings-modal Label,
.ns-dark .warnings-modal Label {
color: #222222;
}
.warnings-modal-item {
margin-bottom: 12;
}
/* The phone's controller for the glasses (phone-ui/remote-controls.xml). */
.remote-controls {
margin: 0 8 0 8;
+37 -36
View File
@@ -1,5 +1,12 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:rc="phone-ui" navigatingTo="navigatingTo" loaded="loaded" unloaded="unloaded">
<ActionBar title="Faceclaw">
<ActionBar>
<!-- Custom titleView: app title on the left; connection status and the
warning-triangle indicator right-aligned beside the overflow menu. -->
<GridLayout columns="auto,*,auto,auto" width="100%" verticalAlignment="center">
<Label col="0" text="Faceclaw" class="action-bar-title" />
<Label col="2" text="{{ connectionStatusLabel }}" tap="{{ onConnectionStatusTap }}" class="action-bar-status" />
<Label col="3" text="&#x26A0;&#xFE0F;" tap="{{ onWarningIconTap }}" visibility="{{ warningIconVisibility }}" class="action-bar-warning" />
</GridLayout>
<ActionItem text="{{ buttonLabel }}" tap="{{ onTap }}" isEnabled="{{ connectItemEnabled }}" android.position="popup" />
<ActionItem text="Pair glasses" tap="{{ onPairGlassesTap }}" isEnabled="{{ canRun }}" android.position="popup" />
<ActionItem text="Configure devices" tap="{{ onConfigureTap }}" isEnabled="{{ canRun }}" android.position="popup" />
@@ -22,42 +29,14 @@
visibility="{{ displayPreviewMessageVisibility }}">
<Label text="{{ displayPreviewMessage }}" textWrap="true" horizontalAlignment="center" verticalAlignment="center" />
</GridLayout>
<GridLayout row="1" rows="auto,auto,auto" class="p-20">
<StackLayout row="0" class="m-b-8">
<StackLayout visibility="{{ evenAppConflictWarningVisibility }}">
<Label text="{{ evenAppConflictMessage }}" textWrap="true" />
<Button text="Open Even app settings" tap="{{ onOpenEvenAppSettingsTap }}" class="-primary" />
</StackLayout>
<StackLayout visibility="{{ firmwareWarningVisibility }}">
<Label text="{{ firmwareWarningMessage }}" textWrap="true" />
<Button text="Install custom firmware" tap="{{ onInstallFirmwareTap }}" class="-primary" />
</StackLayout>
<StackLayout visibility="{{ batteryOptimizationWarningVisibility }}">
<Label text="Android will slow Faceclaw to a crawl when the phone screen is off unless it is exempt from battery optimization." textWrap="true" />
<Button text="Allow unrestricted background usage" tap="{{ onAllowBackgroundUsageTap }}" class="-primary" />
</StackLayout>
</StackLayout>
<StackLayout row="1">
<rc:remote-controls />
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
</StackLayout>
<Label row="2" text="{{ status }}" class="m-t-16" textWrap="true" />
</GridLayout>
<StackLayout row="1" class="p-20">
<rc:remote-controls />
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
</StackLayout>
</GridLayout>
<GridLayout rows="auto,*" class="p-20" visibility="{{ landscapeLayoutVisibility }}">
<StackLayout row="0" class="m-b-8">
<StackLayout visibility="{{ evenAppConflictWarningVisibility }}">
<Label text="{{ evenAppConflictMessage }}" textWrap="true" />
<Button text="Open Even app settings" tap="{{ onOpenEvenAppSettingsTap }}" class="-primary" />
</StackLayout>
<Label text="{{ firmwareWarningMessage }}" textWrap="true" visibility="{{ firmwareWarningVisibility }}" />
<StackLayout visibility="{{ batteryOptimizationWarningVisibility }}">
<Label text="Android will slow Faceclaw to a crawl when the phone screen is off unless it is exempt from battery optimization." textWrap="true" />
<Button text="Allow unrestricted background usage" tap="{{ onAllowBackgroundUsageTap }}" class="-primary" />
</StackLayout>
</StackLayout>
<GridLayout row="1" rows="auto,auto" columns="*,360">
<GridLayout class="p-20" visibility="{{ landscapeLayoutVisibility }}">
<GridLayout rows="auto" columns="*,360">
<StackLayout row="0" col="0" visibility="{{ displayPreviewVisibility }}" horizontalAlignment="left">
<Image
src="{{ displayPreview }}"
@@ -80,9 +59,31 @@
<rc:remote-controls />
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
</StackLayout>
<Label row="1" col="0" colSpan="2" text="{{ status }}" class="m-t-16" textWrap="true" />
</GridLayout>
</GridLayout>
<ScrollView
class="warnings-modal"
visibility="{{ warningsModalVisibility }}"
width="{{ warningsModalWidth }}"
horizontalAlignment="center"
verticalAlignment="center">
<StackLayout class="warnings-modal-content">
<Label text="Attention needed" class="h2" />
<StackLayout visibility="{{ evenAppConflictWarningVisibility }}" class="warnings-modal-item">
<Label text="{{ evenAppConflictMessage }}" textWrap="true" />
<Button text="Open Even app settings" tap="{{ onOpenEvenAppSettingsTap }}" class="-primary" />
</StackLayout>
<StackLayout visibility="{{ firmwareWarningVisibility }}" class="warnings-modal-item">
<Label text="{{ firmwareWarningMessage }}" textWrap="true" />
<Button text="Install custom firmware" tap="{{ onInstallFirmwareTap }}" class="-primary" />
</StackLayout>
<StackLayout visibility="{{ batteryOptimizationWarningVisibility }}" class="warnings-modal-item">
<Label text="Android will slow Faceclaw to a crawl when the phone screen is off unless it is exempt from battery optimization." textWrap="true" />
<Button text="Allow unrestricted background usage" tap="{{ onAllowBackgroundUsageTap }}" class="-primary" />
</StackLayout>
<Button text="Close" tap="{{ onWarningsModalCloseTap }}" />
</StackLayout>
</ScrollView>
<StackLayout
class="system-name-modal"
visibility="{{ textSettingEditorVisibility }}"
+82
View File
@@ -54,6 +54,7 @@ export class MainViewModel extends Observable {
private _firmwareWarningVisible = false;
private _screenRecordingActive = false;
private _batteryOptimizationWarningVisible = false;
private _warningsModalVisible = false;
private _phase: "disconnected" | "connecting" | "connected" | "charging" | "disconnecting" = "disconnected";
// A new view model is built on every navigation to the main page; these
@@ -115,9 +116,36 @@ export class MainViewModel extends Observable {
if (this._status !== value) {
this._status = value;
this.notifyPropertyChange("status", value);
this.notifyPropertyChange("connectionStatusLabel", this.connectionStatusLabel);
}
}
/**
* Short connection indicator for the action bar. The full status string
* (which can be a sentence, e.g. a failure reason) stays available by
* tapping the indicator.
*/
get connectionStatusLabel(): string {
switch (this._phase) {
case "connected":
return "Connected";
case "charging":
return "Charging";
case "disconnecting":
return "Disconnecting";
case "connecting":
// The transport reports retry loops as "Reconnecting..." with the
// phase still "connecting"; keep that distinction visible.
return this._status.startsWith("Reconnecting") ? "Reconnecting" : "Connecting";
default:
return this._status.startsWith("Failed") ? "Failed" : "Disconnected";
}
}
onConnectionStatusTap(): void {
void Dialogs.alert({ title: "Connection status", message: this._status, okButtonText: "OK" });
}
get displayPreview(): ImageSource | null {
return this._displayPreview;
}
@@ -179,6 +207,11 @@ export class MainViewModel extends Observable {
return Math.floor(availableWidth / 2);
}
/** Near-full-width on phones, capped on tablets (the 32 clears the 16 margins). */
get warningsModalWidth(): number {
return Math.min(Screen.mainScreen.widthDIPs - 32, 480);
}
get portraitLayoutVisibility(): "visible" | "collapse" {
return this._layoutOrientation === "portrait" ? "visible" : "collapse";
}
@@ -197,6 +230,7 @@ export class MainViewModel extends Observable {
this.notifyPropertyChange("displayPreviewHeight", this.displayPreviewHeight);
this.notifyPropertyChange("landscapeDisplayPreviewWidth", this.landscapeDisplayPreviewWidth);
this.notifyPropertyChange("landscapeDisplayPreviewHeight", this.landscapeDisplayPreviewHeight);
this.notifyPropertyChange("warningsModalWidth", this.warningsModalWidth);
}
get activeTextSettingId(): string | null {
@@ -361,6 +395,7 @@ export class MainViewModel extends Observable {
this._evenAppConflictWarningVisible = value;
this.notifyPropertyChange("evenAppConflictWarningVisible", value);
this.notifyPropertyChange("evenAppConflictWarningVisibility", this.evenAppConflictWarningVisibility);
this.refreshWarningIndicator();
}
}
@@ -388,6 +423,7 @@ export class MainViewModel extends Observable {
this._firmwareWarningVisible = value;
this.notifyPropertyChange("firmwareWarningVisible", value);
this.notifyPropertyChange("firmwareWarningVisibility", this.firmwareWarningVisibility);
this.refreshWarningIndicator();
}
}
@@ -444,6 +480,7 @@ export class MainViewModel extends Observable {
this._batteryOptimizationWarningVisible = value;
this.notifyPropertyChange("batteryOptimizationWarningVisible", value);
this.notifyPropertyChange("batteryOptimizationWarningVisibility", this.batteryOptimizationWarningVisibility);
this.refreshWarningIndicator();
}
}
@@ -452,9 +489,51 @@ export class MainViewModel extends Observable {
}
onAllowBackgroundUsageTap(): void {
this.setWarningsModalVisible(false);
dashboardController.requestBatteryOptimizationExemption();
}
// ---- the action bar's warning triangle and the modal behind it ----
get anyWarningVisible(): boolean {
return (
this._evenAppConflictWarningVisible ||
this._firmwareWarningVisible ||
this._batteryOptimizationWarningVisible
);
}
get warningIconVisibility(): "visible" | "collapse" {
return this.anyWarningVisible ? "visible" : "collapse";
}
get warningsModalVisibility(): "visible" | "collapse" {
return this._warningsModalVisible ? "visible" : "collapse";
}
onWarningIconTap(): void {
this.setWarningsModalVisible(true);
}
onWarningsModalCloseTap(): void {
this.setWarningsModalVisible(false);
}
private setWarningsModalVisible(value: boolean): void {
if (this._warningsModalVisible !== value) {
this._warningsModalVisible = value;
this.notifyPropertyChange("warningsModalVisibility", this.warningsModalVisibility);
}
}
private refreshWarningIndicator(): void {
this.notifyPropertyChange("warningIconVisibility", this.warningIconVisibility);
// Don't leave the modal open showing nothing once the last warning clears.
if (!this.anyWarningVisible) {
this.setWarningsModalVisible(false);
}
}
get phase(): "disconnected" | "connecting" | "connected" | "charging" | "disconnecting" {
return this._phase;
}
@@ -466,6 +545,7 @@ export class MainViewModel extends Observable {
this.notifyPropertyChange("buttonLabel", this.buttonLabel);
this.notifyPropertyChange("canRun", this.canRun);
this.notifyPropertyChange("connectItemEnabled", this.connectItemEnabled);
this.notifyPropertyChange("connectionStatusLabel", this.connectionStatusLabel);
}
}
@@ -565,6 +645,7 @@ export class MainViewModel extends Observable {
}
async onInstallFirmwareTap(): Promise<void> {
this.setWarningsModalVisible(false);
await this.openFlashPage("install");
}
@@ -624,6 +705,7 @@ export class MainViewModel extends Observable {
}
onOpenEvenAppSettingsTap(): void {
this.setWarningsModalVisible(false);
dashboardController.openEvenAppSettings();
}