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

+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() {