Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions desktop/ox-mobile/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ and build surfaces with the shared primitives in `src/arcade.rs`:
| `arcade::eyebrow(palette, Tone::*, "LABEL", cx)` | Uppercase monospaced role/card eyebrow (`YOU`, `AGENT`, `PLAN`, `COMMAND`, `FILES`, `PROJECT`). |
| `arcade::cartridge(palette, kind, vivid)` | 7×7 provider/worker icon (`arcade::cartridge_for_route(&route)` or `Cartridge::Worker`). |
| `arcade::marquee(palette, hot, compact)` | Pixel OX cabinet marquee — root headers (`Home`) and the `Pair` hero only; never duplicate on the same screen. |
| `arcade::runner::Runner` | Animated 8-fps desktop pixel scenes (Pong, lightbulb, reading, building, testing, `INSERT COIN`, `HIGH SCORE`, UFO tap easter egg). Automatically pauses when inactive or when iOS Reduce Motion is enabled. |
| `arcade::runner::Runner` | Animated 8-fps desktop pixel scenes (Pong, lightbulb, reading, building, testing, `INSERT COIN`, `HIGH SCORE`, UFO tap easter egg). Automatically pauses when inactive or when the phone or this app asks for reduced motion. |

## 2. Semantic color roles (Dark & Light)

Expand Down Expand Up @@ -61,8 +61,10 @@ and always pair color with visible text.
- **Safe areas & keyboards:** Native iOS chrome (`App.m`, `Composer.m`, `QRScanner.m`)
must use dynamic `UIColor colorWithDynamicProvider:` with the exact OX Arcade Dark/Light
hex values and constrain to `safeAreaLayoutGuide` / `keyboardLayoutGuide`.
- **Reduce Motion:** Any animation in Rust or Objective-C must honor
`arcade::reduce_motion_enabled()` / `UIAccessibilityIsReduceMotionEnabled()` and fall
back to a crisp still frame or non-animated transition.
- **Reduce Motion:** Rust animation reads `Palette::motion`, which combines the phone's
setting with this app's `preferences::ReduceMotion` choice. The app follows the phone
by default and can ask for reduced motion. The same choice sets GPUI's motion flag
for component transitions. Objective-C uses `UIAccessibilityIsReduceMotionEnabled()`.
Use a crisp still frame or non-animated transition when motion is reduced.
- **Restraint:** No scanlines, glow, gradients over content, blurred drop shadows, or
sentence-length pixel labels. Keep uppercase monospaced labels to 1–4 words.
53 changes: 17 additions & 36 deletions desktop/ox-mobile/src/arcade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ fn android_animators_enabled() -> Option<bool> {
.ok()
}

#[cfg(target_os = "ios")]
pub(crate) fn phone_motion_allowed() -> Option<bool> {
Some(!reduce_motion_enabled())
}

#[cfg(target_os = "android")]
pub(crate) fn phone_motion_allowed() -> Option<bool> {
android_animators_enabled()
}

#[cfg(any(target_os = "ios", target_os = "android"))]
mod gpui_impl {
use super::*;
Expand All @@ -293,24 +303,9 @@ mod gpui_impl {
}
}

#[cfg(target_os = "ios")]
pub(crate) fn refresh_ios_motion(cx: &mut App) -> bool {
let mut palette = Palette::get(cx);
let motion = !reduce_motion_enabled();
if palette.motion == motion {
return false;
}
palette.motion = motion;
cx.set_global(palette);
true
}

