Fix wallpaper transparency, Recents setup guide, drawer animation, and widget resizing (#2)
Launcher / test (push) Successful in 1m21s
Launcher / apk (push) Successful in 17s

This commit was merged in pull request #2.
This commit is contained in:
nandi committed 2026-11-23 05:36:23 +00:00
1 parent 2fa7bd745b
commit 3070db4fb4
15 files changed
+1011 -161

No files matched your search

+17 -14
View File
@@ -155,7 +155,7 @@ extern "js" fn fetch_text(url : String, f : (Bool, String) -> Unit) -> Unit =
///|
/// Measure the viewport and the home grid (into `window.__m`); false without a grid.
extern "js" fn measure() -> Bool =
#|() => { const s = document.querySelector(".slots"), h = document.querySelector(".home"); if (!s || !h) return false; const r = s.getBoundingClientRect(); window.__m = [innerWidth, innerHeight, r.left, r.top, r.width, parseFloat(getComputedStyle(h).paddingBottom) || 0]; return true; }
#|() => { const s = document.querySelector(".slots"), h = document.querySelector(".home"); if (!s || !h) return false; const r = s.getBoundingClientRect(); window.__m = [innerWidth, innerHeight, r.left, r.top, r.width, parseFloat(getComputedStyle(h).paddingBottom) || 0, window.scrollY || 0]; return true; }
///|
/// Measurement i: viewport width, height, grid left, top, width, the home's bottom padding.
@@ -172,23 +172,18 @@ extern "js" fn resize_handles() -> String =
#|() => JSON.stringify([...document.querySelectorAll(".resize-handle")].map((h) => { const r = h.getBoundingClientRect(); return [Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)]; }))
///|
/// The drawer covers the page down to this y (px); -1 once it covers the screen, 0 when
/// there is no drawer. `last` is the previous bottom edge, so the answer can run ahead of it.
extern "js" fn drawer_cover(last : Double) -> Double =
#|(last) => { const d = document.querySelector(".drawer"); if (!d) return 0; const b = d.getBoundingClientRect().bottom; if (b >= innerHeight - 1) return -1; return Math.min(innerHeight - 1, Math.max(0, Math.ceil(b + 2 * Math.max(0, b - last)))); }
/// Whether the drawer is open and not animating out.
extern "js" fn drawer_covering() -> Bool =
#|() => !!document.querySelector(".drawer:not(.closing)")
///|
extern "js" fn drawer_bottom() -> Double =
#|() => { const d = document.querySelector(".drawer"); return d ? d.getBoundingClientRect().bottom : 0 }
///|
/// A drawer or sheet over the home screen's widgets (the shell has them step aside).
/// A drawer over the home screen's widgets without a sheet on top (the shell keeps widget views placed while `cover` hides them).
extern "js" fn has_drawer() -> Bool =
#|() => !!document.querySelector(".drawer") && !document.querySelector(".sheet-overlay")
#|() => !!document.querySelector(".drawer:not(.closing)") && !document.querySelector(".sheet-overlay")
///|
extern "js" fn focus_search() -> Unit =
#|() => { const i = document.querySelector(".drawer:not(.picking) .drawer-head input"); if (i) i.focus({ preventScroll: true }) }
#|() => { const i = document.querySelector(".drawer:not(.picking):not(.closing) .drawer-head input"); if (i) i.focus({ preventScroll: true }) }
///|
extern "js" fn blur_active() -> Unit =
@@ -308,8 +303,16 @@ extern "js" fn h_pick_wallpaper() -> Unit =
#|() => window.Android.pickWallpaper()
///|
extern "js" fn h_open_recents() -> Unit =
#|() => window.Android.openRecents()
extern "js" fn h_open_recents() -> Bool =
#|() => window.Android.openRecents() !== false
///|
extern "js" fn h_open_accessibility_settings() -> Unit =
#|() => window.Android.openAccessibilitySettings && window.Android.openAccessibilitySettings()
///|
extern "js" fn h_open_self_app_info() -> Unit =
#|() => window.Android.openSelfAppInfo && window.Android.openSelfAppInfo()
///|
extern "js" fn h_http_get(url : String, tag : Int32) -> Unit =
+65 -25
View File
@@ -20,8 +20,6 @@ priv struct PageState {
mut placed : String
mut excluded : String
mut cover_y : Int32
mut cover_last : Double
mut cover_loop : Bool
mut measured : String
mut touch : (Double, Double, Double)?
mut demo_widget : Int32
@@ -43,8 +41,6 @@ fn PageState::new() -> PageState {
placed: "",
excluded: "[]",
cover_y: 0,
cover_last: 0.0,
cover_loop: false,
measured: "",
touch: None,
demo_widget: 100,
@@ -135,14 +131,31 @@ fn exec(e : @app.Effect) -> Unit {
}
OpenRecents =>
if android {
h_open_recents()
if !h_open_recents() {
dispatch(RecentsUnavailable)
}
} else {
toast("Show open windows")
}
OpenAccessibilitySettings =>
if android {
h_open_accessibility_settings()
} else {
toast("Open Accessibility settings")
}
OpenSelfAppInfo =>
if android {
h_open_self_app_info()
} else {
toast("Open App info")
}
Haptic => h_haptic()
LoadApps =>
fetch_text("apps.json", fn(ok, text) {
dispatch(AppsLoaded(if ok { Some(text) } else { None }))
if ok {
prewarm_app_icons()
}
})
LoadWidgets =>
fetch_text("widgets.json", fn(ok, text) {
@@ -201,11 +214,10 @@ fn render() -> Unit {
}
///|
fn after_render() -> Unit {
fn sync_measure() -> Unit {
let st = state.val
fill_icons()
if measure() {
let key = "\{measured(0)},\{measured(1)},\{measured(2)},\{measured(3)},\{measured(4)},\{measured(5)}"
let key = "\{measured(0)},\{measured(1)},\{measured(2)},\{measured(3)},\{measured(4)},\{measured(5)},\{measured(6)}"
if key != st.measured {
st.measured = key
dispatch(
@@ -216,10 +228,18 @@ fn after_render() -> Unit {
grid_top=measured(3),
grid_w=measured(4),
bottom_pad=measured(5),
scroll_y=measured(6),
),
)
}
}
}
///|
fn after_render() -> Unit {
let st = state.val
fill_icons()
sync_measure()
if is_android() {
place()
cover()
@@ -251,28 +271,38 @@ fn place() -> Unit {
}
///|
/// Native widgets sit above the page, so the drawer can't cover them by itself. While
/// it slides down the shell hides them above its bottom edge each frame, a little ahead
/// of it (by its speed), since the shell trails a frame.
/// Native widgets sit above the page, so the shell hides them while the drawer is open.
fn cover() -> Unit {
let st = state.val
let y = drawer_cover(st.cover_last).to_int()
st.cover_last = drawer_bottom()
let y = if drawer_covering() { -1 } else { 0 }
if y != st.cover_y {
st.cover_y = y
h_cover_widgets(y)
}
if y != 0 && y != -1 && !st.cover_loop {
st.cover_loop = true
request_frame(fn() {
state.val.cover_loop = false
cover()
})
}
}
// ---- icons -------------------------------------------------------------------------
///|
/// Pre-fetch uncached app icons on Android right after apps.json loads so the drawer
/// opens with icons ready instead of popping them in during the first open animation.
fn prewarm_app_icons() -> Unit {
if !h_has_load_icons() {
return
}
let st = state.val
let want : Array[Json] = []
for k in model.icon_keys() {
if !st.icon_src.contains(k) && !st.icon_asked.contains(k) {
st.icon_asked[k] = true
want.push(Json::string(k))
}
}
if want.length() > 0 {
h_load_icons(Json::array(want).stringify())
}
}
///|
/// Each `<img class="icon" data-icon=KEY>` gets its src from here. On a phone the shell
/// draws icons on its own thread and hands them back as data: URIs in batches, so the
@@ -358,6 +388,7 @@ fn is_dragging() -> Bool {
fn wire_events() -> Unit {
listen("document", "pointerdown", true, fn(e) {
if ev_primary(e) {
sync_measure()
feed(Down(x=ev_x(e), y=ev_y(e), chain=parse_chain(ev_chain(e))))
}
})
@@ -416,9 +447,12 @@ fn wire_events() -> Unit {
})
listen("window", "resize", true, fn(_) { schedule_render() })
listen("window", "scroll", true, fn(_) {
if is_android() {
request_frame(place)
}
request_frame(fn() {
sync_measure()
if is_android() {
place()
}
})
})
}
@@ -436,8 +470,14 @@ fn expose_api() -> Unit {
expose0("home", fn() { dispatch(GoHome) })
expose0("back", fn() { dispatch(Back) })
expose1("widgetAdded", fn(id) { dispatch(WidgetAdded(id)) })
expose1("widgetMenu", fn(id) { dispatch(WidgetMenu(id)) })
expose1("widgetGrab", fn(id) { dispatch(WidgetGrab(id)) })
expose1("widgetMenu", fn(id) {
sync_measure()
dispatch(WidgetMenu(id))
})
expose1("widgetGrab", fn(id) {
sync_measure()
dispatch(WidgetGrab(id))
})
expose_dd("widgetDrag", fn(x, y) { dispatch(NativeDrag(x, y)) })
expose_b("widgetDrop", fn(moved) { dispatch(NativeDrop(moved)) })
expose0("place", fn() {
+45 -19
View File
@@ -37,7 +37,7 @@ body {
margin: 0; background: var(--background); color: var(--foreground);
font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased;
}
.light, .dark { background: var(--background); color: var(--foreground); }
.light, .dark { color: var(--foreground); }
button, input { font: inherit; color: inherit; margin: 0; }
button { border: 0; background: none; padding: 0; }
:focus-visible { outline: none; }
@@ -102,7 +102,7 @@ button { border: 0; background: none; padding: 0; }
--bottom: var(--inset-bottom, env(safe-area-inset-bottom, 0px));
--shadow-text: 0 1px 4px rgb(0 0 0 / .6);
}
html, body { background: transparent; }
html, html.dark, html.light, body { background: transparent; }
html.demo { background: linear-gradient(160deg, #1e293b, #4c1d95 55%, #0f172a) fixed; }
body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: transparent;
user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
@@ -157,25 +157,37 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
up or resized (or while its native view is away, e.g. another widget is being resized). */
.widget-slot[data-wid]:not(.lifted):not(.resizing) { background: none; border-color: transparent; }
/* A widget being resized: handles sit just outside its right and bottom edges, where the
native widget view doesn't cover them; the bottom one sits in the gap below the row. */
/* A widget being resized: generous 36-40px handles straddle the widget border (inset enough
to stay inside the viewport on full-width widgets); WidgetView passes edge touches through. */
.widget-slot { position: relative; }
.widget-slot.resizing { z-index: 2; outline: 2px solid rgb(255 255 255 / .85);
outline-offset: 3px; transition: none; }
.resize-handle { position: absolute; z-index: 2; touch-action: none; cursor: nwse-resize; }
.resize-handle::after { content: ""; position: absolute; border-radius: 999px; background: #fff;
box-shadow: 0 1px 6px rgb(0 0 0 / .45); }
.resize-handle[data-edge="r"] { top: 0; bottom: 0; right: -16px; width: 16px; cursor: ew-resize; }
.resize-handle[data-edge="r"]::after { top: 50%; left: 6px; width: 6px; height: 2.5rem; transform: translateY(-50%); }
.resize-handle[data-edge="b"] { left: 0; right: 0; bottom: -1rem; height: 1rem; cursor: ns-resize; }
.resize-handle[data-edge="b"]::after { left: 50%; top: 5px; width: 2.5rem; height: 6px; transform: translateX(-50%); }
.resize-handle[data-edge="rb"] { right: -16px; bottom: -1rem; width: 2.75rem; height: 1rem; }
.resize-handle[data-edge="rb"]::after { right: 4px; top: 1px; width: 14px; height: 14px; border-radius: 4px; }
box-shadow: 0 1px 6px rgb(0 0 0 / .45);
transition: background-color .1s, box-shadow .1s; }
.resize-handle.active::after, .resize-handle:active::after {
background: #93c5fd;
box-shadow: 0 0 0 4px rgb(147 197 253 / .35), 0 2px 8px rgb(0 0 0 / .55);
}
.resize-handle[data-edge="l"] { top: 12px; bottom: 12px; left: -14px; width: 36px; cursor: ew-resize; }
.resize-handle[data-edge="l"]::after { top: 50%; left: 7px; width: 6px; height: 2.25rem; transform: translateY(-50%); }
.resize-handle[data-edge="r"] { top: 12px; bottom: 12px; right: -14px; width: 36px; cursor: ew-resize; }
.resize-handle[data-edge="r"]::after { top: 50%; right: 7px; width: 6px; height: 2.25rem; transform: translateY(-50%); }
.resize-handle[data-edge="t"] { left: 12px; right: 12px; top: -14px; height: 36px; cursor: ns-resize; }
.resize-handle[data-edge="t"]::after { left: 50%; top: 7px; width: 2.25rem; height: 6px; transform: translateX(-50%); }
.resize-handle[data-edge="b"] { left: 12px; right: 12px; bottom: -14px; height: 36px; cursor: ns-resize; }
.resize-handle[data-edge="b"]::after { left: 50%; bottom: 7px; width: 2.25rem; height: 6px; transform: translateX(-50%); }
.resize-handle[data-edge="rb"] { right: -14px; bottom: -14px; width: 40px; height: 40px; z-index: 3; cursor: nwse-resize; }
.resize-handle[data-edge="rb"]::after { right: 3px; bottom: 3px; width: 16px; height: 16px; border-radius: 5px; }
.resize-bar { position: fixed; left: 50%; bottom: calc(var(--bottom) + 1rem); z-index: 15; transform: translateX(-50%);
display: flex; align-items: center; gap: .5rem; padding: .4rem .4rem .4rem 1rem; border-radius: 999px;
background: rgb(0 0 0 / .8); color: #fff; font-size: .875rem; white-space: nowrap;
display: flex; align-items: center; gap: .5rem; padding: .4rem .4rem .4rem .75rem; border-radius: 999px;
background: rgb(0 0 0 / .82); color: #fff; font-size: .875rem; white-space: nowrap;
animation: ui-fade .15s; }
.resize-bar { max-width: calc(100vw - 1rem); }
.resize-size { flex: none; padding: .15rem .5rem; border-radius: 999px;
background: rgb(255 255 255 / .16); font-size: .75rem; font-weight: 600;
font-variant-numeric: tabular-nums; }
.resize-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.resize-bar .btn { flex: none; }
.resize-bar .btn.ghost { color: #fff; }
@@ -204,12 +216,21 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
background: rgb(255 255 255 / .75); border-radius: 1px; transform: rotate(45deg); }
button { cursor: pointer; }
/* ---- drawer: slides down over the home screen */
/* ---- drawer: GPU-composited slide+fade over the home screen */
.drawer { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
padding: calc(var(--top) + 1rem) 16px 0; background: rgb(10 10 14 / .72);
backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
animation: drop .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes drop { from { transform: translateY(-100%); } to { transform: none; } }
padding: calc(var(--top) + 1rem) 16px 0; background: rgb(10 10 14 / .84);
will-change: transform, opacity;
animation: drawer-in 180ms cubic-bezier(.2, .8, .2, 1); }
.drawer.closing { pointer-events: none;
animation: drawer-out 140ms cubic-bezier(.4, 0, 1, 1) forwards; }
@keyframes drawer-in {
from { opacity: 0; transform: translate3d(0, -20px, 0); }
to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes drawer-out {
from { opacity: 1; transform: translate3d(0, 0, 0); }
to { opacity: 0; transform: translate3d(0, -16px, 0); }
}
.drawer-head { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.drawer-head .input { flex: 1; height: 2.75rem; border-radius: 999px; padding: 0 1.25rem; font-size: 1rem;
background: rgb(255 255 255 / .1); border-color: rgb(255 255 255 / .15); color: #fff; }
@@ -250,6 +271,11 @@ button { cursor: pointer; }
.widget-name { display: grid; }
.widget-name small { color: var(--muted-foreground); font-size: .8rem; }
.widget-search { width: 100%; margin-bottom: .5rem; }
.sheet-copy { margin: 0 .5rem .75rem; font-size: .875rem; color: var(--muted-foreground); line-height: 1.45; }
.sheet-steps { margin: 0 .5rem 1rem; padding-left: 1.25rem; display: grid; gap: .5rem; font-size: .875rem; line-height: 1.45; }
.sheet-steps strong { font-weight: 600; color: var(--popover-foreground); }
.sheet-actions { display: grid; gap: .5rem; margin: 0 .25rem; }
.sheet-actions .btn { width: 100%; height: 2.5rem; }
.notice, #toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + 2rem); z-index: 30;
transform: translateX(-50%); padding: .5rem 1rem; border-radius: 999px;
@@ -258,4 +284,4 @@ button { cursor: pointer; }
#toast { opacity: 0; transition: opacity .2s; animation: none; }
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .drawer, .sheet { animation: none; } }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer.closing, .sheet { animation: none; } }