1 parent
dccbfd7d86
commit
17f81c60c8
20 files changed
+636
-447
No files matched your search
+57
-22
@@ -19,17 +19,17 @@ priv struct PageState {
|
||||
mut focus_pending : Bool
|
||||
mut placed : String
|
||||
mut excluded : String
|
||||
mut cover_y : Int
|
||||
mut cover_y : Int32
|
||||
mut cover_last : Double
|
||||
mut cover_loop : Bool
|
||||
mut measured : String
|
||||
mut touch : (Double, Double, Double)?
|
||||
mut demo_widget : Int
|
||||
mut http_tag : Int
|
||||
http : Map[Int, (Bool, String) -> Unit]
|
||||
mut demo_widget : Int32
|
||||
mut http_tag : Int32
|
||||
http : Map[Int32, (Bool, String) -> Unit]
|
||||
icon_src : Map[String, String]
|
||||
icon_asked : Map[String, Bool]
|
||||
icon_tries : Map[String, Int]
|
||||
icon_tries : Map[String, Int32]
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -100,8 +100,18 @@ fn exec(e : @app.Effect) -> Unit {
|
||||
let android = is_android()
|
||||
match e {
|
||||
Launch(c) => if android { h_launch(c) } else { toast("Open " + c) }
|
||||
AppInfo(c) => if android { h_app_info(c) } else { toast("App info for " + c) }
|
||||
Uninstall(c) => if android { h_uninstall(c) } else { toast("Uninstall " + c) }
|
||||
AppInfo(c) =>
|
||||
if android {
|
||||
h_app_info(c)
|
||||
} else {
|
||||
toast("App info for " + c)
|
||||
}
|
||||
Uninstall(c) =>
|
||||
if android {
|
||||
h_uninstall(c)
|
||||
} else {
|
||||
toast("Uninstall " + c)
|
||||
}
|
||||
AddWidget(p) =>
|
||||
if android {
|
||||
h_add_widget(p)
|
||||
@@ -111,9 +121,24 @@ fn exec(e : @app.Effect) -> Unit {
|
||||
set_timeout(0, fn() { dispatch(WidgetAdded(id)) })
|
||||
}
|
||||
RemoveWidget(id) => if android { h_remove_widget(id) }
|
||||
OpenSettings => if android { h_open_settings() } else { toast("Open system settings") }
|
||||
PickWallpaper => if android { h_pick_wallpaper() } else { toast("Pick a wallpaper") }
|
||||
OpenRecents => if android { h_open_recents() } else { toast("Show open windows") }
|
||||
OpenSettings =>
|
||||
if android {
|
||||
h_open_settings()
|
||||
} else {
|
||||
toast("Open system settings")
|
||||
}
|
||||
PickWallpaper =>
|
||||
if android {
|
||||
h_pick_wallpaper()
|
||||
} else {
|
||||
toast("Pick a wallpaper")
|
||||
}
|
||||
OpenRecents =>
|
||||
if android {
|
||||
h_open_recents()
|
||||
} else {
|
||||
toast("Show open windows")
|
||||
}
|
||||
Haptic => h_haptic()
|
||||
LoadApps =>
|
||||
fetch_text("apps.json", fn(ok, text) {
|
||||
@@ -149,7 +174,11 @@ fn exec(e : @app.Effect) -> Unit {
|
||||
dispatch(VersionFetched(if ok { Some(text) } else { None }))
|
||||
})
|
||||
InstallApk(url, n) =>
|
||||
if android { h_install_apk(url, n) } else { toast("Install update \{n}") }
|
||||
if android {
|
||||
h_install_apk(url, n)
|
||||
} else {
|
||||
toast("Install update \{n}")
|
||||
}
|
||||
FocusSearch => state.val.focus_pending = true
|
||||
HideKeyboard => {
|
||||
blur_active()
|
||||
@@ -309,17 +338,13 @@ fn got_icons(json : String) -> Unit {
|
||||
// ---- input -------------------------------------------------------------------------
|
||||
|
||||
///|
|
||||
fn parse_chain(s : String) -> Array[Int] {
|
||||
fn parse_chain(s : String) -> Array[Int32] {
|
||||
if s == "" {
|
||||
return []
|
||||
}
|
||||
let out : Array[Int] = []
|
||||
let out : Array[Int32] = []
|
||||
for part in s.split(",") {
|
||||
out.push(
|
||||
try @string.parse_int(part) catch {
|
||||
_ => -1
|
||||
},
|
||||
)
|
||||
out.push(@string.parse_int(part) catch { _ => -1 })
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -342,10 +367,16 @@ fn wire_events() -> Unit {
|
||||
listen("document", "pointerup", true, fn(e) { feed(Up(x=ev_x(e), y=ev_y(e))) })
|
||||
listen("document", "pointercancel", true, fn(_) { feed(Cancel) })
|
||||
// keep the page from scrolling under a lifted slot or a handle being dragged
|
||||
listen("document", "touchmove", false, fn(e) { if is_dragging() { ev_prevent(e) } })
|
||||
listen("document", "touchmove", false, fn(e) {
|
||||
if is_dragging() {
|
||||
ev_prevent(e)
|
||||
}
|
||||
})
|
||||
listen("document", "contextmenu", false, fn(e) { ev_prevent(e) })
|
||||
listen("document", "input", true, fn(e) {
|
||||
run(@app.typed(model, state.val.table, parse_chain(ev_chain(e)), ev_value(e)))
|
||||
run(
|
||||
@app.typed(model, state.val.table, parse_chain(ev_chain(e)), ev_value(e)),
|
||||
)
|
||||
})
|
||||
listen("document", "keydown", true, fn(e) {
|
||||
if ev_composing(e) {
|
||||
@@ -428,7 +459,7 @@ fn num(key : String) -> Int64 {
|
||||
if s == "" {
|
||||
0L
|
||||
} else {
|
||||
try @string.parse_int64(s) catch {
|
||||
@string.parse_int64(s) catch {
|
||||
_ => 0L
|
||||
}
|
||||
}
|
||||
@@ -441,7 +472,11 @@ fn main {
|
||||
}
|
||||
expose_api()
|
||||
wire_events()
|
||||
let saved = if storage_has("launcher.home") { Some(storage_get("launcher.home")) } else { None }
|
||||
let saved = if storage_has("launcher.home") {
|
||||
Some(storage_get("launcher.home"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
let legacy = if saved is None { Some(storage_legacy()) } else { None }
|
||||
dispatch(Restore(saved~, legacy~))
|
||||
if is_android() {
|
||||
|
||||
Reference in new issue
Block a user