#[cfg(target_os = "android")]
pub(crate) fn refresh_android_motion(cx: &mut App) -> bool {
pub(crate) fn refresh_motion(cx: &mut App, motion: bool) -> bool {
let mut palette = Palette::get(cx);
let Some(motion) = android_animators_enabled() else {
return false;
};
cx.set_reduce_motion(!motion);
if palette.motion == motion {
return false;
}
Expand All @@ -322,21 +317,10 @@ mod gpui_impl {
/// Apply the OX Arcade house palette across every `gpui_component` token so
/// every screen, button, input, card, list, and switch shares one cohesive
/// dark or light arcade visual language.
pub(crate) fn apply_theme(cx: &mut App, dark: bool, font_size: f32) {
pub(crate) fn apply_theme(cx: &mut App, dark: bool, font_size: f32, motion: bool) {
let mut palette = Palette::house(!dark);
#[cfg(target_os = "ios")]
{
palette.motion = !reduce_motion_enabled();
}
#[cfg(target_os = "android")]
{
// Seed motion before the first frame, then retain it across theme changes.
palette.motion = cx
.try_global::<Palette>()
.map(|current| current.motion)
.or_else(android_animators_enabled)
.unwrap_or(false);
}
palette.motion = motion;
cx.set_reduce_motion(!motion);
Theme::change(
if dark {
ThemeMode::Dark
Expand Down Expand Up @@ -946,15 +930,12 @@ mod gpui_impl {
}
}

#[cfg(target_os = "android")]
pub(crate) use gpui_impl::refresh_android_motion;
#[cfg(target_os = "ios")]
pub(crate) use gpui_impl::refresh_ios_motion;
#[cfg(any(target_os = "ios", target_os = "android"))]
#[allow(unused_imports)]
pub(crate) use gpui_impl::{
apply_font_size, apply_theme, banner, card, cartridge, eyebrow, flame, marquee, mono_well, ox,
primary_keycap, section_rule, selectable_card, status_pill, tab_icon, tappable_card,
primary_keycap, refresh_motion, section_rule, selectable_card, status_pill, tab_icon,
tappable_card,
};

#[cfg(test)]
Expand Down
95 changes: 84 additions & 11 deletions desktop/ox-mobile/src/mobile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::arcade::{
runner::Runner,
scene::{self, Scene},
};
#[cfg(target_os = "ios")]
use crate::device_auth;
use crate::host_details;
#[cfg(target_os = "ios")]
use crate::ios_composer;
Expand All @@ -15,7 +17,7 @@ use crate::ios_qr as qr;
use crate::key_transfer;
#[cfg(target_os = "android")]
use crate::native_transcript;
use crate::preferences::{self, Appearance, TextSize};
use crate::preferences::{self, Appearance, ReduceMotion, TextSize};
use crate::{
catalog, composer_mentions, destination_review, handoff, host_connection, keyboard_on_tap,
move_destinations, move_open, move_status,
Expand All @@ -42,6 +44,7 @@ use gpui_component::{
checkbox::Checkbox,
input::{Input, InputEvent, InputState},
scroll::ScrollableElement as _,
switch::Switch,
text::TextView,
};
use ox_desk_core::{
Expand All @@ -67,8 +70,6 @@ use std::{
rc::Rc,
time::Instant,
};
#[cfg(target_os = "ios")]
use {crate::device_auth, gpui_component::switch::Switch};

use crate::{
devices,
Expand Down Expand Up @@ -398,6 +399,11 @@ pub(crate) struct Mobile {
text_size_back: Screen,
#[cfg(target_os = "android")]
_text_scale_events: Task<()>,
/// This phone's own motion choice. It can reduce motion, never restore it
/// over the phone's accessibility setting.
reduce_motion: ReduceMotion,
// Read on the event loop. Android must call Java from the native stack.
phone_motion_allowed: Option<bool>,
enter_key: EnterKey,
enter_key_back: Screen,
conversation_back: Screen,
Expand Down Expand Up @@ -630,6 +636,8 @@ impl Mobile {
pub(crate) fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
let appearance = preferences::load_appearance();
let text_size = preferences::load_text_size();
let reduce_motion = preferences::load_reduce_motion();
let phone_motion_allowed = arcade::phone_motion_allowed();
let enter_key = preferences::load_enter_key();
#[cfg(target_os = "android")]
let text_scale_events = {
Expand Down Expand Up @@ -899,6 +907,8 @@ impl Mobile {
text_size_back: Screen::Pair,
#[cfg(target_os = "android")]
_text_scale_events: text_scale_events,
reduce_motion,
phone_motion_allowed,
enter_key,
enter_key_back: Screen::Pair,
conversation_back: Screen::Sessions,
Expand Down Expand Up @@ -1104,20 +1114,16 @@ impl Mobile {
cx.observe_window_appearance(window, |app, _, cx| app.sync_platform_appearance(cx));
let scene_activated = cx.observe_window_activation(window, |app, window, cx| {
if window.is_window_active() {
#[cfg(target_os = "ios")]
if arcade::refresh_ios_motion(cx) {
app.arcade_runner.update(cx, Runner::motion_changed);
}
#[cfg(target_os = "android")]
{
app.sync_android_text_size(cx);
if let Some(entry) = &app.native_transcript_entry {
native_transcript::set_entry(entry.ticket);
}
if arcade::refresh_android_motion(cx) {
app.arcade_runner.update(cx, Runner::motion_changed);
}
}
app.phone_motion_allowed =
arcade::phone_motion_allowed().or(app.phone_motion_allowed);
app.refresh_motion(cx);
app.sync_platform_appearance(cx);
app.recovery.activated();
cx.notify();
Expand Down Expand Up @@ -6222,6 +6228,7 @@ impl Mobile {
let display = arcade::card(palette)
.child(self.text_size_button(cx))
.child(self.appearance_button(cx))
.child(self.reduce_motion_setting("pair-reduce-motion", cx))
.child(self.enter_key_button(cx))
.child(
button("pair-input-test", "Input test")
Expand Down Expand Up @@ -6500,6 +6507,71 @@ impl Mobile {
}))
}

/// A switch whose on state means motion is reduced, either by this phone
/// or by the app's own choice. The phone's setting is authoritative, so
/// the switch cannot turn motion back on while it is active.
fn reduce_motion_setting(&self, id: &'static str, cx: &mut Context<Self>) -> impl IntoElement {
let palette = Palette::get(cx);
let phone_reduces = self.phone_motion_allowed == Some(false);
let next = if self.reduce_motion.reduces() {
ReduceMotion::System
} else {
ReduceMotion::Reduced
};
div()
.id((id, 0_u32))
.flex()
.flex_col()
.justify_center()
.gap(px(2.))
.min_h(px(arcade::TOUCH_TARGET))
.when(!phone_reduces, |row| {
row.on_click(cx.listener(move |app, _, _, cx| app.set_reduce_motion(next, cx)))
})
.child(
Switch::new(id)
.label("Reduce motion")
.checked(self.reduce_motion.reduces() || phone_reduces)
.disabled(phone_reduces)
.on_change(cx.listener(move |app, _: &bool, _, cx| {
app.set_reduce_motion(next, cx);
})),
)
.when(phone_reduces, |row| {
row.child(
div()
.text_xs()
.text_color(rgb(palette.muted))
.child("Reduced by this phone's accessibility setting."),
)
})
}

fn set_reduce_motion(&mut self, reduce_motion: ReduceMotion, cx: &mut Context<Self>) {
if self.reduce_motion == reduce_motion {
return;
}
arcade::haptics::trigger(arcade::haptics::Haptic::Light);
self.reduce_motion = reduce_motion;
self.refresh_motion(cx);
self.error = preferences::save_reduce_motion(reduce_motion)
.err()
.map(|_| "Could not save the motion choice for the next launch.".into());
cx.notify();
}

fn motion_allowed(&self) -> bool {
self.reduce_motion
.motion_allowed(self.phone_motion_allowed)
.unwrap_or(false)
}

fn refresh_motion(&mut self, cx: &mut Context<Self>) {
if arcade::refresh_motion(cx, self.motion_allowed()) {
self.arcade_runner.update(cx, Runner::motion_changed);
}
}

fn appearance_screen(&self, cx: &mut Context<Self>) -> impl IntoElement {
let palette = Palette::get(cx);
scroll("appearance")
Expand Down Expand Up @@ -6583,7 +6655,7 @@ impl Mobile {
let dark = self.appearance.resolves_dark(platform_is_dark());
#[cfg(target_os = "ios")]
ios_appearance::apply(self.appearance.ios_style_code());
arcade::apply_theme(cx, dark, self.resolved_font_px());
arcade::apply_theme(cx, dark, self.resolved_font_px(), self.motion_allowed());
#[cfg(target_os = "android")]
set_android_system_chrome(cx, dark);
}
Expand Down Expand Up @@ -7907,6 +7979,7 @@ impl Mobile {
let app_card = arcade::card(palette)
.child(self.text_size_button(cx).w_full())
.child(self.appearance_button(cx).w_full())
.child(self.reduce_motion_setting("settings-reduce-motion", cx))
.child(self.enter_key_button(cx).w_full())
.child(
button("settings-input-test", "Input test")
Expand Down
Loading
Loading