Fix wallpaper transparency, Recents setup guide, and drawer animation
This commit is contained in:
1 parent
2fa7bd745b
commit
216c80252d
14 files changed
+474
-86
No files matched your search
+16
-13
@@ -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 =
|
||||
|
||||
+40
-17
@@ -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) {
|
||||
@@ -251,28 +264,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
|
||||
|
||||
+22
-8
@@ -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;
|
||||
@@ -204,12 +204,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 +259,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 +272,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; } }
|
||||
Reference in new issue
Block a user