Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49ea6c54ae | ||
|
|
a8ce535f37 | ||
|
|
67b6b58c94 | ||
|
|
5258ac22ad | ||
|
|
17f81c60c8 | ||
|
|
dccbfd7d86 | ||
|
|
637129aa4e | ||
|
|
28e0284d9b | ||
|
|
66e8e90da1 |
No files matched your search
@@ -1,5 +0,0 @@
|
||||
---
|
||||
type: fix
|
||||
---
|
||||
|
||||
Show the Android system wallpaper behind the transparent WebView, add an in-app setup guide for Android 13+ "Restricted setting" on the Windows button, smooth out app drawer animations with keyed overlays, GPU-composited transitions, delayed IME focus, and pre-warmed app icons, and fix widget resizing across all four edges with edge touch passthrough, scroll-synced coordinates, and axis-conditional handles.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
type: feature
|
||||
---
|
||||
|
||||
Add an icon size setting (long-press the home screen, then Icon size): a 70-160% slider with Small / Medium / Large presets and a live preview that resizes the home grid and the app drawer together. Icon, label and row height scale, the column count reflows so nothing overlaps or clips, the choice is saved, and a corrupt saved value is logged and shown instead of silently replaced. 100% is the original size.
|
||||
@@ -1,17 +1,11 @@
|
||||
# ultra launcher
|
||||
|
||||
An Android home screen, written in [MoonBit](https://www.moonbitlang.com). Home starts blank: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to drag it somewhere else; let go without moving to get its menu, or, for a widget, handles on its edges that resize it to the grid. **Icon size** in the same menu sets how big icons are (70%–160% in steps of 5, with Small / Medium / Large presets and a live preview; Medium, 100%, is the original size). It applies to the home screen and the app drawer together, scales icon, label and row height, and changes the column count so nothing overlaps or clips. Swipe down (or tap the search pill) for the drawer with every app and a search (Enter opens the first match); long-press an app there for its menu (add to home, app info, uninstall; system apps have no uninstall), and swipe up to close it. The **Windows** button in the panel at the top opens Recents. The layout is saved on the device, and the app updates itself from the latest release here.
|
||||
An Android home screen, written in [MoonBit](https://www.moonbitlang.com). Home starts blank: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to drag it somewhere else; let go without moving to get its menu, or, for a widget, handles on its edges that resize it to the grid. Swipe down (or tap the search pill) for the drawer with every app and a search (Enter opens the first match); long-press an app there for its menu (add to home, app info, uninstall; system apps have no uninstall), and swipe up to close it. The **Windows** button in the panel at the top opens Recents. The layout is saved on the device, and the app updates itself from the latest release here.
|
||||
|
||||
| home | drawer | app menu | resize handles |
|
||||
|---|---|---|---|
|
||||
|  |  |  |  |
|
||||
|
||||
Icon size, before (100%) and at 130% / 70%, the drawer at 130%, and the error shown for a corrupt saved value:
|
||||
|
||||
| before | 130% | 70% | drawer 130% | corrupt value |
|
||||
|---|---|---|---|---|
|
||||
|  |  |  |  |  |
|
||||
|
||||
(Screenshots are of the browser demo at phone size.)
|
||||
|
||||
## Install
|
||||
@@ -46,7 +40,7 @@ MoonBit owns the logic and the UI; Java is only what Android itself requires.
|
||||
|
||||
| package | what | tested by |
|
||||
|---|---|---|
|
||||
| `grid/` | the home grid: packing (dense, with pinned cells), cell/box math, pin, resize steps, widget columns, and the icon size setting (range, parsing, row height, column counts) | `moon test` |
|
||||
| `grid/` | the home grid: packing (dense, with pinned cells), cell/box math, pin, resize steps, widget columns | `moon test` |
|
||||
| `gesture/` | pointer state machine: tap, long press (500 ms, 10 px slop), drag, release, swipe | `moon test` |
|
||||
| `updater/` | release/`version.json` parsing, `build-N` tags, the install/skip decision, 6 h throttle | `moon test` |
|
||||
| `jsonx/` | small `Json` accessors | `moon test` |
|
||||
|
||||
@@ -36,7 +36,6 @@ import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.Window;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.RenderProcessGoneDetail;
|
||||
@@ -78,10 +77,9 @@ import java.util.concurrent.Executors;
|
||||
*
|
||||
* and exposes window.Android (launch, appInfo, uninstall, addWidget, removeWidget,
|
||||
* placeWidgets, coverWidgets, widgetLimits, excludeGestures, loadIcons, haptic, keyboard,
|
||||
* openSettings, pickWallpaper, openRecents, recentsEnabled, openAccessibilitySettings,
|
||||
* openSelfAppInfo, httpGet, installApk, installedVersion, declinedVersion) for the page's
|
||||
* host effects. No decisions are made here: the page (core/ and app/ in MoonBit) decides,
|
||||
* this class carries them out.
|
||||
* openSettings, pickWallpaper, openRecents, httpGet, installApk, installedVersion,
|
||||
* declinedVersion) for the page's host effects. No decisions are made here: the page
|
||||
* (core/ and app/ in MoonBit) decides, this class carries them out.
|
||||
*
|
||||
* Widgets are real AppWidgetHostViews in a layer above the WebView. The page reports where
|
||||
* its live widget slots are (placeWidgets), and this class moves the views there. Package
|
||||
@@ -105,7 +103,6 @@ public class HomeActivity extends Activity {
|
||||
private final Map<Integer, Long> widgetSizes = new HashMap<>(); // last size told to each widget
|
||||
private int pendingWidget = -1;
|
||||
private int editingWidget = -1; // showing resize handles: a press on it moves it
|
||||
private int editingResizeMode; // RESIZE_HORIZONTAL | RESIZE_VERTICAL for editingWidget
|
||||
private boolean ready;
|
||||
private int insetTop, insetBottom; // CSS px
|
||||
private LauncherApps launcher;
|
||||
@@ -113,12 +110,6 @@ public class HomeActivity extends Activity {
|
||||
private final Map<String, byte[]> icons = new ConcurrentHashMap<>();
|
||||
private final Map<String, LauncherActivityInfo> activities = new ConcurrentHashMap<>();
|
||||
private final Handler main = new Handler(Looper.getMainLooper());
|
||||
private final Runnable showIme = () -> {
|
||||
if (!ready || web == null) return;
|
||||
web.requestFocus();
|
||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||
if (imm != null) imm.showSoftInput(web, InputMethodManager.SHOW_IMPLICIT);
|
||||
};
|
||||
private final ExecutorService iconThread = Executors.newSingleThreadExecutor();
|
||||
|
||||
private final LauncherApps.Callback packages = new LauncherApps.Callback() {
|
||||
@@ -138,11 +129,6 @@ public class HomeActivity extends Activity {
|
||||
widgetHost = new Host(this);
|
||||
|
||||
Window w = getWindow();
|
||||
w.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
w.setNavigationBarContrastEnforced(false);
|
||||
w.setStatusBarContrastEnforced(false);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
w.setDecorFitsSystemWindows(false);
|
||||
} else {
|
||||
@@ -153,7 +139,6 @@ public class HomeActivity extends Activity {
|
||||
}
|
||||
|
||||
private void createWebView() {
|
||||
main.removeCallbacks(showIme);
|
||||
ready = false;
|
||||
web = new WebView(this);
|
||||
web.setBackgroundColor(Color.TRANSPARENT);
|
||||
@@ -189,9 +174,7 @@ public class HomeActivity extends Activity {
|
||||
widgetViews.clear();
|
||||
widgetSizes.clear();
|
||||
widgetLayer = new CoverLayer(this);
|
||||
widgetLayer.setBackgroundColor(Color.TRANSPARENT);
|
||||
FrameLayout root = new FrameLayout(this);
|
||||
root.setBackgroundColor(Color.TRANSPARENT);
|
||||
root.addView(web);
|
||||
root.addView(widgetLayer);
|
||||
setContentView(root);
|
||||
@@ -213,7 +196,6 @@ public class HomeActivity extends Activity {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
launcher.unregisterCallback(packages);
|
||||
main.removeCallbacks(showIme);
|
||||
iconThread.shutdownNow();
|
||||
web.destroy();
|
||||
super.onDestroy();
|
||||
@@ -571,14 +553,6 @@ public class HomeActivity extends Activity {
|
||||
return;
|
||||
}
|
||||
editingWidget = editing;
|
||||
if (editing != -1) {
|
||||
AppWidgetProviderInfo editInfo = widgets.getAppWidgetInfo(editing);
|
||||
editingResizeMode = editInfo != null
|
||||
? editInfo.resizeMode
|
||||
: (AppWidgetProviderInfo.RESIZE_HORIZONTAL | AppWidgetProviderInfo.RESIZE_VERTICAL);
|
||||
} else {
|
||||
editingResizeMode = 0;
|
||||
}
|
||||
for (Map.Entry<Integer, AppWidgetHostView> e : widgetViews.entrySet()) {
|
||||
if (!want.containsKey(e.getKey())) e.getValue().setVisibility(View.GONE);
|
||||
}
|
||||
@@ -599,7 +573,7 @@ public class HomeActivity extends Activity {
|
||||
v.setLayoutParams(lp);
|
||||
v.setVisibility(View.VISIBLE);
|
||||
// Scrolling moves a widget without resizing it; only tell it about new sizes.
|
||||
long size = ((long) r[4] << 32) | (r[5] & 0xffffffffL);
|
||||
long size = ((long) r[4] << 32) | r[5];
|
||||
Long was = widgetSizes.put(id, size);
|
||||
if (was == null || was != size) {
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
@@ -683,23 +657,6 @@ public class HomeActivity extends Activity {
|
||||
super.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
if (home.editingWidget == id && ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
int mode = home.editingResizeMode;
|
||||
boolean canH = (mode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0;
|
||||
boolean canV = (mode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0;
|
||||
float d = getResources().getDisplayMetrics().density;
|
||||
float insetX = Math.min(18f * d, getWidth() * 0.3f);
|
||||
float insetY = Math.min(18f * d, getHeight() * 0.3f);
|
||||
float x = ev.getX(), y = ev.getY();
|
||||
boolean nearH = canH && (x < insetX || x > getWidth() - insetX);
|
||||
boolean nearV = canV && (y < insetY || y > getHeight() - insetY);
|
||||
if (nearH || nearV) return false;
|
||||
}
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent e) {
|
||||
switch (e.getActionMasked()) {
|
||||
@@ -795,16 +752,13 @@ public class HomeActivity extends Activity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Recents through RecentsService, falling back to Accessibility settings if
|
||||
* invoked directly while the service isn't running.
|
||||
* Show Recents through RecentsService. Until the user has turned the service on, take
|
||||
* them to Accessibility settings, with our service highlighted where Settings supports it.
|
||||
*/
|
||||
private void openRecents() {
|
||||
if (RecentsService.showRecents()) return;
|
||||
openAccessibilitySettings();
|
||||
}
|
||||
|
||||
/** Open Accessibility settings with RecentsService highlighted where Settings supports it. */
|
||||
private void openAccessibilitySettings() {
|
||||
Toast.makeText(this, "Turn on \"" + getString(R.string.recents_service_label)
|
||||
+ "\" to show open windows", Toast.LENGTH_LONG).show();
|
||||
String me = new ComponentName(this, RecentsService.class).flattenToString();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(":settings:fragment_args_key", me);
|
||||
@@ -813,12 +767,6 @@ public class HomeActivity extends Activity {
|
||||
.putExtra(":settings:show_fragment_args", args));
|
||||
}
|
||||
|
||||
/** Open ultra Home's own App info page (for "Allow restricted settings" on Android 13+). */
|
||||
private void openSelfAppInfo() {
|
||||
startIntent(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", getPackageName(), null)));
|
||||
}
|
||||
|
||||
/** window.Android: called from the page's @jscall imports on a binder thread. */
|
||||
final class Bridge {
|
||||
@JavascriptInterface public void launch(String component) {
|
||||
@@ -885,14 +833,16 @@ public class HomeActivity extends Activity {
|
||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING));
|
||||
}
|
||||
|
||||
/** The page focused the drawer's search box; show the keyboard once the entrance finishes. */
|
||||
/** The page focused the drawer's search box; show the keyboard for it. */
|
||||
@JavascriptInterface public void showKeyboard() {
|
||||
main.removeCallbacks(showIme);
|
||||
main.postDelayed(showIme, 190);
|
||||
main.postDelayed(() -> {
|
||||
web.requestFocus();
|
||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||
if (imm != null) imm.showSoftInput(web, InputMethodManager.SHOW_IMPLICIT);
|
||||
}, 50);
|
||||
}
|
||||
|
||||
@JavascriptInterface public void hideKeyboard() {
|
||||
main.removeCallbacks(showIme);
|
||||
main.post(() -> {
|
||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||
if (imm != null) imm.hideSoftInputFromWindow(web.getWindowToken(), 0);
|
||||
@@ -907,22 +857,8 @@ public class HomeActivity extends Activity {
|
||||
main.post(() -> startIntent(Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), "Wallpaper")));
|
||||
}
|
||||
|
||||
@JavascriptInterface public boolean openRecents() {
|
||||
if (!RecentsService.isRunning()) return false;
|
||||
@JavascriptInterface public void openRecents() {
|
||||
main.post(HomeActivity.this::openRecents);
|
||||
return true;
|
||||
}
|
||||
|
||||
@JavascriptInterface public boolean recentsEnabled() {
|
||||
return RecentsService.isRunning();
|
||||
}
|
||||
|
||||
@JavascriptInterface public void openAccessibilitySettings() {
|
||||
main.post(HomeActivity.this::openAccessibilitySettings);
|
||||
}
|
||||
|
||||
@JavascriptInterface public void openSelfAppInfo() {
|
||||
main.post(HomeActivity.this::openSelfAppInfo);
|
||||
}
|
||||
|
||||
/** GET a URL on a background thread; the page hears back through launcher.httpResult(tag, ok, text). */
|
||||
|
||||
@@ -13,11 +13,6 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
public class RecentsService extends AccessibilityService {
|
||||
private static volatile RecentsService running;
|
||||
|
||||
/** Whether the accessibility service is currently connected. */
|
||||
static boolean isRunning() {
|
||||
return running != null;
|
||||
}
|
||||
|
||||
/** Open Recents; false when the service isn't turned on. */
|
||||
static boolean showRecents() {
|
||||
RecentsService s = running;
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
<string name="app_name">ultra Home</string>
|
||||
<string name="recents_service_label">ultra Home window list</string>
|
||||
<string name="recents_service_summary">Lets the home screen\'s Windows button open Recents</string>
|
||||
<string name="recents_service_description">Turn this on so the Windows button on the ultra Home screen can show your open windows (Recents). Android only lets accessibility services open Recents. If Android blocks this as a restricted setting, open ultra Home\'s App info and turn on Allow restricted settings once. This service reads nothing on screen and does nothing else.</string>
|
||||
<string name="recents_service_description">Turn this on so the Windows button on the ultra Home screen can show your open windows (Recents). Android only lets accessibility services open Recents. This service reads nothing on screen and does nothing else.</string>
|
||||
</resources>
|
||||
+3
-57
@@ -60,37 +60,24 @@ pub(all) enum Sheet {
|
||||
/// The menu of a drawer app (row in the app list).
|
||||
DrawerApp(Int32)
|
||||
WidgetPicker
|
||||
RecentsSetup
|
||||
/// The icon size slider and presets.
|
||||
IconSize
|
||||
}
|
||||
|
||||
///|
|
||||
#derive(Eq, Debug)
|
||||
pub(all) enum Edge {
|
||||
Left
|
||||
Right
|
||||
Top
|
||||
Bottom
|
||||
Corner
|
||||
}
|
||||
|
||||
///|
|
||||
/// A resize in progress: a handle was pressed on the widget whose viewport box and
|
||||
/// grid edges were captured on down.
|
||||
/// A resize in progress: a handle was pressed on the widget whose box (px, viewport) was
|
||||
/// at `left`, `top`.
|
||||
pub(all) struct ResizeDrag {
|
||||
edge : Edge
|
||||
slot : Int32
|
||||
left : Double
|
||||
top : Double
|
||||
right : Double
|
||||
bottom : Double
|
||||
anchor_col : Int32
|
||||
anchor_row : Int32
|
||||
right_col : Int32
|
||||
bottom_row : Int32
|
||||
mut col : Int32
|
||||
mut row : Int32
|
||||
mut cols : Int32
|
||||
mut rows : Int32
|
||||
}
|
||||
@@ -120,25 +107,9 @@ pub(all) struct Model {
|
||||
mut grid_left : Double
|
||||
mut grid_top : Double
|
||||
mut col_w : Double
|
||||
/// Icon size in percent of the original (see grid/scale.mbt), applied to the home
|
||||
/// grid and the drawer.
|
||||
mut icon_pct : Int32
|
||||
/// Why the saved icon size could not be used (empty: it could); shown in the icon
|
||||
/// size sheet. The bad stored value is left alone until a size is chosen.
|
||||
mut icon_error : String
|
||||
/// The last measurement, kept so a size change can lay out again without one.
|
||||
mut vw : Int32
|
||||
mut grid_w : Double
|
||||
/// Px of screen below the top of the grid that rows can fill.
|
||||
mut avail_h : Double
|
||||
/// Columns of the drawer's app list.
|
||||
mut drawer_cols : Int32
|
||||
mut query : String
|
||||
mut wquery : String
|
||||
mut drawer : Bool
|
||||
/// The drawer is animating out before detaching.
|
||||
mut drawer_closing : Bool
|
||||
mut drawer_gen : Int32
|
||||
/// The drawer is in "add apps" mode: taps toggle home slots.
|
||||
mut picking : Bool
|
||||
mut sheet : Sheet
|
||||
@@ -191,17 +162,9 @@ pub fn Model::new() -> Model {
|
||||
grid_left: 0.0,
|
||||
grid_top: 0.0,
|
||||
col_w: 0.0,
|
||||
icon_pct: @grid.scale_default,
|
||||
icon_error: "",
|
||||
vw: 0,
|
||||
grid_w: 0.0,
|
||||
avail_h: 0.0,
|
||||
drawer_cols: 4,
|
||||
query: "",
|
||||
wquery: "",
|
||||
drawer: false,
|
||||
drawer_closing: false,
|
||||
drawer_gen: 0,
|
||||
picking: false,
|
||||
sheet: NoSheet,
|
||||
gone: "",
|
||||
@@ -243,7 +206,7 @@ pub(all) enum Msg {
|
||||
// ---- from the platform
|
||||
/// Boot: the saved layout (this app's JSON, and the old WebView build's
|
||||
/// `ultra.home.*` localStorage as a JSON object), the clock, and the self-update state.
|
||||
Restore(saved~ : String?, legacy~ : String?, icon_size~ : String?)
|
||||
Restore(saved~ : String?, legacy~ : String?)
|
||||
Started(
|
||||
now~ : Int64,
|
||||
last_check~ : Int64,
|
||||
@@ -258,7 +221,6 @@ pub(all) enum Msg {
|
||||
grid_top~ : Double,
|
||||
grid_w~ : Double,
|
||||
bottom_pad~ : Double,
|
||||
scroll_y~ : Double,
|
||||
)
|
||||
AppsLoaded(String?)
|
||||
WidgetsLoaded(String?)
|
||||
@@ -295,7 +257,6 @@ pub(all) enum Msg {
|
||||
WClear
|
||||
OpenDrawer
|
||||
CloseDrawer
|
||||
DrawerClosed(Int32)
|
||||
OpenApp(Int32)
|
||||
OpenFirst
|
||||
OpenHome(Int32)
|
||||
@@ -315,17 +276,8 @@ pub(all) enum Msg {
|
||||
MoveEarlier(Int32)
|
||||
InfoOf(Int32)
|
||||
Settings
|
||||
/// Open the icon size sheet.
|
||||
IconSizeMenu
|
||||
/// The slider's value (text, as the input reports it).
|
||||
SetIconSize(String)
|
||||
/// A preset button, in percent.
|
||||
IconPreset(Int32)
|
||||
Wallpaper
|
||||
Recents
|
||||
RecentsUnavailable
|
||||
OpenAccessibilitySettings
|
||||
OpenSelfAppInfo
|
||||
CheckUpdates
|
||||
Lift(Int32)
|
||||
Grab(Int32)
|
||||
@@ -349,8 +301,6 @@ pub(all) enum Effect {
|
||||
OpenSettings
|
||||
PickWallpaper
|
||||
OpenRecents
|
||||
OpenAccessibilitySettings
|
||||
OpenSelfAppInfo
|
||||
Haptic
|
||||
/// Fetch apps.json / widgets.json and answer `AppsLoaded` / `WidgetsLoaded`.
|
||||
LoadApps
|
||||
@@ -358,10 +308,6 @@ pub(all) enum Effect {
|
||||
/// Ask the shell for a widget's limits and answer `LimitsKnown`.
|
||||
QueryLimits(Int32)
|
||||
SaveHome(String)
|
||||
/// Store the icon size (percent).
|
||||
SaveIconSize(Int32)
|
||||
/// Write a line to the platform's error log.
|
||||
LogError(String)
|
||||
SaveLastCheck(Int64)
|
||||
/// Send the message after this many ms.
|
||||
Delay(Int32, Msg)
|
||||
|
||||
+2
-36
@@ -60,9 +60,7 @@ pub(all) struct Carry {
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) enum Edge {
|
||||
Left
|
||||
Right
|
||||
Top
|
||||
Bottom
|
||||
Corner
|
||||
}
|
||||
@@ -77,15 +75,11 @@ pub(all) enum Effect {
|
||||
OpenSettings
|
||||
PickWallpaper
|
||||
OpenRecents
|
||||
OpenAccessibilitySettings
|
||||
OpenSelfAppInfo
|
||||
Haptic
|
||||
LoadApps
|
||||
LoadWidgets
|
||||
QueryLimits(Int32)
|
||||
SaveHome(String)
|
||||
SaveIconSize(Int32)
|
||||
LogError(String)
|
||||
SaveLastCheck(Int64)
|
||||
Delay(Int32, Msg)
|
||||
HoldTimer(Int32, Int32)
|
||||
@@ -125,17 +119,9 @@ pub(all) struct Model {
|
||||
mut grid_left : Double
|
||||
mut grid_top : Double
|
||||
mut col_w : Double
|
||||
mut icon_pct : Int32
|
||||
mut icon_error : String
|
||||
mut vw : Int32
|
||||
mut grid_w : Double
|
||||
mut avail_h : Double
|
||||
mut drawer_cols : Int32
|
||||
mut query : String
|
||||
mut wquery : String
|
||||
mut drawer : Bool
|
||||
mut drawer_closing : Bool
|
||||
mut drawer_gen : Int32
|
||||
mut picking : Bool
|
||||
mut sheet : Sheet
|
||||
mut gone : String
|
||||
@@ -161,13 +147,10 @@ pub(all) struct Model {
|
||||
mut gesture : @gesture.State
|
||||
}
|
||||
pub fn Model::app_row(Self, String) -> Int32
|
||||
pub fn Model::cell_h(Self) -> Int32
|
||||
pub fn Model::drawer_open(Self) -> Bool
|
||||
pub fn Model::first_match(Self) -> Int32
|
||||
pub fn Model::first_widget_match(Self) -> Int32
|
||||
pub fn Model::hidden(Self, Int32) -> Bool
|
||||
pub fn Model::home_of(Self, Int32) -> Int32
|
||||
pub fn Model::icon_keys(Self) -> Array[String]
|
||||
pub fn Model::new() -> Self
|
||||
pub fn Model::packed(Self) -> @grid.Packed
|
||||
pub fn Model::slot_of_widget(Self, Int32) -> Int32
|
||||
@@ -175,9 +158,9 @@ pub fn Model::widget_matches(Self, Int32) -> Bool
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) enum Msg {
|
||||
Restore(saved~ : String?, legacy~ : String?, icon_size~ : String?)
|
||||
Restore(saved~ : String?, legacy~ : String?)
|
||||
Started(now~ : Int64, last_check~ : Int64, declined~ : Int32, installed~ : Int32)
|
||||
Measured(vw~ : Int32, vh~ : Int32, grid_left~ : Double, grid_top~ : Double, grid_w~ : Double, bottom_pad~ : Double, scroll_y~ : Double)
|
||||
Measured(vw~ : Int32, vh~ : Int32, grid_left~ : Double, grid_top~ : Double, grid_w~ : Double, bottom_pad~ : Double)
|
||||
AppsLoaded(String?)
|
||||
WidgetsLoaded(String?)
|
||||
LimitsKnown(Int32, String?)
|
||||
@@ -199,7 +182,6 @@ pub(all) enum Msg {
|
||||
WClear
|
||||
OpenDrawer
|
||||
CloseDrawer
|
||||
DrawerClosed(Int32)
|
||||
OpenApp(Int32)
|
||||
OpenFirst
|
||||
OpenHome(Int32)
|
||||
@@ -218,14 +200,8 @@ pub(all) enum Msg {
|
||||
MoveEarlier(Int32)
|
||||
InfoOf(Int32)
|
||||
Settings
|
||||
IconSizeMenu
|
||||
SetIconSize(String)
|
||||
IconPreset(Int32)
|
||||
Wallpaper
|
||||
Recents
|
||||
RecentsUnavailable
|
||||
OpenAccessibilitySettings
|
||||
OpenSelfAppInfo
|
||||
CheckUpdates
|
||||
Lift(Int32)
|
||||
Grab(Int32)
|
||||
@@ -241,14 +217,6 @@ pub(all) struct ResizeDrag {
|
||||
slot : Int32
|
||||
left : Double
|
||||
top : Double
|
||||
right : Double
|
||||
bottom : Double
|
||||
anchor_col : Int32
|
||||
anchor_row : Int32
|
||||
right_col : Int32
|
||||
bottom_row : Int32
|
||||
mut col : Int32
|
||||
mut row : Int32
|
||||
mut cols : Int32
|
||||
mut rows : Int32
|
||||
}
|
||||
@@ -260,8 +228,6 @@ pub(all) enum Sheet {
|
||||
Item(Int32)
|
||||
DrawerApp(Int32)
|
||||
WidgetPicker
|
||||
RecentsSetup
|
||||
IconSize
|
||||
}
|
||||
|
||||
pub(all) struct WidgetInfo {
|
||||
|
||||
+9
-445
@@ -33,7 +33,7 @@ struct Sim {
|
||||
fn Sim::new() -> Sim {
|
||||
let m = Model::new()
|
||||
let s = { m, tree: [], table: [], log: [], last_x: 0.0, last_y: 0.0, }
|
||||
s.run(update(m, Restore(saved=None, legacy=None, icon_size=None)))
|
||||
s.run(update(m, Restore(saved=None, legacy=None)))
|
||||
s.send(
|
||||
Measured(
|
||||
vw=390,
|
||||
@@ -42,7 +42,6 @@ fn Sim::new() -> Sim {
|
||||
grid_top=150.0,
|
||||
grid_w=358.0,
|
||||
bottom_pad=24.0,
|
||||
scroll_y=0.0,
|
||||
),
|
||||
)
|
||||
s.send(AppsLoaded(Some(apps_json)))
|
||||
@@ -250,21 +249,6 @@ fn cell_center(col : Int32, row : Int32) -> (Double, Double) {
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
/// Finish the pending drawer-close animation timer.
|
||||
fn Sim::finish_drawer_close(self : Sim) -> Unit {
|
||||
let mut gen : Int32? = None
|
||||
for e in self.log {
|
||||
if e is Delay(_, DrawerClosed(g)) {
|
||||
gen = Some(g)
|
||||
}
|
||||
}
|
||||
match gen {
|
||||
Some(g) => self.send(DrawerClosed(g))
|
||||
None => abort("no pending DrawerClosed timer")
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Add apps to the home screen through the long-press menu and the drawer's pick mode.
|
||||
fn Sim::add_apps(self : Sim, labels : Array[String]) -> Unit {
|
||||
@@ -274,7 +258,6 @@ fn Sim::add_apps(self : Sim, labels : Array[String]) -> Unit {
|
||||
self.tap("tile", label=l, from=1) // the drawer's, not the home screen's under it
|
||||
}
|
||||
self.tap("btn", label="Done")
|
||||
self.finish_drawer_close()
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -311,9 +294,7 @@ test "add apps through the drawer's pick mode" {
|
||||
s.tap("tile", label="Phone", from=1)
|
||||
s.tap("tile", label="Gmail", from=1) // toggled off again
|
||||
s.tap("btn", label="Done")
|
||||
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||
s.finish_drawer_close()
|
||||
assert_true(!s.m.drawer && !s.m.drawer_closing)
|
||||
assert_true(!s.m.drawer)
|
||||
assert_eq(s.home_names(), ["Chrome", "Phone"])
|
||||
}
|
||||
|
||||
@@ -326,10 +307,8 @@ test "swipe down opens the drawer, swipe up closes it" {
|
||||
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=false))
|
||||
assert_true(s.m.drawer) // the list isn't at its end yet
|
||||
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=true))
|
||||
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||
assert_true(s.has_effect(HideKeyboard))
|
||||
s.finish_drawer_close()
|
||||
assert_true(!s.m.drawer)
|
||||
assert_true(s.has_effect(HideKeyboard))
|
||||
s.send(Touch(dx=3.0, dy=40.0, ms=200, home_top=true, list_end=false))
|
||||
assert_true(!s.m.drawer) // too short
|
||||
}
|
||||
@@ -601,10 +580,8 @@ test "a widget: hold opens resize handles; drag the handles; Done" {
|
||||
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
|
||||
assert_eq(s.m.resizing, 0) // no item menu for a widget: handles
|
||||
assert_eq(s.m.sheet, NoSheet)
|
||||
assert_true(s.has_effect(QueryLimits(100))) // queried immediately on entering resize mode
|
||||
let html = @vdom.to_html(s.tree[0])
|
||||
assert_true(html.contains("resize-handle"))
|
||||
assert_true(@vdom.to_html(s.tree[1]).contains("5 × 2"))
|
||||
assert_true(
|
||||
@vdom.to_html(s.tree[1]).contains(
|
||||
"Drag to move, or drag the handles to resize",
|
||||
@@ -615,10 +592,10 @@ test "a widget: hold opens resize handles; drag the handles; Done" {
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "b")) })
|
||||
.unwrap()
|
||||
s.press(hc, x=100.0, y=150.0 + 2.0 * 72.0 + 70.0)
|
||||
assert_true(s.has_effect(QueryLimits(100)))
|
||||
s.move_to(100.0, 150.0 + 3.0 * 72.0 + 40.0)
|
||||
s.release()
|
||||
assert_eq(s.m.home[0].rows, 4)
|
||||
assert_true(@vdom.to_html(s.tree[1]).contains("5 × 4"))
|
||||
assert_eq(s.m.resizing, 0) // handles stay
|
||||
// the right handle to three columns (the widget starts the full row)
|
||||
let rc = s
|
||||
@@ -629,7 +606,6 @@ test "a widget: hold opens resize handles; drag the handles; Done" {
|
||||
s.move_to(c3x + 36.0, 170.0)
|
||||
s.release()
|
||||
assert_eq(s.m.home[0].w, 3)
|
||||
assert_true(@vdom.to_html(s.tree[1]).contains("3 × 4"))
|
||||
// pressing the widget's body picks it up at once; letting go keeps the handles
|
||||
let wc = s.chain("widget-slot")
|
||||
s.press(wc, x=wx, y=wy)
|
||||
@@ -660,19 +636,10 @@ test "resizing stays within the widget's limits" {
|
||||
)
|
||||
let (wx, wy) = cell_center(2, 0)
|
||||
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
|
||||
let html = @vdom.to_html(s.tree[0])
|
||||
assert_true(
|
||||
html.contains("data-edge=\"l\"") && html.contains("data-edge=\"r\""),
|
||||
)
|
||||
assert_true(
|
||||
!html.contains("data-edge=\"t\"") &&
|
||||
!html.contains("data-edge=\"b\"") &&
|
||||
!html.contains("data-edge=\"rb\""),
|
||||
)
|
||||
let rc = s
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "r")) })
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "rb")) })
|
||||
.unwrap()
|
||||
s.press(rc, x=370.0, y=200.0)
|
||||
s.press(rc, x=370.0, y=250.0)
|
||||
s.move_to(60.0, 600.0) // far left and down
|
||||
s.release()
|
||||
assert_eq(s.m.home[0].w, 3) // 3 columns = 204px, the nearest to 200 within the limit
|
||||
@@ -736,8 +703,6 @@ test "back and home close things from the top down" {
|
||||
assert_eq(s.m.sheet, NoSheet)
|
||||
assert_true(s.m.drawer)
|
||||
s.send(Back)
|
||||
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||
s.finish_drawer_close()
|
||||
assert_true(!s.m.drawer)
|
||||
s.send(OpenDrawer)
|
||||
s.send(GoHome)
|
||||
@@ -757,7 +722,7 @@ test "the layout is saved on every change and restored" {
|
||||
}
|
||||
assert_eq(saved, save_json(s.m.home))
|
||||
let s2 = Sim::new()
|
||||
s2.run(update(s2.m, Restore(saved=Some(saved), legacy=None, icon_size=None)))
|
||||
s2.run(update(s2.m, Restore(saved=Some(saved), legacy=None)))
|
||||
assert_eq(s2.home_names(), ["Chrome", "Gmail"])
|
||||
// restoring what is already saved doesn't save it again
|
||||
let n = s2.log.filter(fn(e) { e is SaveHome(_) }).length() - 1 // Sim::new saved the empty one
|
||||
@@ -783,7 +748,7 @@ test "the old WebView build's home screen is brought over once" {
|
||||
assert_eq(legacy_import("{}", Ref(1)).length(), 0)
|
||||
assert_eq(legacy_import("garbage", Ref(1)).length(), 0)
|
||||
let s = Sim::new()
|
||||
s.run(update(s.m, Restore(saved=None, legacy=Some(legacy), icon_size=None)))
|
||||
s.run(update(s.m, Restore(saved=None, legacy=Some(legacy))))
|
||||
assert_eq(s.m.home.length(), 2)
|
||||
assert_true(s.log.contains(SaveHome(save_json(s.m.home)))) // saved in the new format
|
||||
// a saved layout wins over the old one
|
||||
@@ -794,7 +759,6 @@ test "the old WebView build's home screen is brought over once" {
|
||||
Restore(
|
||||
saved=Some(save_json([slot_app("c.gmail/.Main")])),
|
||||
legacy=Some(legacy),
|
||||
icon_size=None,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -928,7 +892,7 @@ test "view snapshot: home with an app" {
|
||||
#| <span class="magnifier" aria-hidden="true"></span>
|
||||
#| <span>Search apps</span>
|
||||
#| </button>
|
||||
#| <ul class="slots" style="--s:1;grid-template-columns:repeat(5,minmax(0,1fr));grid-template-rows:repeat(8,64px)">
|
||||
#| <ul class="slots" style="grid-template-columns:repeat(5,minmax(0,1fr));grid-template-rows:repeat(8,64px)">
|
||||
#| <li class="tile" data-slot="0" style="grid-column:1 / span 1;grid-row:1 / span 1" on="tap press">
|
||||
#| <img class="icon" alt="" draggable="false" data-icon="i3"></img>
|
||||
#| <span class="name">Chrome</span>
|
||||
@@ -938,403 +902,3 @@ test "view snapshot: home with an app" {
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
test "RecentsUnavailable opens setup sheet with settings and app info actions" {
|
||||
let s = Sim::new()
|
||||
s.send(RecentsUnavailable)
|
||||
assert_eq(s.m.sheet, RecentsSetup)
|
||||
let html = s.sheet_html()
|
||||
assert_true(html.contains("Enable window list"))
|
||||
assert_true(html.contains("Restricted setting"))
|
||||
assert_true(html.contains("Allow restricted settings"))
|
||||
s.tap("btn", label="Open Accessibility settings")
|
||||
assert_true(s.has_effect(OpenAccessibilitySettings))
|
||||
assert_eq(s.m.sheet, RecentsSetup)
|
||||
s.tap("btn", label="Open App info")
|
||||
assert_true(s.has_effect(OpenSelfAppInfo))
|
||||
assert_eq(s.m.sheet, RecentsSetup)
|
||||
s.tap("btn", label="Close")
|
||||
assert_eq(s.m.sheet, NoSheet)
|
||||
}
|
||||
|
||||
///|
|
||||
test "drawer close animation lifecycle and reopening cancels stale close" {
|
||||
let s = Sim::new()
|
||||
s.send(OpenDrawer)
|
||||
assert_true(s.m.drawer_open())
|
||||
s.send(CloseDrawer)
|
||||
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||
assert_true(!s.m.drawer_open())
|
||||
assert_true(s.has_effect(HideKeyboard))
|
||||
let stale_gen = s.m.drawer_gen
|
||||
assert_true(s.has_effect(Delay(140, DrawerClosed(stale_gen))))
|
||||
assert_true(@vdom.to_html(s.tree[1]).contains("drawer closing"))
|
||||
// Reopening while closing cancels the pending close
|
||||
s.send(OpenDrawer)
|
||||
assert_true(s.m.drawer_open())
|
||||
assert_true(!s.m.drawer_closing)
|
||||
s.send(DrawerClosed(stale_gen))
|
||||
assert_true(s.m.drawer_open())
|
||||
// Launching an app closes immediately with no closing animation delay
|
||||
s.tap("tile", label="Chrome", from=1)
|
||||
assert_true(s.has_effect(Launch("c.chrome/.Main")))
|
||||
assert_true(!s.m.drawer && !s.m.drawer_closing)
|
||||
// First-match Enter and GoHome also close immediately
|
||||
s.send(OpenDrawer)
|
||||
let c = s.chain("input")
|
||||
s.run(typed(s.m, s.table, c, "cal"))
|
||||
s.run(key(s.m, s.table, c, Enter))
|
||||
assert_true(!s.m.drawer && !s.m.drawer_closing)
|
||||
}
|
||||
|
||||
///|
|
||||
test "top-level view nodes have distinct non-zero keys" {
|
||||
let s = Sim::new()
|
||||
s.send(OpenDrawer)
|
||||
s.send(AppMenu(0))
|
||||
s.m.notice = "Added to home"
|
||||
let keys : Array[Int32] = []
|
||||
for n in view(s.m) {
|
||||
if n is El(e) {
|
||||
assert_true(e.key != 0)
|
||||
assert_true(!keys.contains(e.key))
|
||||
keys.push(e.key)
|
||||
}
|
||||
}
|
||||
assert_eq(keys, [1, 2, 3, 4, 6])
|
||||
}
|
||||
|
||||
///|
|
||||
test "left/right/top/bottom resize anchors opposite edge and pins unpinned widget" {
|
||||
let s = Sim::new()
|
||||
s.add_apps(["Chrome", "Gmail", "Phone"])
|
||||
s.send(PickWidget)
|
||||
s.send(WidgetsLoaded(Some(widgets_json)))
|
||||
s.send(ChooseWidget(0))
|
||||
s.send(WidgetAdded(100))
|
||||
s.send(
|
||||
LimitsKnown(
|
||||
100,
|
||||
Some("{\"w\":130,\"minW\":64,\"minH\":64,\"h\":true,\"v\":true}"),
|
||||
),
|
||||
)
|
||||
// Unpinned 2x2 widget starts at (3, 0) beside the 3 apps; resizing Right pins it at (3, 0)
|
||||
// and widening past the right edge caps at 5 - 3 = 2 columns without shifting x or jumping rows
|
||||
assert_eq((s.m.home[3].x, s.m.home[3].y, s.m.home[3].w), (-1, -1, 2))
|
||||
let (wx, wy) = cell_center(3, 0)
|
||||
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
|
||||
let rc = s
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "r")) })
|
||||
.unwrap()
|
||||
s.press(rc, x=374.0, y=200.0)
|
||||
s.move_to(520.0, 200.0)
|
||||
s.release()
|
||||
assert_eq((s.m.home[3].x, s.m.home[3].y, s.m.home[3].w), (3, 0, 2))
|
||||
|
||||
// Place widget at (2, 2) and test Left + Top handles keeping right/bottom anchored
|
||||
s.m.home[3].x = 2
|
||||
s.m.home[3].y = 2
|
||||
s.m.home[3].w = 2
|
||||
s.m.home[3].rows = 2
|
||||
s.refresh()
|
||||
let lc = s
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "l")) })
|
||||
.unwrap()
|
||||
let (c1x, c2y) = cell_center(1, 2)
|
||||
s.press(lc, x=c1x + 40.0, y=c2y)
|
||||
s.move_to(c1x - 32.0, c2y) // grow left by 1 col -> (1, 2), w=3 (right_col stays 4)
|
||||
assert_eq((s.m.home[3].x, s.m.home[3].w), (1, 3))
|
||||
s.move_to(-100.0, c2y) // clamp at col 0 -> (0, 2), w=4 (right_col stays 4)
|
||||
assert_eq((s.m.home[3].x, s.m.home[3].w), (0, 4))
|
||||
let (c2x, _) = cell_center(2, 2)
|
||||
s.move_to(c2x + 40.0, c2y) // shrink back to 1 col -> (3, 2), w=1 (right_col stays 4)
|
||||
s.release()
|
||||
assert_eq((s.m.home[3].x, s.m.home[3].w), (3, 1))
|
||||
|
||||
let tc = s
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "t")) })
|
||||
.unwrap()
|
||||
let (c3x, c1y) = cell_center(3, 1)
|
||||
s.press(tc, x=c3x, y=150.0 + 2.0 * 72.0)
|
||||
s.move_to(c3x, c1y - 24.0) // grow up by 1 row -> row 1, rows=3 (bottom_row stays 4)
|
||||
assert_eq((s.m.home[3].y, s.m.home[3].rows), (1, 3))
|
||||
s.move_to(c3x, -50.0) // clamp at row 0 -> row 0, rows=4 (bottom_row stays 4)
|
||||
assert_eq((s.m.home[3].y, s.m.home[3].rows), (0, 4))
|
||||
let (_, c3y) = cell_center(3, 3)
|
||||
s.move_to(c3x, c3y - 24.0) // shrink down to 1 row -> row 3, rows=1 (bottom_row stays 4)
|
||||
s.release()
|
||||
assert_eq((s.m.home[3].y, s.m.home[3].rows), (3, 1))
|
||||
}
|
||||
|
||||
///|
|
||||
test "holding a resize handle for 500ms does not lift widget or corrupt resize state" {
|
||||
let s = Sim::new()
|
||||
s.send(PickWidget)
|
||||
s.send(WidgetsLoaded(Some(widgets_json)))
|
||||
s.send(ChooseWidget(0))
|
||||
s.send(WidgetAdded(100))
|
||||
s.send(
|
||||
LimitsKnown(
|
||||
100,
|
||||
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":true,\"v\":true}"),
|
||||
),
|
||||
)
|
||||
let (wx, wy) = cell_center(2, 0)
|
||||
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
|
||||
let rc = s
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "r")) })
|
||||
.unwrap()
|
||||
s.press(rc, x=370.0, y=170.0)
|
||||
s.hold()
|
||||
assert_eq(s.m.resizing, 0)
|
||||
assert_eq(s.m.lifted, -1)
|
||||
assert_true(s.m.resize is Some(_))
|
||||
let (c2x, _) = cell_center(1, 0)
|
||||
s.move_to(c2x + 36.0, 170.0)
|
||||
s.release()
|
||||
assert_eq(s.m.home[0].w, 2)
|
||||
assert_eq(s.m.resizing, 0)
|
||||
assert_eq(s.m.lifted, -1)
|
||||
assert_eq(s.m.sheet, NoSheet)
|
||||
}
|
||||
|
||||
///|
|
||||
test "scrolled Measured keeps nrows constant and resizes in viewport coordinates" {
|
||||
let s = Sim::new()
|
||||
s.send(PickWidget)
|
||||
s.send(WidgetsLoaded(Some(widgets_json)))
|
||||
s.send(ChooseWidget(0))
|
||||
s.send(WidgetAdded(100))
|
||||
s.send(
|
||||
LimitsKnown(
|
||||
100,
|
||||
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":true,\"v\":true}"),
|
||||
),
|
||||
)
|
||||
let unscrolled_rows = s.m.nrows
|
||||
// Scrolled down 200px: grid_top in viewport moved from 150 to -50
|
||||
s.send(
|
||||
Measured(
|
||||
vw=390,
|
||||
vh=800,
|
||||
grid_left=16.0,
|
||||
grid_top=-50.0,
|
||||
grid_w=358.0,
|
||||
bottom_pad=24.0,
|
||||
scroll_y=200.0,
|
||||
),
|
||||
)
|
||||
assert_eq(s.m.nrows, unscrolled_rows)
|
||||
let (wx, wy) = cell_center(2, 0)
|
||||
s.long_press(s.chain("widget-slot"), x=wx, y=wy - 200.0)
|
||||
let bc = s
|
||||
.chain_where(fn(e) { e.attrs.contains(("data-edge", "b")) })
|
||||
.unwrap()
|
||||
s.press(bc, x=100.0, y=-50.0 + 2.0 * 72.0)
|
||||
s.move_to(100.0, -50.0 + 3.0 * 72.0 - 8.0) // 3 rows in scrolled viewport coords
|
||||
s.release()
|
||||
assert_eq(s.m.home[0].rows, 3)
|
||||
}
|
||||
|
||||
///|
|
||||
test "only supported resize handles render per widget resizeMode" {
|
||||
let s = Sim::new()
|
||||
s.send(PickWidget)
|
||||
s.send(WidgetsLoaded(Some(widgets_json)))
|
||||
s.send(ChooseWidget(0))
|
||||
s.send(WidgetAdded(100))
|
||||
s.send(
|
||||
LimitsKnown(
|
||||
100,
|
||||
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":false,\"v\":true}"),
|
||||
),
|
||||
)
|
||||
let (wx, wy) = cell_center(2, 0)
|
||||
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
|
||||
let v_only = @vdom.to_html(s.tree[0])
|
||||
assert_true(
|
||||
v_only.contains("data-edge=\"t\"") && v_only.contains("data-edge=\"b\""),
|
||||
)
|
||||
assert_true(
|
||||
!v_only.contains("data-edge=\"l\"") &&
|
||||
!v_only.contains("data-edge=\"r\"") &&
|
||||
!v_only.contains("data-edge=\"rb\""),
|
||||
)
|
||||
s.send(
|
||||
LimitsKnown(
|
||||
100,
|
||||
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":false,\"v\":false}"),
|
||||
),
|
||||
)
|
||||
s.refresh()
|
||||
let none_html = @vdom.to_html(s.tree[0])
|
||||
assert_true(!none_html.contains("resize-handle"))
|
||||
}
|
||||
|
||||
///|
|
||||
/// Type a value into the icon size slider, as the page reports it.
|
||||
fn Sim::slide(self : Sim, value : String) -> Unit {
|
||||
let chain = self.chain("icon-size-slider")
|
||||
self.run(typed(self.m, self.table, chain, value))
|
||||
}
|
||||
|
||||
///|
|
||||
fn Sim::open_icon_size(self : Sim) -> Unit {
|
||||
self.long_press(self.chain("home"))
|
||||
self.tap("sheet-item", label="Icon size")
|
||||
}
|
||||
|
||||
///|
|
||||
fn Sim::saved_sizes(self : Sim) -> Array[Int32] {
|
||||
let out = []
|
||||
for e in self.log {
|
||||
if e is SaveIconSize(p) {
|
||||
out.push(p)
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: the default is today's layout and nothing is saved at boot" {
|
||||
let s = Sim::new()
|
||||
assert_eq(s.m.icon_pct, 100)
|
||||
assert_eq((s.m.cols, s.m.nrows, s.m.cell_h(), s.m.drawer_cols), (5, 8, 64, 4))
|
||||
assert_eq(s.saved_sizes(), [])
|
||||
s.add_apps(["Chrome"])
|
||||
let html = @vdom.to_html(s.tree[0])
|
||||
assert_true(html.contains("--s:1;grid-template-columns:repeat(5,"))
|
||||
assert_true(html.contains("grid-template-rows:repeat(8,64px)"))
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: the home menu opens the sheet; the slider resizes live, columns and rows reflow, and it is saved" {
|
||||
let s = Sim::new()
|
||||
s.add_apps(["Chrome", "Gmail", "Phone"])
|
||||
s.open_icon_size()
|
||||
assert_eq(s.m.sheet, IconSize)
|
||||
let html = s.sheet_html()
|
||||
assert_true(html.contains("type=\"range\""))
|
||||
assert_true(html.contains("min=\"70\""))
|
||||
assert_true(html.contains("max=\"160\""))
|
||||
assert_true(html.contains("100%"))
|
||||
s.slide("130")
|
||||
assert_eq(s.m.icon_pct, 130)
|
||||
assert_eq((s.m.cols, s.m.cell_h(), s.m.drawer_cols), (4, 83, 3))
|
||||
assert_eq(s.m.nrows, @grid.rows_fit(s.m.avail_h, ch=83))
|
||||
assert_eq(s.saved_sizes(), [130])
|
||||
assert_true(s.sheet_html().contains("130%"))
|
||||
// the home grid behind the sheet changed too
|
||||
let home = @vdom.to_html(s.tree[0])
|
||||
assert_true(home.contains("--s:1.3;grid-template-columns:repeat(4,"))
|
||||
assert_true(home.contains("repeat(8,83px)") || home.contains("83px"))
|
||||
// and the drawer's list
|
||||
s.send(CloseSheet)
|
||||
s.send(OpenDrawer)
|
||||
let drawer = @vdom.to_html(s.tree[1])
|
||||
assert_true(drawer.contains("--s:1.3;grid-template-columns:repeat(3,"))
|
||||
// no cell leaves the grid or overlaps
|
||||
let packed = s.m.packed()
|
||||
for c in packed.cells {
|
||||
if c is Some(c) {
|
||||
assert_true(c.col >= 0 && c.col + c.w <= s.m.cols)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: presets, and Medium is the original size" {
|
||||
let s = Sim::new()
|
||||
s.open_icon_size()
|
||||
s.tap("btn", label="Small")
|
||||
assert_eq(s.m.icon_pct, 80)
|
||||
s.tap("btn", label="Large")
|
||||
assert_eq(s.m.icon_pct, 130)
|
||||
s.tap("btn", label="Medium")
|
||||
assert_eq(s.m.icon_pct, 100)
|
||||
assert_eq((s.m.cols, s.m.cell_h()), (5, 64))
|
||||
assert_eq(s.saved_sizes(), [80, 130, 100])
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: small icons fit more columns and rows" {
|
||||
let s = Sim::new()
|
||||
s.send(IconPreset(70))
|
||||
assert_eq((s.m.cols, s.m.cell_h(), s.m.drawer_cols), (7, 45, 6))
|
||||
assert_true(s.m.nrows > 8)
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: a saved size is restored without being saved again" {
|
||||
let s = Sim::new()
|
||||
s.run(update(s.m, Restore(saved=None, legacy=None, icon_size=Some("115"))))
|
||||
assert_eq(s.m.icon_pct, 115)
|
||||
assert_eq(s.m.cols, 4) // 5 * 100 / 115 = 4.3
|
||||
assert_eq(s.m.icon_error, "")
|
||||
assert_eq(s.saved_sizes(), [])
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: a corrupt saved size is reported loudly and not overwritten" {
|
||||
for bad in ["abc", "", "1.5", "65", "500", "-10", "102"] {
|
||||
let s = Sim::new()
|
||||
s.run(update(s.m, Restore(saved=None, legacy=None, icon_size=Some(bad))))
|
||||
assert_true(s.m.icon_error.has_prefix("saved icon size"))
|
||||
assert_true(
|
||||
s.log.any(fn(e) {
|
||||
e is LogError(l) && l.contains("launcher: saved icon size")
|
||||
}),
|
||||
)
|
||||
assert_true(s.m.notice.has_prefix("Icon size problem: saved icon size"))
|
||||
// the layout is the original one, and the bad value is not rewritten
|
||||
assert_eq((s.m.icon_pct, s.m.cols), (100, 5))
|
||||
assert_eq(s.saved_sizes(), [])
|
||||
// the sheet shows the error until a size is chosen
|
||||
s.open_icon_size()
|
||||
assert_true(s.sheet_html().contains("role=\"alert\""))
|
||||
s.tap("btn", label="Medium")
|
||||
assert_eq(s.m.icon_error, "")
|
||||
assert_eq(s.saved_sizes(), [100]) // choosing replaces the corrupt value
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: an out-of-range slider value changes nothing and is reported" {
|
||||
let s = Sim::new()
|
||||
s.open_icon_size()
|
||||
s.send(SetIconSize("900"))
|
||||
assert_eq(s.m.icon_pct, 100)
|
||||
assert_true(s.m.icon_error.contains("outside 70..160"))
|
||||
assert_true(s.log.any(fn(e) { e is LogError(_) }))
|
||||
assert_eq(s.saved_sizes(), [])
|
||||
s.send(IconPreset(33))
|
||||
assert_eq(s.m.icon_pct, 100)
|
||||
assert_true(s.m.icon_error.contains("not a valid icon size"))
|
||||
}
|
||||
|
||||
///|
|
||||
test "icon size: dragging an icon finds the cell under the pointer at a larger size" {
|
||||
let s = Sim::new()
|
||||
s.add_apps(["Chrome", "Gmail", "Phone"])
|
||||
s.send(IconPreset(130)) // 4 columns of 83px rows
|
||||
s.send(CloseSheet)
|
||||
let ch = s.m.cell_h()
|
||||
assert_eq(ch, 83)
|
||||
let col_w = s.m.col_w
|
||||
let center = fn(c : Int32, r : Int32) {
|
||||
(
|
||||
s.m.grid_left + c.to_double() * (col_w + 8.0) + col_w / 2.0,
|
||||
s.m.grid_top + r.to_double() * (ch + 8).to_double() + ch.to_double() / 2.0,
|
||||
)
|
||||
}
|
||||
let (px, py) = center(2, 0)
|
||||
let (tx, ty) = center(3, 2)
|
||||
s.press(s.chain("tile", label="Phone"), x=px, y=py)
|
||||
s.hold()
|
||||
s.move_to(tx - 30.0, ty)
|
||||
s.move_to(tx, ty)
|
||||
s.release()
|
||||
assert_eq((s.m.home[2].x, s.m.home[2].y), (3, 2))
|
||||
assert_eq(s.m.packed().cells[2], Some({ col: 3, row: 2, w: 1, h: 1, }))
|
||||
}
|
||||
+64
-246
@@ -78,50 +78,6 @@ pub fn Model::hidden(self : Model, i : Int32) -> Bool {
|
||||
self.home[i].kind == App && self.app_row(self.home[i].str) < 0
|
||||
}
|
||||
|
||||
///|
|
||||
/// Height of a home row at the current icon size.
|
||||
pub fn Model::cell_h(self : Model) -> Int32 {
|
||||
@grid.cell_height(self.icon_pct)
|
||||
}
|
||||
|
||||
///|
|
||||
/// Columns, rows and column width from the last measurement and the icon size. Run when
|
||||
/// either changes.
|
||||
fn Model::relayout(self : Model) -> Unit {
|
||||
if self.vw <= 0 {
|
||||
return // not measured yet
|
||||
}
|
||||
self.cols = @grid.home_columns(self.vw, self.grid_w, self.icon_pct)
|
||||
self.col_w = @grid.column_width(self.grid_w, self.cols)
|
||||
self.nrows = @grid.rows_fit(self.avail_h, ch=self.cell_h())
|
||||
self.drawer_cols = @grid.drawer_columns(self.vw, self.icon_pct)
|
||||
}
|
||||
|
||||
///|
|
||||
/// Apply a new icon size (already valid): lay out again and save it.
|
||||
fn Model::set_icon_pct(self : Model, pct : Int32, fx : Array[Effect]) -> Unit {
|
||||
self.icon_error = ""
|
||||
if pct == self.icon_pct {
|
||||
fx.push(SaveIconSize(pct)) // also replaces a corrupt stored value
|
||||
return
|
||||
}
|
||||
self.icon_pct = pct
|
||||
self.relayout()
|
||||
fx.push(SaveIconSize(pct))
|
||||
}
|
||||
|
||||
///|
|
||||
/// The icon size is unusable: say so on screen and in the log; nothing is changed.
|
||||
fn Model::icon_size_error(
|
||||
self : Model,
|
||||
reason : String,
|
||||
fx : Array[Effect],
|
||||
) -> Unit {
|
||||
self.icon_error = reason
|
||||
fx.push(LogError("launcher: \{reason}"))
|
||||
self.say("Icon size problem: \{reason}", fx)
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn Model::packed(self : Model) -> @grid.Packed {
|
||||
@grid.pack(self.home, self.cols, self.nrows, hidden=fn(i) { self.hidden(i) })
|
||||
@@ -199,48 +155,13 @@ fn Model::drop_gone(self : Model, fx : Array[Effect]) -> Unit {
|
||||
self.gone = ""
|
||||
}
|
||||
|
||||
///|
|
||||
/// Whether the drawer is open and not currently animating out.
|
||||
pub fn Model::drawer_open(self : Model) -> Bool {
|
||||
self.drawer && !self.drawer_closing
|
||||
}
|
||||
|
||||
///|
|
||||
/// App icon keys in priority order: home-screen apps first, then the rest of the app list.
|
||||
pub fn Model::icon_keys(self : Model) -> Array[String] {
|
||||
let out : Array[String] = []
|
||||
let seen : Map[String, Bool] = Map([])
|
||||
for s in self.home {
|
||||
if s.kind == App {
|
||||
let row = self.app_row(s.str)
|
||||
if row >= 0 {
|
||||
let k = self.apps[row].icon
|
||||
if k != "" && !seen.contains(k) {
|
||||
seen[k] = true
|
||||
out.push(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for a in self.apps {
|
||||
let k = a.icon
|
||||
if k != "" && !seen.contains(k) {
|
||||
seen[k] = true
|
||||
out.push(k)
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
///|
|
||||
fn Model::close_all(self : Model, fx : Array[Effect]) -> Unit {
|
||||
if self.drawer && !self.drawer_closing {
|
||||
if self.drawer {
|
||||
fx.push(HideKeyboard)
|
||||
}
|
||||
self.query = ""
|
||||
self.drawer = false
|
||||
self.drawer_closing = false
|
||||
self.drawer_gen += 1
|
||||
self.picking = false
|
||||
self.sheet = NoSheet
|
||||
self.lifted = -1
|
||||
@@ -252,23 +173,19 @@ fn Model::close_all(self : Model, fx : Array[Effect]) -> Unit {
|
||||
|
||||
///|
|
||||
fn Model::open_drawer(self : Model, fx : Array[Effect]) -> Unit {
|
||||
if self.sheet == NoSheet && !self.drawer_open() {
|
||||
if self.sheet == NoSheet && !self.drawer {
|
||||
self.drawer = true
|
||||
self.drawer_closing = false
|
||||
self.drawer_gen += 1
|
||||
self.picking = false
|
||||
self.query = ""
|
||||
fx.push(FocusSearch)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
fn Model::close_drawer(self : Model, fx : Array[Effect]) -> Unit {
|
||||
if self.drawer_open() && self.sheet == NoSheet {
|
||||
self.drawer_closing = true
|
||||
self.drawer_gen += 1
|
||||
if self.drawer && self.sheet == NoSheet {
|
||||
self.drawer = false
|
||||
self.picking = false
|
||||
self.query = ""
|
||||
fx.push(HideKeyboard)
|
||||
fx.push(Delay(140, DrawerClosed(self.drawer_gen)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +200,7 @@ fn Model::slot_box(
|
||||
) -> (Double, Double, Double, Double)? {
|
||||
match packed.cells[i] {
|
||||
Some(c) => {
|
||||
let (x, y, w, h) = @grid.box(c, self.col_w, ch=self.cell_h())
|
||||
let (x, y, w, h) = @grid.box(c, self.col_w)
|
||||
Some((x + self.grid_left, y + self.grid_top, w, h))
|
||||
}
|
||||
None => None
|
||||
@@ -347,12 +264,11 @@ fn Model::drag_lifted(
|
||||
return
|
||||
}
|
||||
let half_w = self.col_w / 2.0
|
||||
let half_h = self.cell_h().to_double() / 2.0
|
||||
let half_h = @grid.cell_px.to_double() / 2.0
|
||||
let (fc, fr) = @grid.cell_at(
|
||||
x - self.grid_left - half_w,
|
||||
y - self.grid_top - half_h,
|
||||
self.col_w,
|
||||
ch=self.cell_h(),
|
||||
)
|
||||
let mut to = self.slot_at(packed, x, y)
|
||||
if to < 0 {
|
||||
@@ -360,7 +276,7 @@ fn Model::drag_lifted(
|
||||
fc.to_double() * (self.col_w + @grid.col_gap.to_double()) +
|
||||
half_w
|
||||
let cy = self.grid_top +
|
||||
fr.to_double() * (self.cell_h() + @grid.row_gap).to_double() +
|
||||
fr.to_double() * (@grid.cell_px + @grid.row_gap).to_double() +
|
||||
half_h
|
||||
to = self.slot_at(packed, cx, cy)
|
||||
}
|
||||
@@ -373,7 +289,7 @@ fn Model::drag_lifted(
|
||||
return
|
||||
}
|
||||
let grid_bottom = self.grid_top +
|
||||
(packed.rows * (self.cell_h() + @grid.row_gap)).to_double()
|
||||
(packed.rows * (@grid.cell_px + @grid.row_gap)).to_double()
|
||||
if y > grid_bottom {
|
||||
return // below the grid
|
||||
}
|
||||
@@ -381,7 +297,6 @@ fn Model::drag_lifted(
|
||||
x - self.grid_left - carry.dx,
|
||||
y - self.grid_top - carry.dy,
|
||||
self.col_w,
|
||||
ch=self.cell_h(),
|
||||
)
|
||||
let cell = row * 64 + @cmp.minimum(col, 63)
|
||||
if cell != carry.cell {
|
||||
@@ -394,7 +309,7 @@ fn Model::drag_lifted(
|
||||
/// The pointer is up. Letting go without moving opens the item's menu (a widget gets
|
||||
/// resize handles instead); letting go of a dragged one just drops it, and whatever it
|
||||
/// then covers moves on to free cells.
|
||||
fn Model::drop_lifted(self : Model, moved : Bool, fx : Array[Effect]) -> Unit {
|
||||
fn Model::drop_lifted(self : Model, moved : Bool) -> Unit {
|
||||
self.carry = None
|
||||
if self.lifted < 0 || self.lifted >= self.home.length() {
|
||||
self.lifted = -1
|
||||
@@ -407,10 +322,7 @@ fn Model::drop_lifted(self : Model, moved : Bool, fx : Array[Effect]) -> Unit {
|
||||
}
|
||||
if !moved || self.regrab {
|
||||
match s.kind {
|
||||
Widget => {
|
||||
self.resizing = self.lifted
|
||||
fx.push(QueryLimits(s.wid))
|
||||
}
|
||||
Widget => self.resizing = self.lifted
|
||||
App => self.sheet = Item(self.lifted)
|
||||
}
|
||||
}
|
||||
@@ -425,34 +337,23 @@ fn Model::begin_resize(self : Model, edge : Edge, fx : Array[Effect]) -> Unit {
|
||||
return
|
||||
}
|
||||
let s = self.home[i]
|
||||
guard self.packed().cells[i] is Some(cell) else { return }
|
||||
s.x = cell.col
|
||||
s.y = cell.row
|
||||
let (bx, by, bw, bh) = @grid.box(cell, self.col_w, ch=self.cell_h())
|
||||
let left = self.grid_left + bx
|
||||
let top = self.grid_top + by
|
||||
let (left, top) = match self.slot_box(self.packed(), i) {
|
||||
Some(b) => (b.0, b.1)
|
||||
None => (self.grid_left, self.grid_top)
|
||||
}
|
||||
self.resize = Some({
|
||||
edge,
|
||||
slot: i,
|
||||
left,
|
||||
top,
|
||||
right: left + bw,
|
||||
bottom: top + bh,
|
||||
anchor_col: cell.col,
|
||||
anchor_row: cell.row,
|
||||
right_col: cell.col + cell.w,
|
||||
bottom_row: cell.row + cell.h,
|
||||
col: cell.col,
|
||||
row: cell.row,
|
||||
cols: cell.w,
|
||||
rows: cell.h,
|
||||
cols: s.cols(self.cols),
|
||||
rows: s.height(),
|
||||
})
|
||||
fx.push(QueryLimits(s.wid))
|
||||
}
|
||||
|
||||
///|
|
||||
/// Dragging a handle snaps the widget to whole columns and rows, within its limits
|
||||
/// and without shifting its anchored edge.
|
||||
/// Dragging a handle snaps the widget to whole columns and rows, within its limits.
|
||||
fn Model::drag_resize(
|
||||
self : Model,
|
||||
r : ResizeDrag,
|
||||
@@ -466,86 +367,42 @@ fn Model::drag_resize(
|
||||
let s = self.home[r.slot]
|
||||
let lim = self.limits.get(s.wid).unwrap_or(default_limits)
|
||||
let n = self.cols
|
||||
let mut col = r.col
|
||||
let mut row = r.row
|
||||
let mut cols = r.cols
|
||||
let mut rows = r.rows
|
||||
let cg = @grid.col_gap.to_double()
|
||||
let rg = @grid.row_gap.to_double()
|
||||
if lim.h {
|
||||
match r.edge {
|
||||
Right | Corner => {
|
||||
let hi = @cmp.maximum(1, n - r.anchor_col)
|
||||
cols = @grid.fit(
|
||||
x - r.left,
|
||||
1,
|
||||
hi,
|
||||
self.col_w,
|
||||
cg,
|
||||
lim.min_w,
|
||||
lim.max_w,
|
||||
)
|
||||
col = r.anchor_col
|
||||
}
|
||||
Left => {
|
||||
let hi = @cmp.maximum(1, @cmp.minimum(n, r.right_col))
|
||||
cols = @grid.fit(
|
||||
r.right - x,
|
||||
1,
|
||||
hi,
|
||||
self.col_w,
|
||||
cg,
|
||||
lim.min_w,
|
||||
lim.max_w,
|
||||
)
|
||||
col = r.right_col - cols
|
||||
}
|
||||
Top | Bottom => ()
|
||||
}
|
||||
if r.edge != Bottom && lim.h {
|
||||
cols = @grid.fit(
|
||||
x - r.left,
|
||||
1,
|
||||
n,
|
||||
self.col_w,
|
||||
@grid.col_gap.to_double(),
|
||||
lim.min_w,
|
||||
lim.max_w,
|
||||
)
|
||||
}
|
||||
if lim.v {
|
||||
match r.edge {
|
||||
Bottom | Corner => {
|
||||
rows = @grid.fit(
|
||||
y - r.top,
|
||||
1,
|
||||
20,
|
||||
self.cell_h().to_double(),
|
||||
rg,
|
||||
lim.min_h,
|
||||
lim.max_h,
|
||||
)
|
||||
row = r.anchor_row
|
||||
}
|
||||
Top => {
|
||||
let hi = @cmp.maximum(1, @cmp.minimum(20, r.bottom_row))
|
||||
rows = @grid.fit(
|
||||
r.bottom - y,
|
||||
1,
|
||||
hi,
|
||||
self.cell_h().to_double(),
|
||||
rg,
|
||||
lim.min_h,
|
||||
lim.max_h,
|
||||
)
|
||||
row = r.bottom_row - rows
|
||||
}
|
||||
Left | Right => ()
|
||||
}
|
||||
if r.edge != Right && lim.v {
|
||||
rows = @grid.fit(
|
||||
y - r.top,
|
||||
1,
|
||||
20,
|
||||
@grid.cell_px.to_double(),
|
||||
@grid.row_gap.to_double(),
|
||||
lim.min_h,
|
||||
lim.max_h,
|
||||
)
|
||||
}
|
||||
if col == r.col && row == r.row && cols == r.cols && rows == r.rows {
|
||||
if cols == r.cols && rows == r.rows {
|
||||
return
|
||||
}
|
||||
r.col = col
|
||||
r.row = row
|
||||
r.cols = cols
|
||||
r.rows = rows
|
||||
fx.push(Haptic)
|
||||
s.x = col
|
||||
s.y = row
|
||||
s.w = if cols >= n { 0 } else { cols }
|
||||
s.rows = rows
|
||||
@grid.clear_cells(self.home, r.slot, self.cols)
|
||||
if s.x >= 0 {
|
||||
@grid.pin(self.home, r.slot, s.x, s.y, self.cols, self.nrows)
|
||||
@grid.clear_cells(self.home, r.slot, self.cols)
|
||||
}
|
||||
}
|
||||
|
||||
// ---- update -------------------------------------------------------------------
|
||||
@@ -580,7 +437,7 @@ fn Model::choose_widget(self : Model, i : Int32, fx : Array[Effect]) -> Unit {
|
||||
///|
|
||||
fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
match msg {
|
||||
Restore(saved~, legacy~, icon_size~) => {
|
||||
Restore(saved~, legacy~) => {
|
||||
let next = Ref(m.next_key)
|
||||
let mut slots = None
|
||||
if saved is Some(text) {
|
||||
@@ -596,15 +453,6 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
m.home = s
|
||||
}
|
||||
m.next_key = next.val
|
||||
if icon_size is Some(text) {
|
||||
match @grid.parse_scale(text) {
|
||||
Ok(pct) => {
|
||||
m.icon_pct = pct
|
||||
m.relayout()
|
||||
}
|
||||
Err(reason) => m.icon_size_error("saved \{reason}", fx)
|
||||
}
|
||||
}
|
||||
fx.push(LoadApps)
|
||||
}
|
||||
Started(now~, last_check~, declined~, installed~) => {
|
||||
@@ -617,13 +465,12 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
fx.push(FetchRelease(@updater.release_api))
|
||||
}
|
||||
}
|
||||
Measured(vw~, vh~, grid_left~, grid_top~, grid_w~, bottom_pad~, scroll_y~) => {
|
||||
m.vw = vw
|
||||
Measured(vw~, vh~, grid_left~, grid_top~, grid_w~, bottom_pad~) => {
|
||||
m.cols = @grid.columns_for(vw)
|
||||
m.grid_left = grid_left
|
||||
m.grid_top = grid_top
|
||||
m.grid_w = grid_w
|
||||
m.avail_h = vh.to_double() - bottom_pad - (grid_top + scroll_y)
|
||||
m.relayout()
|
||||
m.col_w = @grid.column_width(grid_w, m.cols)
|
||||
m.nrows = @grid.rows_fit(vh.to_double() - bottom_pad - grid_top)
|
||||
}
|
||||
AppsLoaded(text) => {
|
||||
m.loading = false
|
||||
@@ -671,8 +518,11 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
m.resizing = -1
|
||||
} else if m.sheet != NoSheet {
|
||||
m.sheet = NoSheet
|
||||
} else if m.drawer_open() {
|
||||
m.close_drawer(fx)
|
||||
} else if m.drawer {
|
||||
m.drawer = false
|
||||
m.picking = false
|
||||
m.query = ""
|
||||
fx.push(HideKeyboard)
|
||||
}
|
||||
WidgetAdded(id) =>
|
||||
if m.chosen >= 0 &&
|
||||
@@ -683,7 +533,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
@grid.Slot::widget(
|
||||
w.label,
|
||||
id,
|
||||
rows=@grid.widget_rows(w.h, ch=m.cell_h()),
|
||||
rows=@grid.widget_rows(w.h),
|
||||
key=m.new_key(),
|
||||
),
|
||||
)
|
||||
@@ -693,7 +543,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
}
|
||||
WidgetMenu(wid) => {
|
||||
let i = m.slot_of_widget(wid)
|
||||
if i >= 0 && !m.drawer_open() && m.sheet == NoSheet {
|
||||
if i >= 0 && !m.drawer && m.sheet == NoSheet {
|
||||
m.resizing = -1
|
||||
m.regrab = false
|
||||
m.lifted = i
|
||||
@@ -702,7 +552,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
}
|
||||
WidgetGrab(wid) => {
|
||||
let i = m.slot_of_widget(wid)
|
||||
if i >= 0 && i == m.resizing && !m.drawer_open() && m.sheet == NoSheet {
|
||||
if i >= 0 && i == m.resizing && !m.drawer && m.sheet == NoSheet {
|
||||
m.resizing = -1
|
||||
m.regrab = true
|
||||
m.lifted = i
|
||||
@@ -722,13 +572,13 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
}
|
||||
NativeDrop(moved) => {
|
||||
m.native_from = None
|
||||
m.drop_lifted(moved, fx)
|
||||
m.drop_lifted(moved)
|
||||
}
|
||||
Touch(dx~, dy~, ms~, home_top~, list_end~) =>
|
||||
if !m.dragged && m.lifted < 0 && m.sheet == NoSheet {
|
||||
match @gesture.classify_swipe(dx, dy, ms) {
|
||||
Some(Down) => if !m.drawer_open() && home_top { m.open_drawer(fx) }
|
||||
Some(Up) => if m.drawer_open() && list_end { m.close_drawer(fx) }
|
||||
Some(Down) => if !m.drawer && home_top { m.open_drawer(fx) }
|
||||
Some(Up) => if m.drawer && list_end { m.close_drawer(fx) }
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
@@ -783,13 +633,6 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
WClear => m.wquery = ""
|
||||
OpenDrawer => m.open_drawer(fx)
|
||||
CloseDrawer => m.close_drawer(fx)
|
||||
DrawerClosed(gen) =>
|
||||
if gen == m.drawer_gen && m.drawer_closing {
|
||||
m.drawer = false
|
||||
m.drawer_closing = false
|
||||
m.picking = false
|
||||
m.query = ""
|
||||
}
|
||||
OpenApp(row) =>
|
||||
if row >= 0 && row < m.apps.length() {
|
||||
fx.push(Launch(m.apps[row].component))
|
||||
@@ -820,7 +663,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
}
|
||||
}
|
||||
AppMenu(row) =>
|
||||
if m.drawer_open() && m.sheet == NoSheet {
|
||||
if m.drawer && m.sheet == NoSheet {
|
||||
fx.push(Haptic)
|
||||
m.sheet = DrawerApp(row)
|
||||
}
|
||||
@@ -842,10 +685,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
PickApps => {
|
||||
m.sheet = NoSheet
|
||||
m.drawer = true
|
||||
m.drawer_closing = false
|
||||
m.drawer_gen += 1
|
||||
m.picking = true
|
||||
m.query = ""
|
||||
}
|
||||
PickWidget => {
|
||||
m.sheet = WidgetPicker
|
||||
@@ -878,29 +718,11 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
fx.push(OpenSettings)
|
||||
m.sheet = NoSheet
|
||||
}
|
||||
IconSizeMenu => m.sheet = IconSize
|
||||
SetIconSize(text) =>
|
||||
match @grid.parse_scale(text) {
|
||||
Ok(pct) => m.set_icon_pct(pct, fx)
|
||||
Err(reason) => m.icon_size_error(reason, fx)
|
||||
}
|
||||
IconPreset(pct) =>
|
||||
if @grid.scale_valid(pct) {
|
||||
m.set_icon_pct(pct, fx)
|
||||
} else {
|
||||
m.icon_size_error("preset \{pct} is not a valid icon size", fx)
|
||||
}
|
||||
Wallpaper => {
|
||||
fx.push(PickWallpaper)
|
||||
m.sheet = NoSheet
|
||||
}
|
||||
Recents => fx.push(OpenRecents)
|
||||
RecentsUnavailable => {
|
||||
m.resizing = -1
|
||||
m.sheet = RecentsSetup
|
||||
}
|
||||
OpenAccessibilitySettings => fx.push(OpenAccessibilitySettings)
|
||||
OpenSelfAppInfo => fx.push(OpenSelfAppInfo)
|
||||
CheckUpdates => {
|
||||
m.sheet = NoSheet
|
||||
if m.checking {
|
||||
@@ -913,18 +735,14 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
}
|
||||
}
|
||||
Lift(i) =>
|
||||
if !m.drawer_open() &&
|
||||
m.sheet == NoSheet &&
|
||||
m.resize is None &&
|
||||
i != m.lifted &&
|
||||
i < m.home.length() {
|
||||
if !m.drawer && m.sheet == NoSheet && i != m.lifted && i < m.home.length() {
|
||||
fx.push(Haptic)
|
||||
m.resizing = -1
|
||||
m.regrab = false
|
||||
m.lifted = i
|
||||
}
|
||||
Grab(i) =>
|
||||
if i >= 0 && i == m.resizing && !m.drawer_open() && m.sheet == NoSheet {
|
||||
if i >= 0 && i == m.resizing && !m.drawer && m.sheet == NoSheet {
|
||||
m.resizing = -1
|
||||
m.regrab = true
|
||||
m.lifted = i
|
||||
@@ -942,7 +760,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
||||
Released(moved~, held~) => {
|
||||
ignore(held)
|
||||
m.resize = None
|
||||
m.drop_lifted(moved, fx)
|
||||
m.drop_lifted(moved)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-214
@@ -22,17 +22,12 @@ fn cell_style(c : @grid.Cell) -> String {
|
||||
}
|
||||
|
||||
///|
|
||||
fn handle(edge : String, e : Edge, active : Bool) -> Node[Msg] {
|
||||
fn handle(edge : String, e : Edge) -> Node[Msg] {
|
||||
el(
|
||||
"span",
|
||||
classes=["resize-handle", cls_if("active", active)],
|
||||
classes=["resize-handle"],
|
||||
attrs=[("data-edge", edge), ("aria-hidden", "true")],
|
||||
handlers={
|
||||
..Handlers::none(),
|
||||
down: Some(ResizeBegin(e)),
|
||||
tap: Some(Nop),
|
||||
press: Some(Nop),
|
||||
},
|
||||
handlers={ ..Handlers::none(), down: Some(ResizeBegin(e)), tap: Some(Nop), },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -47,7 +42,7 @@ fn Model::view_slot(
|
||||
let style = cell_style(cell)
|
||||
match s.kind {
|
||||
Widget => {
|
||||
let live = !self.drawer_open() &&
|
||||
let live = !self.drawer &&
|
||||
self.sheet == NoSheet &&
|
||||
(self.resizing < 0 || i == self.resizing)
|
||||
let attrs = [("data-slot", i.to_string())]
|
||||
@@ -58,22 +53,9 @@ fn Model::view_slot(
|
||||
el("span", classes=["widget-label"], children=[text(s.str)]),
|
||||
]
|
||||
if i == self.resizing {
|
||||
let lim = self.limits.get(s.wid).unwrap_or(default_limits)
|
||||
let active = match self.resize {
|
||||
Some(r) if r.slot == i => Some(r.edge)
|
||||
_ => None
|
||||
}
|
||||
if lim.h {
|
||||
children.push(handle("l", Left, active == Some(Left)))
|
||||
children.push(handle("r", Right, active == Some(Right)))
|
||||
}
|
||||
if lim.v {
|
||||
children.push(handle("t", Top, active == Some(Top)))
|
||||
children.push(handle("b", Bottom, active == Some(Bottom)))
|
||||
}
|
||||
if lim.h && lim.v {
|
||||
children.push(handle("rb", Corner, active == Some(Corner)))
|
||||
}
|
||||
children.push(handle("r", Right))
|
||||
children.push(handle("b", Bottom))
|
||||
children.push(handle("rb", Corner))
|
||||
}
|
||||
Some(
|
||||
el(
|
||||
@@ -170,7 +152,7 @@ fn Model::view_home(self : Model) -> Node[Msg] {
|
||||
el(
|
||||
"ul",
|
||||
classes=["slots", cls_if("dragging", self.lifted >= 0)],
|
||||
style="--s:\{@grid.css_factor(self.icon_pct)};grid-template-columns:repeat(\{self.cols},minmax(0,1fr));grid-template-rows:repeat(\{rows},\{self.cell_h()}px)",
|
||||
style="grid-template-columns:repeat(\{self.cols},minmax(0,1fr));grid-template-rows:repeat(\{rows},\{@grid.cell_px}px)",
|
||||
children=slots,
|
||||
),
|
||||
]
|
||||
@@ -183,7 +165,6 @@ fn Model::view_home(self : Model) -> Node[Msg] {
|
||||
}
|
||||
el(
|
||||
"div",
|
||||
key=1,
|
||||
classes=["home"],
|
||||
handlers={
|
||||
..Handlers::none(),
|
||||
@@ -266,14 +247,7 @@ fn Model::view_drawer(self : Model) -> Node[Msg] {
|
||||
]),
|
||||
)
|
||||
}
|
||||
children.push(
|
||||
el(
|
||||
"ul",
|
||||
classes=["apps"],
|
||||
style="--s:\{@grid.css_factor(self.icon_pct)};grid-template-columns:repeat(\{self.drawer_cols},minmax(0,1fr))",
|
||||
children=tiles,
|
||||
),
|
||||
)
|
||||
children.push(el("ul", classes=["apps"], children=tiles))
|
||||
if self.loading {
|
||||
children.push(
|
||||
el("p", classes=["empty"], children=[text("Loading apps…")]),
|
||||
@@ -281,16 +255,7 @@ fn Model::view_drawer(self : Model) -> Node[Msg] {
|
||||
} else if tiles.length() == 0 {
|
||||
children.push(el("p", classes=["empty"], children=[text("No apps match.")]))
|
||||
}
|
||||
el(
|
||||
"div",
|
||||
key=2,
|
||||
classes=[
|
||||
"drawer",
|
||||
cls_if("picking", self.picking),
|
||||
cls_if("closing", self.drawer_closing),
|
||||
],
|
||||
children~,
|
||||
)
|
||||
el("div", classes=["drawer", cls_if("picking", self.picking)], children~)
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -303,107 +268,6 @@ fn sheet_title(label : String) -> Node[Msg] {
|
||||
el("h2", classes=["sheet-title"], children=[text(label)])
|
||||
}
|
||||
|
||||
///|
|
||||
fn preset_btn(label : String, pct : Int32, current : Int32) -> Node[Msg] {
|
||||
el(
|
||||
"button",
|
||||
classes=[
|
||||
"btn",
|
||||
if pct == current {
|
||||
"primary"
|
||||
} else {
|
||||
"outline"
|
||||
},
|
||||
"sm",
|
||||
cls_if("on", pct == current),
|
||||
],
|
||||
attrs=[("data-preset", pct.to_string())],
|
||||
handlers=tap(IconPreset(pct)),
|
||||
children=[text(label)],
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
/// The icon size sheet: a preview of a few real icons at the chosen size, the slider, the
|
||||
/// presets. The home grid behind the sheet changes with the slider as well.
|
||||
fn Model::view_icon_size(self : Model, items : Array[Node[Msg]]) -> Unit {
|
||||
let pct = self.icon_pct
|
||||
items.push(sheet_title("Icon size"))
|
||||
if self.icon_error != "" {
|
||||
items.push(
|
||||
el(
|
||||
"div",
|
||||
classes=["alert", "destructive", "icon-error"],
|
||||
attrs=[("role", "alert")],
|
||||
children=[
|
||||
el("div", classes=["alert-title"], children=[
|
||||
text("Icon size problem"),
|
||||
]),
|
||||
el("div", classes=["alert-description"], children=[
|
||||
text(self.icon_error),
|
||||
]),
|
||||
],
|
||||
),
|
||||
)
|
||||
}
|
||||
let sample : Array[Node[Msg]] = []
|
||||
for i in 0..<self.apps.length() {
|
||||
if sample.length() >= 4 {
|
||||
break
|
||||
}
|
||||
let a = self.apps[i]
|
||||
sample.push(
|
||||
el("li", key=i + 1, classes=["tile"], children=[
|
||||
icon(a.icon),
|
||||
el("span", classes=["name"], children=[text(a.label)]),
|
||||
]),
|
||||
)
|
||||
}
|
||||
items.push(
|
||||
el(
|
||||
"ul",
|
||||
classes=["icon-preview"],
|
||||
attrs=[("aria-label", "Preview")],
|
||||
style="--s:\{@grid.css_factor(pct)}",
|
||||
children=sample,
|
||||
),
|
||||
)
|
||||
items.push(
|
||||
el("div", classes=["icon-size-row"], children=[
|
||||
el(
|
||||
"input",
|
||||
classes=["icon-size-slider"],
|
||||
attrs=[
|
||||
("type", "range"),
|
||||
("min", @grid.scale_min.to_string()),
|
||||
("max", @grid.scale_max.to_string()),
|
||||
("step", @grid.scale_step.to_string()),
|
||||
("aria-label", "Icon size"),
|
||||
],
|
||||
props=[("value", pct.to_string())],
|
||||
handlers={ ..Handlers::none(), input: Some(fn(v) { SetIconSize(v) }), },
|
||||
),
|
||||
el("span", classes=["resize-size", "icon-size-value"], children=[
|
||||
text("\{pct}%"),
|
||||
]),
|
||||
]),
|
||||
)
|
||||
items.push(
|
||||
el("div", classes=["icon-presets"], children=[
|
||||
preset_btn("Small", @grid.scale_small, pct),
|
||||
preset_btn("Medium", @grid.scale_medium, pct),
|
||||
preset_btn("Large", @grid.scale_large, pct),
|
||||
]),
|
||||
)
|
||||
items.push(
|
||||
el("div", classes=["sheet-actions"], children=[
|
||||
el("button", classes=["btn", "ghost"], handlers=tap(CloseSheet), children=[
|
||||
text("Done"),
|
||||
]),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
||||
let items : Array[Node[Msg]] = []
|
||||
@@ -413,7 +277,6 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
||||
items.push(sheet_title("Home screen"))
|
||||
items.push(sheet_btn("Add apps", PickApps))
|
||||
items.push(sheet_btn("Add widget", PickWidget))
|
||||
items.push(sheet_btn("Icon size", IconSizeMenu))
|
||||
items.push(sheet_btn("Wallpaper", Wallpaper))
|
||||
items.push(sheet_btn("Settings", Settings))
|
||||
items.push(sheet_btn("Check for updates", CheckUpdates))
|
||||
@@ -516,71 +379,11 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
||||
)
|
||||
}
|
||||
}
|
||||
IconSize => self.view_icon_size(items)
|
||||
RecentsSetup => {
|
||||
items.push(sheet_title("Enable window list"))
|
||||
items.push(
|
||||
el("p", classes=["sheet-copy"], children=[
|
||||
text(
|
||||
"Android only lets accessibility services open Recents, and blocks them on sideloaded apps until you allow restricted settings once (it stays allowed across updates). This service reads nothing on screen.",
|
||||
),
|
||||
]),
|
||||
)
|
||||
items.push(
|
||||
el("ol", classes=["sheet-steps"], children=[
|
||||
el("li", children=[
|
||||
text("Tap "),
|
||||
el("strong", children=[text("Open Accessibility settings")]),
|
||||
text(" and tap "),
|
||||
el("strong", children=[text("ultra Home window list")]),
|
||||
text("."),
|
||||
]),
|
||||
el("li", children=[
|
||||
text("If Android says "),
|
||||
el("strong", children=[text("Restricted setting")]),
|
||||
text(", return here, tap "),
|
||||
el("strong", children=[text("Open App info")]),
|
||||
text(", then tap "),
|
||||
el("strong", children=[text("⋮")]),
|
||||
text(" (or scroll to the bottom on Android 15+) → "),
|
||||
el("strong", children=[text("Allow restricted settings")]),
|
||||
text("."),
|
||||
]),
|
||||
el("li", children=[
|
||||
text("Return to "),
|
||||
el("strong", children=[text("Accessibility settings")]),
|
||||
text(" and turn on "),
|
||||
el("strong", children=[text("ultra Home window list")]),
|
||||
text("."),
|
||||
]),
|
||||
]),
|
||||
)
|
||||
items.push(
|
||||
el("div", classes=["sheet-actions"], children=[
|
||||
el(
|
||||
"button",
|
||||
classes=["btn"],
|
||||
handlers=tap(OpenAccessibilitySettings),
|
||||
children=[text("Open Accessibility settings")],
|
||||
),
|
||||
el(
|
||||
"button",
|
||||
classes=["btn", "secondary"],
|
||||
handlers=tap(OpenSelfAppInfo),
|
||||
children=[text("Open App info")],
|
||||
),
|
||||
el("button", classes=["btn", "ghost"], handlers=tap(CloseSheet), children=[
|
||||
text("Close"),
|
||||
]),
|
||||
]),
|
||||
)
|
||||
}
|
||||
}
|
||||
[
|
||||
el("div", key=3, classes=["sheet-overlay"], handlers=tap(CloseSheet)),
|
||||
el("div", classes=["sheet-overlay"], handlers=tap(CloseSheet)),
|
||||
el(
|
||||
"div",
|
||||
key=4,
|
||||
classes=["sheet"],
|
||||
attrs=[("role", "dialog"), ("aria-modal", "true")],
|
||||
handlers={ ..Handlers::none(), escape: Some(CloseSheet), },
|
||||
@@ -591,10 +394,7 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
||||
|
||||
///|
|
||||
fn Model::view_resize_bar(self : Model) -> Node[Msg] {
|
||||
let s = self.home[self.resizing]
|
||||
let size = "\{s.cols(self.cols)} × \{s.height()}"
|
||||
el("div", key=5, classes=["resize-bar"], attrs=[("role", "toolbar")], children=[
|
||||
el("span", classes=["resize-size"], children=[text(size)]),
|
||||
el("div", classes=["resize-bar"], attrs=[("role", "toolbar")], children=[
|
||||
el("span", classes=["resize-hint"], children=[
|
||||
text("Drag to move, or drag the handles to resize"),
|
||||
]),
|
||||
@@ -619,12 +419,12 @@ pub fn view(m : Model) -> Array[Node[Msg]] {
|
||||
}
|
||||
if m.sheet != NoSheet {
|
||||
out.append(m.view_sheet())
|
||||
} else if m.resizing >= 0 && !m.drawer_open() {
|
||||
} else if m.resizing >= 0 && !m.drawer {
|
||||
out.push(m.view_resize_bar())
|
||||
}
|
||||
if m.notice != "" {
|
||||
out.push(
|
||||
el("div", key=6, classes=["notice"], attrs=[("role", "status")], children=[
|
||||
el("div", classes=["notice"], attrs=[("role", "status")], children=[
|
||||
text(m.notice),
|
||||
]),
|
||||
)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 134 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 69 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 102 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB |
+15
-28
@@ -63,8 +63,8 @@ pub fn Slot::widget(
|
||||
|
||||
///|
|
||||
/// Rows of app tiles nearest to a widget height in px, at least one.
|
||||
pub fn widget_rows(px : Int32, ch~ : Int32 = cell_px) -> Int32 {
|
||||
let k = (px + row_gap + (ch + row_gap) / 2) / (ch + row_gap)
|
||||
pub fn widget_rows(px : Int32) -> Int32 {
|
||||
let k = (px + row_gap + (cell_px + row_gap) / 2) / (cell_px + row_gap)
|
||||
if k < 1 {
|
||||
1
|
||||
} else {
|
||||
@@ -192,51 +192,38 @@ pub fn pack(
|
||||
}
|
||||
|
||||
///|
|
||||
/// A cell's box in px, given the column width and the row height `ch`: (x, y, w, h).
|
||||
pub fn box(
|
||||
cell : Cell,
|
||||
col_w : Double,
|
||||
ch~ : Int32 = cell_px,
|
||||
) -> (Double, Double, Double, Double) {
|
||||
/// A cell's box in px, given the column width: (x, y, w, h).
|
||||
pub fn box(cell : Cell, col_w : Double) -> (Double, Double, Double, Double) {
|
||||
let cg = col_gap.to_double()
|
||||
let rg = row_gap.to_double()
|
||||
(
|
||||
cell.col.to_double() * (col_w + cg),
|
||||
cell.row.to_double() * (ch.to_double() + rg),
|
||||
cell.row.to_double() * (cell_px.to_double() + rg),
|
||||
cell.w.to_double() * col_w + (cell.w - 1).to_double() * cg,
|
||||
cell.h.to_double() * ch.to_double() + (cell.h - 1).to_double() * rg,
|
||||
cell.h.to_double() * cell_px.to_double() + (cell.h - 1).to_double() * rg,
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
/// The cell nearest to a point (px in the grid, from its top left): (col, row).
|
||||
pub fn cell_at(
|
||||
x : Double,
|
||||
y : Double,
|
||||
col_w : Double,
|
||||
ch~ : Int32 = cell_px,
|
||||
) -> (Int32, Int32) {
|
||||
pub fn cell_at(x : Double, y : Double, col_w : Double) -> (Int32, Int32) {
|
||||
let c = (x / (col_w + col_gap.to_double()) + 0.5).floor().to_int()
|
||||
let r = (y / (ch + row_gap).to_double() + 0.5).floor().to_int()
|
||||
let r = (y / (cell_px + row_gap).to_double() + 0.5).floor().to_int()
|
||||
(@cmp.maximum(0, c), @cmp.maximum(0, r))
|
||||
}
|
||||
|
||||
///|
|
||||
/// The cell whose box contains a point, or `None` outside every cell (in the gaps).
|
||||
pub fn cell_under(
|
||||
x : Double,
|
||||
y : Double,
|
||||
col_w : Double,
|
||||
ch~ : Int32 = cell_px,
|
||||
) -> (Int32, Int32)? {
|
||||
pub fn cell_under(x : Double, y : Double, col_w : Double) -> (Int32, Int32)? {
|
||||
if x < 0.0 || y < 0.0 {
|
||||
return None
|
||||
}
|
||||
let pw = col_w + col_gap.to_double()
|
||||
let ph = (ch + row_gap).to_double()
|
||||
let ph = (cell_px + row_gap).to_double()
|
||||
let c = (x / pw).floor().to_int()
|
||||
let r = (y / ph).floor().to_int()
|
||||
if x - c.to_double() * pw > col_w || y - r.to_double() * ph > ch.to_double() {
|
||||
if x - c.to_double() * pw > col_w ||
|
||||
y - r.to_double() * ph > cell_px.to_double() {
|
||||
None
|
||||
} else {
|
||||
Some((c, r))
|
||||
@@ -358,9 +345,9 @@ pub fn column_width(grid_width : Double, cols : Int32) -> Double {
|
||||
}
|
||||
|
||||
///|
|
||||
/// How many rows of height `ch` fit in `height` px.
|
||||
pub fn rows_fit(height : Double, ch~ : Int32 = cell_px) -> Int32 {
|
||||
let r = ((height + row_gap.to_double()) / (ch + row_gap).to_double())
|
||||
/// How many rows of the grid fit in `height` px.
|
||||
pub fn rows_fit(height : Double) -> Int32 {
|
||||
let r = ((height + row_gap.to_double()) / (cell_px + row_gap).to_double())
|
||||
.floor()
|
||||
.to_int()
|
||||
@cmp.maximum(1, r)
|
||||
|
||||
+1
-16
@@ -120,9 +120,7 @@ test "moving in the order" {
|
||||
|
||||
///|
|
||||
test "widget heights in px to rows" {
|
||||
assert_eq([40, 64, 100, 136, 208, 420].map(fn(p) { widget_rows(p) }), [
|
||||
1, 1, 2, 2, 3, 6,
|
||||
])
|
||||
assert_eq([40, 64, 100, 136, 208, 420].map(widget_rows), [1, 1, 2, 2, 3, 6])
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -157,16 +155,3 @@ test "viewport to grid" {
|
||||
assert_eq(rows_fit(500.0), 7)
|
||||
assert_eq(rows_fit(10.0), 1)
|
||||
}
|
||||
|
||||
///|
|
||||
test "fit clamps anchored spans within lo..hi and negative targets" {
|
||||
// Widget pinned at col 2 of 5 can only grow to hi = 3 columns on the right
|
||||
assert_eq(fit(500.0, 1, 3, 65.2, 8.0, 64, 0), 3)
|
||||
// Negative drag past the left/top edge clamps cleanly to 1
|
||||
assert_eq(fit(-120.0, 1, 4, 65.2, 8.0, 0, 0), 1)
|
||||
// Expanding a widget unpins slots now overlapped by it
|
||||
let h = [widget(2, 2, x=1, y=1), app(x=3, y=1), app(x=0, y=0)]
|
||||
h[0].w = 3
|
||||
clear_cells(h, 0, 5)
|
||||
assert_eq((h[1].x, h[1].y, h[2].x, h[2].y), (-1, -1, 0, 0))
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import {
|
||||
"moonbitlang/core/cmp",
|
||||
"moonbitlang/core/string",
|
||||
}
|
||||
+5
-41
@@ -6,15 +6,13 @@ import {
|
||||
}
|
||||
|
||||
// Values
|
||||
pub fn box(Cell, Double, ch? : Int32) -> (Double, Double, Double, Double)
|
||||
pub fn box(Cell, Double) -> (Double, Double, Double, Double)
|
||||
|
||||
pub fn cell_at(Double, Double, Double, ch? : Int32) -> (Int32, Int32)
|
||||
|
||||
pub fn cell_height(Int32) -> Int32
|
||||
pub fn cell_at(Double, Double, Double) -> (Int32, Int32)
|
||||
|
||||
pub let cell_px : Int32
|
||||
|
||||
pub fn cell_under(Double, Double, Double, ch? : Int32) -> (Int32, Int32)?
|
||||
pub fn cell_under(Double, Double, Double) -> (Int32, Int32)?
|
||||
|
||||
pub fn clear_cells(Array[Slot], Int32, Int32) -> Unit
|
||||
|
||||
@@ -24,57 +22,23 @@ pub fn column_width(Double, Int32) -> Double
|
||||
|
||||
pub fn columns_for(Int32) -> Int32
|
||||
|
||||
pub fn css_factor(Int32) -> String
|
||||
|
||||
pub fn drawer_columns(Int32, Int32) -> Int32
|
||||
|
||||
pub let drawer_icon_px : Int32
|
||||
|
||||
pub fn fit(Double, Int32, Int32, Double, Double, Int32, Int32) -> Int32
|
||||
|
||||
pub fn home_columns(Int32, Double, Int32) -> Int32
|
||||
|
||||
pub let home_icon_px : Int32
|
||||
|
||||
pub let min_cols : Int32
|
||||
|
||||
pub fn move_slot(Array[Slot], Int32, Int32) -> Unit
|
||||
|
||||
pub fn pack(Array[Slot], Int32, Int32, hidden? : (Int32) -> Bool) -> Packed
|
||||
|
||||
pub fn parse_scale(String) -> Result[Int32, String]
|
||||
|
||||
pub fn pin(Array[Slot], Int32, Int32, Int32, Int32, Int32) -> Unit
|
||||
|
||||
pub let row_gap : Int32
|
||||
|
||||
pub fn rows_fit(Double, ch? : Int32) -> Int32
|
||||
|
||||
pub let scale_default : Int32
|
||||
|
||||
pub let scale_large : Int32
|
||||
|
||||
pub let scale_max : Int32
|
||||
|
||||
pub let scale_medium : Int32
|
||||
|
||||
pub let scale_min : Int32
|
||||
|
||||
pub let scale_small : Int32
|
||||
|
||||
pub let scale_step : Int32
|
||||
|
||||
pub fn scale_valid(Int32) -> Bool
|
||||
|
||||
pub fn scaled_columns(Int32, Int32, Double, Int32, Int32) -> Int32
|
||||
|
||||
pub fn scaled_px(Int32, Int32) -> Int32
|
||||
pub fn rows_fit(Double) -> Int32
|
||||
|
||||
pub fn span(Int32, Double, Double) -> Double
|
||||
|
||||
pub fn widget_cols(Int32, Double, Int32) -> Int32
|
||||
|
||||
pub fn widget_rows(Int32, ch? : Int32) -> Int32
|
||||
pub fn widget_rows(Int32) -> Int32
|
||||
|
||||
// Errors
|
||||
|
||||
|
||||
-142
@@ -1,142 +0,0 @@
|
||||
///|
|
||||
/// The icon size setting as plain functions: the allowed range, parsing a stored or
|
||||
/// slider value, and how icon size, row height and column count follow from it.
|
||||
/// The size is a whole percent of today's size (`scale_default` = 100: no change).
|
||||
|
||||
///|
|
||||
pub let scale_min : Int32 = 70
|
||||
|
||||
///|
|
||||
pub let scale_max : Int32 = 160
|
||||
|
||||
///|
|
||||
pub let scale_default : Int32 = 100
|
||||
|
||||
///|
|
||||
/// Slider step in percent.
|
||||
pub let scale_step : Int32 = 5
|
||||
|
||||
///|
|
||||
/// The presets: Small, Medium (today's size), Large.
|
||||
pub let scale_small : Int32 = 80
|
||||
|
||||
///|
|
||||
pub let scale_medium : Int32 = 100
|
||||
|
||||
///|
|
||||
pub let scale_large : Int32 = 130
|
||||
|
||||
///|
|
||||
/// The home icon at 100%, in px (`.slots .icon`).
|
||||
pub let home_icon_px : Int32 = 40
|
||||
|
||||
///|
|
||||
/// The drawer icon at 100%, in px (`.icon`).
|
||||
pub let drawer_icon_px : Int32 = 52
|
||||
|
||||
///|
|
||||
/// Fewest columns either grid is reduced to, however large the icons.
|
||||
pub let min_cols : Int32 = 3
|
||||
|
||||
///|
|
||||
/// A size is a valid setting: in range and on the step.
|
||||
pub fn scale_valid(pct : Int32) -> Bool {
|
||||
pct >= scale_min && pct <= scale_max && pct % scale_step == 0
|
||||
}
|
||||
|
||||
///|
|
||||
/// Parse a stored or slider value (decimal whole percent, nothing else). The error says
|
||||
/// what was wrong and what is allowed; callers show and log it.
|
||||
pub fn parse_scale(text : String) -> Result[Int32, String] {
|
||||
let t = text.trim().to_owned()
|
||||
let n = @string.parse_int(t) catch {
|
||||
_ => return Err("icon size \"\{text}\" is not a whole number")
|
||||
}
|
||||
if scale_valid(n) {
|
||||
Ok(n)
|
||||
} else {
|
||||
Err(
|
||||
"icon size \{n} is outside \{scale_min}..\{scale_max} in steps of \{scale_step}",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// `base` px at `pct` percent, rounded to a whole px, at least 1.
|
||||
pub fn scaled_px(base : Int32, pct : Int32) -> Int32 {
|
||||
@cmp.maximum(1, (base * pct + 50) / 100)
|
||||
}
|
||||
|
||||
///|
|
||||
/// Height of a home row at `pct`.
|
||||
pub fn cell_height(pct : Int32) -> Int32 {
|
||||
scaled_px(cell_px, pct)
|
||||
}
|
||||
|
||||
///|
|
||||
/// The percent as a CSS number (`1`, `1.25`, `0.8`), for the `--s` custom property.
|
||||
pub fn css_factor(pct : Int32) -> String {
|
||||
let whole = pct / 100
|
||||
let frac = pct % 100
|
||||
if frac == 0 {
|
||||
whole.to_string()
|
||||
} else if frac < 10 {
|
||||
"\{whole}.0\{frac}"
|
||||
} else if frac % 10 == 0 {
|
||||
"\{whole}.\{frac / 10}"
|
||||
} else {
|
||||
"\{whole}.\{frac}"
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Columns of a grid `avail` px wide whose icons are `icon` px: `base` columns at 100%,
|
||||
/// `base * 100 / pct` (rounded) at `pct`, no fewer than `min_cols` and then never so
|
||||
/// many that a column (`gap` px apart) is narrower than its icon.
|
||||
pub fn scaled_columns(
|
||||
base : Int32,
|
||||
pct : Int32,
|
||||
avail : Double,
|
||||
gap : Int32,
|
||||
icon : Int32,
|
||||
) -> Int32 {
|
||||
let mut c = @cmp.maximum(min_cols, (base * 100 + pct / 2) / pct)
|
||||
while c > 1 && column_width_in(avail, c, gap) < icon.to_double() {
|
||||
c -= 1
|
||||
}
|
||||
c
|
||||
}
|
||||
|
||||
///|
|
||||
fn column_width_in(avail : Double, cols : Int32, gap : Int32) -> Double {
|
||||
(avail - (cols - 1).to_double() * gap.to_double()) / cols.to_double()
|
||||
}
|
||||
|
||||
///|
|
||||
/// Home grid columns for a viewport width, the width of the grid and the size.
|
||||
pub fn home_columns(vw : Int32, grid_w : Double, pct : Int32) -> Int32 {
|
||||
scaled_columns(
|
||||
columns_for(vw),
|
||||
pct,
|
||||
grid_w,
|
||||
col_gap,
|
||||
scaled_px(home_icon_px, pct),
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
/// Drawer columns (4 below 480px, else 5, at 100%); its list is the viewport less 16px
|
||||
/// padding each side, with 8px between columns.
|
||||
pub fn drawer_columns(vw : Int32, pct : Int32) -> Int32 {
|
||||
scaled_columns(
|
||||
if vw >= 480 {
|
||||
5
|
||||
} else {
|
||||
4
|
||||
},
|
||||
pct,
|
||||
(vw - 32).to_double(),
|
||||
8,
|
||||
scaled_px(drawer_icon_px, pct),
|
||||
)
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
///|
|
||||
test "the default size is today's size" {
|
||||
assert_eq(scale_default, 100)
|
||||
assert_eq(scale_medium, scale_default)
|
||||
assert_eq(cell_height(scale_default), cell_px)
|
||||
assert_eq(scaled_px(home_icon_px, scale_default), 40)
|
||||
assert_eq(scaled_px(drawer_icon_px, scale_default), 52)
|
||||
// the column counts the app had before the setting existed
|
||||
assert_eq(home_columns(390, 358.0, 100), columns_for(390))
|
||||
assert_eq(home_columns(600, 528.0, 100), columns_for(600))
|
||||
assert_eq(drawer_columns(390, 100), 4)
|
||||
assert_eq(drawer_columns(600, 100), 5)
|
||||
}
|
||||
|
||||
///|
|
||||
test "presets and range are valid settings" {
|
||||
for p in [scale_small, scale_medium, scale_large, scale_min, scale_max] {
|
||||
assert_true(scale_valid(p))
|
||||
}
|
||||
assert_true(scale_min < scale_default && scale_default < scale_max)
|
||||
}
|
||||
|
||||
///|
|
||||
test "parse_scale accepts steps in range" {
|
||||
assert_eq(parse_scale("100"), Ok(100))
|
||||
assert_eq(parse_scale(" 85 "), Ok(85))
|
||||
assert_eq(parse_scale("70"), Ok(70))
|
||||
assert_eq(parse_scale("160"), Ok(160))
|
||||
}
|
||||
|
||||
///|
|
||||
test "parse_scale rejects corrupt values with a reason" {
|
||||
assert_eq(parse_scale("abc"), Err("icon size \"abc\" is not a whole number"))
|
||||
assert_eq(parse_scale(""), Err("icon size \"\" is not a whole number"))
|
||||
assert_eq(parse_scale("1.5"), Err("icon size \"1.5\" is not a whole number"))
|
||||
assert_eq(
|
||||
parse_scale("65"),
|
||||
Err("icon size 65 is outside 70..160 in steps of 5"),
|
||||
)
|
||||
assert_eq(
|
||||
parse_scale("500"),
|
||||
Err("icon size 500 is outside 70..160 in steps of 5"),
|
||||
)
|
||||
assert_eq(
|
||||
parse_scale("-10"),
|
||||
Err("icon size -10 is outside 70..160 in steps of 5"),
|
||||
)
|
||||
// in range but off the step
|
||||
assert_eq(
|
||||
parse_scale("102"),
|
||||
Err("icon size 102 is outside 70..160 in steps of 5"),
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
test "sizes scale together" {
|
||||
assert_eq(scaled_px(home_icon_px, 150), 60)
|
||||
assert_eq(scaled_px(home_icon_px, 70), 28)
|
||||
assert_eq(cell_height(150), 96)
|
||||
assert_eq(cell_height(70), 45)
|
||||
assert_eq(cell_height(scale_min) < cell_px, true)
|
||||
assert_eq(scaled_px(1, 70), 1) // never below a pixel
|
||||
}
|
||||
|
||||
///|
|
||||
test "css_factor" {
|
||||
assert_eq(css_factor(100), "1")
|
||||
assert_eq(css_factor(130), "1.3")
|
||||
assert_eq(css_factor(80), "0.8")
|
||||
assert_eq(css_factor(105), "1.05")
|
||||
assert_eq(css_factor(160), "1.6")
|
||||
assert_eq(css_factor(70), "0.7")
|
||||
}
|
||||
|
||||
///|
|
||||
test "larger icons mean fewer columns, smaller mean more" {
|
||||
assert_eq(home_columns(390, 358.0, 70), 7)
|
||||
assert_eq(home_columns(390, 358.0, 130), 4)
|
||||
assert_eq(home_columns(390, 358.0, 160), 3)
|
||||
assert_eq(drawer_columns(390, 70), 6)
|
||||
assert_eq(drawer_columns(390, 160), 3)
|
||||
}
|
||||
|
||||
///|
|
||||
test "columns never go below min_cols while icons fit" {
|
||||
for pct in 70..<=160 {
|
||||
if pct % scale_step == 0 {
|
||||
assert_true(home_columns(390, 358.0, pct) >= min_cols)
|
||||
assert_true(drawer_columns(390, pct) >= min_cols)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "icons never overlap or clip: a column is at least as wide as its icon" {
|
||||
// every size, on phones of several widths (grid is the viewport less 32px, max 528)
|
||||
for vw in [320, 360, 390, 412, 480, 600, 800] {
|
||||
let grid_w = ((if vw > 560 { 560 } else { vw }) - 32).to_double()
|
||||
for pct in 70..<=160 {
|
||||
if pct % scale_step != 0 {
|
||||
continue
|
||||
}
|
||||
let c = home_columns(vw, grid_w, pct)
|
||||
assert_true(
|
||||
column_width(grid_w, c) >= scaled_px(home_icon_px, pct).to_double(),
|
||||
)
|
||||
let d = drawer_columns(vw, pct)
|
||||
let dw = (vw - 32).to_double()
|
||||
assert_true(
|
||||
(dw - (d - 1).to_double() * 8.0) / d.to_double() >=
|
||||
scaled_px(drawer_icon_px, pct).to_double(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "a very narrow grid sheds columns to keep the icons whole" {
|
||||
// 160px of grid at 160%: icons are 64px, so only two columns fit with the 8px gap
|
||||
assert_eq(scaled_columns(5, 160, 160.0, 8, 64), 2)
|
||||
assert_eq(scaled_columns(5, 100, 400.0, 8, 40), 5)
|
||||
}
|
||||
|
||||
///|
|
||||
test "row height parameter threads through the cell maths" {
|
||||
let c : Cell = { col: 1, row: 2, w: 2, h: 2, }
|
||||
let (x, y, w, h) = box(c, 60.0, ch=96)
|
||||
assert_eq((x, y, w, h), (68.0, 208.0, 128.0, 200.0))
|
||||
assert_eq(box(c, 60.0), box(c, 60.0, ch=cell_px))
|
||||
assert_eq(rows_fit(500.0, ch=96), 4)
|
||||
assert_eq(rows_fit(500.0), 7)
|
||||
assert_eq(widget_rows(200, ch=96), 2)
|
||||
assert_eq(cell_at(80.0, 220.0, 70.0, ch=96), (1, 2))
|
||||
assert_eq(cell_under(80.0, 220.0, 70.0, ch=96), Some((1, 2)))
|
||||
assert_eq(cell_under(80.0, 100.0, 70.0, ch=96), None) // in the row gap
|
||||
}
|
||||
+10
-161
@@ -28,8 +28,6 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
p.on("pageerror", (e) => { console.error("page error:", e.message); process.exitCode = 1; });
|
||||
await p.addInitScript((release) => {
|
||||
window.__calls = [];
|
||||
window.__recentsEnabled = true;
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true };
|
||||
const rec = (n) => (...a) => { window.__calls.push([n, ...a]); };
|
||||
const disc = "data:image/svg+xml," + encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><circle cx='4' cy='4' r='4' fill='red'/></svg>");
|
||||
window.Android = {
|
||||
@@ -37,14 +35,10 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
addWidget: (prov) => { rec("addWidget")(prov); setTimeout(() => window.launcher.widgetAdded(77), 0); },
|
||||
removeWidget: rec("removeWidget"), placeWidgets: rec("placeWidgets"), coverWidgets: rec("coverWidgets"),
|
||||
excludeGestures: rec("excludeGestures"),
|
||||
widgetLimits: () => JSON.stringify(window.__widgetLimits),
|
||||
widgetLimits: () => JSON.stringify({ w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true }),
|
||||
loadIcons: (json) => { rec("loadIcons")(json); const o = {}; for (const k of JSON.parse(json)) o[k] = disc; setTimeout(() => window.launcher.icons(o), 0); },
|
||||
haptic: rec("haptic"), showKeyboard: rec("showKeyboard"), hideKeyboard: rec("hideKeyboard"),
|
||||
openSettings: rec("openSettings"), pickWallpaper: rec("pickWallpaper"),
|
||||
recentsEnabled: () => !!window.__recentsEnabled,
|
||||
openRecents: () => { rec("openRecents")(); return !!window.__recentsEnabled; },
|
||||
openAccessibilitySettings: rec("openAccessibilitySettings"),
|
||||
openSelfAppInfo: rec("openSelfAppInfo"),
|
||||
openSettings: rec("openSettings"), pickWallpaper: rec("pickWallpaper"), openRecents: rec("openRecents"),
|
||||
httpGet: (url, tag) => { rec("httpGet")(url, tag);
|
||||
setTimeout(() => window.launcher.httpResult(tag, true, url.endsWith("/latest") ? release : JSON.stringify({ versionCode: 9, commit: "abc" })), 0); },
|
||||
installApk: rec("installApk"), installedVersion: () => 5, declinedVersion: () => -1,
|
||||
@@ -62,14 +56,6 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
await p.reload();
|
||||
await p.waitForSelector(".hint");
|
||||
assert.ok(!(await p.evaluate(() => document.documentElement.classList.contains("demo"))), "no demo backdrop on a phone");
|
||||
const bg = await p.evaluate(() => ({
|
||||
htmlColor: getComputedStyle(document.documentElement).backgroundColor,
|
||||
htmlImage: getComputedStyle(document.documentElement).backgroundImage,
|
||||
bodyColor: getComputedStyle(document.body).backgroundColor,
|
||||
}));
|
||||
assert.equal(bg.htmlColor, "rgba(0, 0, 0, 0)", "html background is transparent on Android");
|
||||
assert.equal(bg.bodyColor, "rgba(0, 0, 0, 0)", "body background is transparent on Android");
|
||||
assert.equal(bg.htmlImage, "none", "no demo gradient on Android");
|
||||
|
||||
// on start the page checks for an update: release API, then version.json, then installs build 9 over 5
|
||||
await p.waitForFunction(() => window.__calls.some((c) => c[0] === "installApk"));
|
||||
@@ -78,17 +64,10 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
assert.deepEqual((await calls("installApk"))[0].slice(1), ["https://x/a.apk", 9]);
|
||||
assert.equal(await p.textContent(".notice"), "Downloading launcher update (build 9)…");
|
||||
|
||||
// app icons are pre-warmed right after apps.json loads, before opening the drawer
|
||||
await p.waitForFunction(() => window.__calls.some((c) => c[0] === "loadIcons"));
|
||||
assert.ok((await calls("loadIcons")).length > 0, "icons are pre-warmed before opening the drawer");
|
||||
|
||||
// the drawer asks the shell for icons (batched, by key) and fills the images from its answer
|
||||
await p.evaluate(() => document.body.dispatchEvent(Object.assign(new Event("x"), {})));
|
||||
await longpress(".hint");
|
||||
await p.evaluate(() => { document.querySelector(".sheet-overlay").__tag = "overlay"; });
|
||||
await p.click(".sheet-item >> text=Add apps"); await settle();
|
||||
assert.equal(await p.$eval(".drawer", (d) => d.__tag), undefined, "drawer does not recycle sheet-overlay");
|
||||
assert.equal(await p.$eval(".drawer", (d) => getComputedStyle(d).backdropFilter), "none", "no full-screen backdrop blur");
|
||||
assert.ok((await calls("loadIcons")).length > 0, "icons are asked for");
|
||||
assert.ok(!(await calls("showKeyboard")).length, "no keyboard in pick mode");
|
||||
await p.click(".apps .tile:nth-child(4)"); await p.click(".drawer-head >> text=Done"); await settle();
|
||||
@@ -96,28 +75,9 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
await p.click(".slots .tile"); await settle();
|
||||
assert.deepEqual((await calls("launch"))[0].slice(1), ["com.example.chrome/.MainActivity"]);
|
||||
|
||||
// Windows asks the shell for Recents when enabled, and opens setup sheet when disabled
|
||||
// Windows asks the shell for Recents; settings and wallpaper too
|
||||
await p.click(".panel-btn"); await settle();
|
||||
assert.equal((await calls("openRecents")).length, 1);
|
||||
assert.ok(!(await p.$(".sheet")), "no setup sheet when RecentsService is running");
|
||||
|
||||
await p.evaluate(() => { window.__recentsEnabled = false; });
|
||||
await p.click(".panel-btn");
|
||||
await p.waitForSelector(".sheet");
|
||||
assert.equal((await calls("openRecents")).length, 2);
|
||||
assert.equal(await p.textContent(".sheet-title"), "Enable window list");
|
||||
const setupText = await p.textContent(".sheet");
|
||||
assert.ok(setupText.includes("Restricted setting"), "explains Android 13+ Restricted setting");
|
||||
assert.ok(setupText.includes("Allow restricted settings"), "explains Allow restricted settings step");
|
||||
await p.click(".sheet button:has-text('Open Accessibility settings')"); await settle();
|
||||
assert.equal((await calls("openAccessibilitySettings")).length, 1);
|
||||
assert.ok(await p.$(".sheet"), "setup sheet stays open while user checks Settings");
|
||||
await p.click(".sheet button:has-text('Open App info')"); await settle();
|
||||
assert.equal((await calls("openSelfAppInfo")).length, 1);
|
||||
assert.ok(await p.$(".sheet"), "setup sheet stays open while user checks App info");
|
||||
await p.click(".sheet button:has-text('Close')"); await settle();
|
||||
assert.ok(!(await p.$(".sheet")), "Close dismisses setup sheet");
|
||||
await p.evaluate(() => { window.__recentsEnabled = true; });
|
||||
|
||||
// add a widget: the shell binds it and the page places it over its slot (wid, x, y, w, h, editing)
|
||||
await longpress(".home", 0.95);
|
||||
@@ -135,147 +95,36 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
assert.ok(w < 358, "starts at its natural width, not the whole row"); // 110px natural = 2 columns
|
||||
|
||||
// opening the drawer: the shell is told to cover the widgets, the keyboard comes up, widgets are unmarked
|
||||
await p.click(".search-pill");
|
||||
await p.click(".search-pill"); await settle();
|
||||
await p.waitForSelector(".drawer");
|
||||
await settle();
|
||||
assert.equal((await calls("coverWidgets")).pop()[1], -1, "the shell hides widgets under the drawer");
|
||||
assert.ok((await calls("coverWidgets")).length > 0, "the shell hides widgets under the drawer");
|
||||
assert.ok((await calls("showKeyboard")).length > 0, "the search takes the keyboard");
|
||||
assert.equal(await p.$$eval("[data-wid]", (ws) => ws.length), 0);
|
||||
await p.click(".drawer-head >> text=Close");
|
||||
await p.waitForSelector(".drawer.closing", { timeout: 1000 });
|
||||
await p.click(".drawer-head >> text=Close"); await settle();
|
||||
assert.ok((await calls("hideKeyboard")).length > 0);
|
||||
assert.equal((await calls("coverWidgets")).pop()[1], 0, "the widgets are shown again as drawer closes");
|
||||
await p.waitForSelector(".drawer", { state: "detached", timeout: 2000 });
|
||||
assert.equal((await calls("coverWidgets")).pop()[1], 0, "the widgets are shown again");
|
||||
|
||||
// a long press on the native widget view reaches the page; letting go without moving shows handles,
|
||||
// and the shell is told to keep its edge swipes off them
|
||||
await p.evaluate(() => { window.launcher.widgetMenu(77); window.launcher.widgetDrop(false); }); await settle();
|
||||
assert.ok(await p.$(".widget-slot.resizing .resize-handle"), "handles");
|
||||
assert.equal(await p.textContent(".resize-size"), "2 × 2");
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 5, "five handles excluded from system gestures");
|
||||
assert.ok(JSON.parse((await calls("excludeGestures")).pop()[1]).length === 3, "three handles excluded from system gestures");
|
||||
assert.equal(JSON.parse((await calls("placeWidgets")).pop()[1])[0][5], 1, "the shell is told which widget is being edited");
|
||||
// dragging it from the native view moves it to a cell (widgetDrag reports page px)
|
||||
const tileBox = await p.locator(".slots .tile").first().boundingBox();
|
||||
const pitchX = Math.round(tileBox.width + 8);
|
||||
const pitchY = Math.round(tileBox.height + 8);
|
||||
await p.evaluate(([dx, dy]) => {
|
||||
window.launcher.widgetGrab(77);
|
||||
window.launcher.widgetDrag(150, 200);
|
||||
window.launcher.widgetDrag(150 + dx, 200 + dy);
|
||||
window.launcher.widgetDrop(true);
|
||||
}, [pitchX, 2 * pitchY]);
|
||||
await p.evaluate(() => { window.launcher.widgetGrab(77); window.launcher.widgetDrag(200, 300); window.launcher.widgetDrag(200, 420); window.launcher.widgetDrop(true); });
|
||||
await settle();
|
||||
const moved = await p.$eval(".widget-slot", (s) => s.style.gridRow);
|
||||
assert.ok(!moved.startsWith("1 "), `moved off the first row: ${moved}`);
|
||||
|
||||
// Left and Top resize handles grow without shifting the anchored right/bottom edges
|
||||
const b0 = await p.locator(".widget-slot").boundingBox();
|
||||
const hl = await p.locator(".resize-handle[data-edge=l]").boundingBox();
|
||||
await p.mouse.move(hl.x + hl.width / 2, hl.y + hl.height / 2);
|
||||
await p.mouse.down();
|
||||
await p.mouse.move(hl.x + hl.width / 2 - pitchX, hl.y + hl.height / 2, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
const b1 = await p.locator(".widget-slot").boundingBox();
|
||||
assert.ok(Math.abs((b0.x + b0.width) - (b1.x + b1.width)) < 2, "left resize keeps right edge anchored");
|
||||
assert.ok(Math.abs((b1.width - b0.width) - pitchX) < 3, `left resize grew by 1 col: ${b1.width - b0.width}`);
|
||||
assert.equal(await p.textContent(".resize-size"), "3 × 2");
|
||||
|
||||
const ht = await p.locator(".resize-handle[data-edge=t]").boundingBox();
|
||||
await p.mouse.move(ht.x + ht.width / 2, ht.y + ht.height / 2);
|
||||
await p.mouse.down();
|
||||
await p.mouse.move(ht.x + ht.width / 2, ht.y + ht.height / 2 - pitchY, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
const b2 = await p.locator(".widget-slot").boundingBox();
|
||||
assert.ok(Math.abs((b1.y + b1.height) - (b2.y + b2.height)) < 2, "top resize keeps bottom edge anchored");
|
||||
assert.ok(Math.abs((b2.height - b1.height) - pitchY) < 3, `top resize grew by 1 row: ${b2.height - b1.height}`);
|
||||
assert.equal(await p.textContent(".resize-size"), "3 × 3");
|
||||
|
||||
// holding a resize handle >= 500ms does not lift widget or corrupt resize state
|
||||
const hr = await p.locator(".resize-handle[data-edge=r]").boundingBox();
|
||||
await p.mouse.move(hr.x + hr.width / 2, hr.y + hr.height / 2);
|
||||
await p.mouse.down(); await p.waitForTimeout(600);
|
||||
await p.mouse.move(hr.x + hr.width / 2 + pitchX, hr.y + hr.height / 2, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
assert.ok(await p.$(".widget-slot.resizing"), "still resizing after 600ms hold");
|
||||
assert.ok(!(await p.$(".widget-slot.lifted")), "not lifted after holding handle");
|
||||
assert.ok(!(await p.$(".sheet")), "no sheet opened after holding handle");
|
||||
assert.equal(await p.textContent(".resize-size"), "4 × 3");
|
||||
|
||||
// scrolled resize: ensure page scrolls, scroll down, then resize bottom by +1 row
|
||||
await p.evaluate(() => {
|
||||
document.querySelector(".home").style.minHeight = "1200px";
|
||||
window.scrollTo(0, 120);
|
||||
});
|
||||
await settle();
|
||||
assert.ok((await p.evaluate(() => window.scrollY)) > 50, "page scrolled for scrolled resize test");
|
||||
const bs0 = await p.locator(".widget-slot").boundingBox();
|
||||
const hb = await p.locator(".resize-handle[data-edge=b]").boundingBox();
|
||||
await p.mouse.move(hb.x + hb.width / 2, hb.y + hb.height / 2);
|
||||
await p.mouse.down();
|
||||
await p.mouse.move(hb.x + hb.width / 2, hb.y + hb.height / 2 + pitchY, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
const bs1 = await p.locator(".widget-slot").boundingBox();
|
||||
assert.ok(Math.abs((bs1.height - bs0.height) - pitchY) < 3, `scrolled bottom resize grew by 1 row: ${bs1.height - bs0.height}`);
|
||||
assert.equal(await p.textContent(".resize-size"), "4 × 4");
|
||||
await p.evaluate(() => {
|
||||
document.querySelector(".home").style.minHeight = "";
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
await settle();
|
||||
|
||||
// axis-conditional handles: h-only, v-only, and non-resizable
|
||||
const edges = () => p.$$eval(".resize-handle", (hs) => hs.map((h) => h.dataset.edge));
|
||||
await p.click(".resize-bar >> text=Done"); await settle();
|
||||
await p.evaluate(() => {
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: false };
|
||||
window.launcher.widgetMenu(77); window.launcher.widgetDrop(false);
|
||||
});
|
||||
await settle();
|
||||
assert.deepEqual(await edges(), ["l", "r"]);
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 2);
|
||||
|
||||
await p.click(".resize-bar >> text=Done"); await settle();
|
||||
await p.evaluate(() => {
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: false, v: true };
|
||||
window.launcher.widgetMenu(77); window.launcher.widgetDrop(false);
|
||||
});
|
||||
await settle();
|
||||
assert.deepEqual(await edges(), ["t", "b"]);
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 2);
|
||||
|
||||
await p.click(".resize-bar >> text=Done"); await settle();
|
||||
await p.evaluate(() => {
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: false, v: false };
|
||||
window.launcher.widgetMenu(77); window.launcher.widgetDrop(false);
|
||||
});
|
||||
await settle();
|
||||
assert.deepEqual(await edges(), []);
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 0);
|
||||
await p.evaluate(() => { window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true }; });
|
||||
|
||||
await p.click(".resize-bar >> text=Remove"); await settle();
|
||||
assert.equal((await calls("removeWidget"))[0][1], 77);
|
||||
|
||||
// opening the drawer while a notice is visible does not recycle .notice as .drawer
|
||||
await longpress(".home", 0.95);
|
||||
await p.click(".sheet-item >> text=Check for updates");
|
||||
await p.waitForSelector(".notice");
|
||||
await p.evaluate(() => { document.querySelector(".notice").__tag = "notice"; });
|
||||
await p.click(".search-pill");
|
||||
await p.waitForSelector(".drawer");
|
||||
assert.equal(await p.$eval(".drawer", (d) => d.__tag), undefined, "drawer does not recycle .notice");
|
||||
assert.equal(await p.$eval(".notice", (n) => n.__tag), "notice", ".notice keeps its DOM element");
|
||||
await p.click(".drawer-head >> text=Close");
|
||||
await p.waitForSelector(".drawer", { state: "detached", timeout: 2000 });
|
||||
|
||||
// a package change: the shell calls reload(), which fetches the app list again and re-asks for icons
|
||||
const before = (await calls("loadIcons")).length;
|
||||
await p.evaluate(() => window.launcher.reload()); await settle();
|
||||
assert.ok((await calls("loadIcons")).length > before, "icons are asked for again after a reload");
|
||||
// back and home close the drawer
|
||||
await p.click(".search-pill"); await p.waitForSelector(".drawer");
|
||||
await p.evaluate(() => window.launcher.back());
|
||||
await p.waitForSelector(".drawer", { state: "detached", timeout: 2000 });
|
||||
await p.evaluate(() => window.launcher.back()); await settle();
|
||||
assert.ok(!(await p.$(".drawer")));
|
||||
console.log("android bridge ok");
|
||||
await b.close(); srv.close();
|
||||
|
||||
+1
-121
@@ -38,14 +38,6 @@ const serve = () => new Promise((resolve) => {
|
||||
await p.waitForSelector(".hint");
|
||||
await shot(p, "00-blank-home");
|
||||
assert.ok(!(await p.$(".clock")), "home has no built-in clock");
|
||||
const demoBg = await p.evaluate(() => ({
|
||||
hasDemo: document.documentElement.classList.contains("demo"),
|
||||
htmlBgImage: getComputedStyle(document.documentElement).backgroundImage,
|
||||
bodyBgColor: getComputedStyle(document.body).backgroundColor,
|
||||
}));
|
||||
assert.ok(demoBg.hasDemo, "desktop mode adds .demo class");
|
||||
assert.ok(demoBg.htmlBgImage.includes("linear-gradient"), "desktop mode keeps gradient backdrop");
|
||||
assert.equal(demoBg.bodyBgColor, "rgba(0, 0, 0, 0)", "body itself stays transparent");
|
||||
const longpress = async (sel, fy = 0.5) => {
|
||||
const r = await p.locator(sel).first().boundingBox();
|
||||
await p.mouse.move(r.x + r.width / 2, r.y + r.height * fy);
|
||||
@@ -59,9 +51,7 @@ const serve = () => new Promise((resolve) => {
|
||||
const homeApps = () => p.$$eval(".slots .name", (ns) => ns.map((n) => n.textContent));
|
||||
// long press on the blank home: add apps through the drawer's pick mode
|
||||
await longpress(".hint");
|
||||
await p.evaluate(() => { document.querySelector(".sheet-overlay").__tag = "overlay"; });
|
||||
await p.click(".sheet-item >> text=Add apps"); await settle();
|
||||
assert.equal(await p.$eval(".drawer", (d) => d.__tag), undefined, "drawer does not recycle sheet-overlay");
|
||||
for (const i of [4, 8, 12]) await p.click(`.apps .tile:nth-child(${i})`);
|
||||
await settle();
|
||||
assert.equal(await p.$$eval(".apps .tile.on", (ts) => ts.length), 3);
|
||||
@@ -173,22 +163,8 @@ const serve = () => new Promise((resolve) => {
|
||||
// hold a widget without moving: resize handles; drag them to snap it to the grid
|
||||
await longpress(".widget-slot");
|
||||
assert.ok(!(await p.$(".sheet")), "a widget gets handles, not the menu");
|
||||
assert.equal(await p.textContent(".resize-size"), "5 × 2");
|
||||
for (const edge of ["l", "r", "t", "b", "rb"]) {
|
||||
const box = await p.locator(`.resize-handle[data-edge=${edge}]`).boundingBox();
|
||||
assert.ok(box, `handle ${edge} rendered`);
|
||||
assert.ok(box.width >= 36 && box.height >= 36, `handle ${edge} generous target: ${box.width}x${box.height}`);
|
||||
assert.ok(box.x >= 0 && box.x + box.width <= 390, `handle ${edge} stays inside viewport: [${box.x}, ${box.x + box.width}]`);
|
||||
}
|
||||
assert.ok(await p.$(".widget-slot.resizing .resize-handle[data-edge=rb]"));
|
||||
await shot(p, "05-resize-handles");
|
||||
// resting a finger >= 500ms on a resize handle must not lift the widget or open a menu
|
||||
const hr = await p.locator(".resize-handle[data-edge=r]").boundingBox();
|
||||
await p.mouse.move(hr.x + hr.width / 2, hr.y + hr.height / 2);
|
||||
await p.mouse.down(); await p.waitForTimeout(600);
|
||||
assert.ok(await p.$(".widget-slot.resizing"), "holding handle keeps resize mode");
|
||||
assert.ok(!(await p.$(".widget-slot.lifted")), "holding handle does not lift widget");
|
||||
assert.ok(!(await p.$(".sheet")), "holding handle does not open sheet");
|
||||
await p.mouse.up(); await settle();
|
||||
const size = () => p.$eval(".widget-slot", (w) => [Math.round(w.getBoundingClientRect().width), Math.round(w.getBoundingClientRect().height)]);
|
||||
const [w0] = await size();
|
||||
const tile = await p.locator(".slots .tile").first().boundingBox();
|
||||
@@ -201,7 +177,6 @@ const serve = () => new Promise((resolve) => {
|
||||
const [w1, h1] = await size();
|
||||
assert.ok(w1 < w0 && Math.abs(w1 - (2 * tile.width + 8)) < 3, `two columns wide: ${w1} (tile ${tile.width})`);
|
||||
assert.equal(h1, 2 * 64 + 8, "snapped to two whole rows of tiles");
|
||||
assert.equal(await p.textContent(".resize-size"), "2 × 2");
|
||||
assert.ok(await p.$(".widget-slot.resizing"), "letting go of a handle keeps the handles");
|
||||
await p.click(".resize-bar >> text=Done"); await settle();
|
||||
assert.ok(!(await p.$(".resize-handle")));
|
||||
@@ -235,101 +210,6 @@ const serve = () => new Promise((resolve) => {
|
||||
assert.ok(!(await p.$(".widget-slot")));
|
||||
await p.evaluate(() => { window.launcher.reload(); }); await settle();
|
||||
assert.equal(await p.$$eval(".slots > li", (ls) => ls.length), 4);
|
||||
// ---- icon size: a slider in the home menu resizes every icon grid live, is saved, and survives a reload
|
||||
const grid = () => p.$eval(".slots", (g) => {
|
||||
const gs = g.getBoundingClientRect(), tiles = [...g.querySelectorAll(".tile")].map((t) => {
|
||||
const r = t.getBoundingClientRect(), i = t.querySelector(".icon").getBoundingClientRect();
|
||||
return { r, i, name: t.querySelector(".name").getBoundingClientRect(), font: parseFloat(getComputedStyle(t.querySelector(".name")).fontSize) };
|
||||
});
|
||||
return {
|
||||
cols: getComputedStyle(g).gridTemplateColumns.split(" ").length,
|
||||
row: parseFloat(getComputedStyle(g).gridTemplateRows.split(" ")[0]),
|
||||
icon: tiles[0].i.width, font: tiles[0].font, gridLeft: gs.left, gridRight: gs.right,
|
||||
tiles: tiles.map((t) => ({ l: t.r.left, r: t.r.right, t: t.r.top, b: t.r.bottom, il: t.i.left, ir: t.i.right, it: t.i.top, ib: t.i.bottom, nb: t.name.bottom })),
|
||||
};
|
||||
});
|
||||
const noOverlapOrClip = (g, what) => {
|
||||
for (const [n, a] of g.tiles.entries()) {
|
||||
assert.ok(a.il >= a.l - 0.5 && a.ir <= a.r + 0.5, `${what}: icon ${n} inside its tile (x)`);
|
||||
assert.ok(a.it >= a.t - 0.5 && a.nb <= a.b + 1, `${what}: icon and label ${n} inside its tile (y)`);
|
||||
assert.ok(a.l >= g.gridLeft - 0.5 && a.r <= g.gridRight + 0.5, `${what}: tile ${n} inside the grid`);
|
||||
for (const c of g.tiles.slice(n + 1)) {
|
||||
assert.ok(a.r <= c.l + 0.5 || c.r <= a.l + 0.5 || a.b <= c.t + 0.5 || c.b <= a.t + 0.5, `${what}: tiles ${n} overlap`);
|
||||
}
|
||||
}
|
||||
};
|
||||
const base = await grid();
|
||||
noOverlapOrClip(base, "100%");
|
||||
assert.equal(base.icon, 40, "the default icon is today's 40px");
|
||||
assert.equal(base.row, 64);
|
||||
assert.equal(base.cols, 5);
|
||||
await shot(p, "06-icon-size-before");
|
||||
await longpress(".home", 0.95);
|
||||
await p.click(".sheet-item >> text=Icon size"); await settle();
|
||||
assert.equal(await p.$eval(".icon-size-slider", (e) => e.value), "100");
|
||||
assert.equal((await p.textContent(".icon-size-value")).trim(), "100%");
|
||||
const setSlider = async (v) => { await p.$eval(".icon-size-slider", (e, v) => { e.value = v; e.dispatchEvent(new Event("input", { bubbles: true })); }, v); await settle(); };
|
||||
await setSlider("130");
|
||||
const big = await grid();
|
||||
noOverlapOrClip(big, "130%");
|
||||
assert.equal(big.icon, 52, "icon 40 -> 52");
|
||||
assert.equal(big.row, 83);
|
||||
assert.equal(big.cols, 4, "fewer columns at a larger size");
|
||||
assert.ok(big.font > base.font, "label text grows with the icon");
|
||||
const pv = await p.$eval(".icon-preview .icon", (i) => i.getBoundingClientRect().width);
|
||||
assert.equal(pv, 52, "the preview shows the size");
|
||||
assert.equal((await p.textContent(".icon-size-value")).trim(), "130%");
|
||||
await shot(p, "07-icon-size-large");
|
||||
await p.click(".icon-presets >> text=Small"); await settle();
|
||||
assert.equal(await p.$eval(".icon-size-slider", (e) => e.value), "80");
|
||||
const small = await grid();
|
||||
noOverlapOrClip(small, "80%");
|
||||
assert.ok(small.icon < base.icon && small.cols > base.cols && small.row < base.row);
|
||||
await setSlider("160");
|
||||
noOverlapOrClip(await grid(), "160%");
|
||||
await setSlider("70");
|
||||
noOverlapOrClip(await grid(), "70%");
|
||||
await shot(p, "08-icon-size-small");
|
||||
await setSlider("130");
|
||||
assert.equal(await p.evaluate(() => localStorage.getItem("launcher.iconSize")), "130");
|
||||
await p.click(".sheet >> text=Done"); await settle();
|
||||
// the drawer follows: bigger icons, fewer columns
|
||||
await p.click(".search-pill"); await settle();
|
||||
const dr = await p.$eval(".drawer .apps", (u) => ({
|
||||
cols: getComputedStyle(u).gridTemplateColumns.split(" ").length,
|
||||
icon: u.querySelector(".icon").getBoundingClientRect().width,
|
||||
}));
|
||||
assert.equal(dr.cols, 3, "drawer: 4 columns -> 3");
|
||||
assert.ok(Math.abs(dr.icon - 67.6) < 0.1, `drawer icon 52px -> 67.6px: ${dr.icon}`);
|
||||
await shot(p, "09-icon-size-drawer-large");
|
||||
await p.click(".drawer-head >> text=Close"); await settle();
|
||||
// saved: it survives a reload, and 100% is saved as 100
|
||||
await p.reload(); await p.waitForSelector(".slots .tile");
|
||||
const again = await grid();
|
||||
assert.equal(again.icon, 52);
|
||||
assert.equal(again.cols, 4);
|
||||
await longpress(".home", 0.95);
|
||||
await p.click(".sheet-item >> text=Icon size"); await settle();
|
||||
await p.click(".icon-presets >> text=Medium"); await settle();
|
||||
await p.click(".sheet >> text=Done"); await settle();
|
||||
const back = await grid();
|
||||
assert.equal(back.icon, 40); assert.equal(back.row, 64); assert.equal(back.cols, 5);
|
||||
// a corrupt saved value is reported (alert and console), not silently replaced
|
||||
const errors = [];
|
||||
p.on("console", (m) => { if (m.type() === "error") errors.push(m.text()); });
|
||||
await p.evaluate(() => localStorage.setItem("launcher.iconSize", "huge"));
|
||||
await p.reload(); await p.waitForSelector(".slots .tile");
|
||||
assert.ok(errors.some((e) => e.includes("saved icon size \"huge\" is not a whole number")), `logged: ${errors}`);
|
||||
assert.ok((await p.textContent("#app")).includes("Icon size problem"), "a notice shows");
|
||||
assert.equal(await p.evaluate(() => localStorage.getItem("launcher.iconSize")), "huge", "the bad value is left alone");
|
||||
await longpress(".home", 0.95);
|
||||
await p.click(".sheet-item >> text=Icon size"); await settle();
|
||||
assert.ok(await p.$(".sheet .alert.destructive"), "the sheet shows the error");
|
||||
await shot(p, "10-icon-size-corrupt");
|
||||
await p.click(".icon-presets >> text=Medium"); await settle();
|
||||
assert.equal(await p.evaluate(() => localStorage.getItem("launcher.iconSize")), "100", "choosing a size replaces it");
|
||||
assert.ok(!(await p.$(".sheet .alert")), "and clears the error");
|
||||
await p.click(".sheet >> text=Done"); await settle();
|
||||
console.log("launcher ok");
|
||||
|
||||
await b.close();
|
||||
|
||||
+14
-21
@@ -133,10 +133,6 @@ extern "js" fn now_ms() -> Double =
|
||||
extern "js" fn storage_get(k : String) -> String =
|
||||
#|(k) => { try { return localStorage.getItem(k) ?? "" } catch { return "" } }
|
||||
|
||||
///|
|
||||
extern "js" fn log_error(line : String) -> Unit =
|
||||
#|(line) => console.error(line)
|
||||
|
||||
///|
|
||||
extern "js" fn storage_has(k : String) -> Bool =
|
||||
#|(k) => { try { return localStorage.getItem(k) !== null } catch { return false } }
|
||||
@@ -159,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, window.scrollY || 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]; return true; }
|
||||
|
||||
///|
|
||||
/// Measurement i: viewport width, height, grid left, top, width, the home's bottom padding.
|
||||
@@ -176,18 +172,23 @@ 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)]; }))
|
||||
|
||||
///|
|
||||
/// Whether the drawer is open and not animating out.
|
||||
extern "js" fn drawer_covering() -> Bool =
|
||||
#|() => !!document.querySelector(".drawer:not(.closing)")
|
||||
/// 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)))); }
|
||||
|
||||
///|
|
||||
/// 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 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).
|
||||
extern "js" fn has_drawer() -> Bool =
|
||||
#|() => !!document.querySelector(".drawer:not(.closing)") && !document.querySelector(".sheet-overlay")
|
||||
#|() => !!document.querySelector(".drawer") && !document.querySelector(".sheet-overlay")
|
||||
|
||||
///|
|
||||
extern "js" fn focus_search() -> Unit =
|
||||
#|() => { const i = document.querySelector(".drawer:not(.picking):not(.closing) .drawer-head input"); if (i) i.focus({ preventScroll: true }) }
|
||||
#|() => { const i = document.querySelector(".drawer:not(.picking) .drawer-head input"); if (i) i.focus({ preventScroll: true }) }
|
||||
|
||||
///|
|
||||
extern "js" fn blur_active() -> Unit =
|
||||
@@ -307,16 +308,8 @@ extern "js" fn h_pick_wallpaper() -> Unit =
|
||||
#|() => window.Android.pickWallpaper()
|
||||
|
||||
///|
|
||||
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_open_recents() -> Unit =
|
||||
#|() => window.Android.openRecents()
|
||||
|
||||
///|
|
||||
extern "js" fn h_http_get(url : String, tag : Int32) -> Unit =
|
||||
|
||||
+26
-73
@@ -20,6 +20,8 @@ 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
|
||||
@@ -41,6 +43,8 @@ fn PageState::new() -> PageState {
|
||||
placed: "",
|
||||
excluded: "[]",
|
||||
cover_y: 0,
|
||||
cover_last: 0.0,
|
||||
cover_loop: false,
|
||||
measured: "",
|
||||
touch: None,
|
||||
demo_widget: 100,
|
||||
@@ -131,31 +135,14 @@ fn exec(e : @app.Effect) -> Unit {
|
||||
}
|
||||
OpenRecents =>
|
||||
if android {
|
||||
if !h_open_recents() {
|
||||
dispatch(RecentsUnavailable)
|
||||
}
|
||||
h_open_recents()
|
||||
} 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) {
|
||||
@@ -170,8 +157,6 @@ fn exec(e : @app.Effect) -> Unit {
|
||||
dispatch(LimitsKnown(id, Some(json)))
|
||||
}
|
||||
SaveHome(json) => storage_set("launcher.home", json)
|
||||
SaveIconSize(pct) => storage_set("launcher.iconSize", pct.to_string())
|
||||
LogError(line) => log_error(line)
|
||||
SaveLastCheck(t) => storage_set("launcher.update.lastCheck", t.to_string())
|
||||
Delay(ms, msg) => set_timeout(ms, fn() { dispatch(msg) })
|
||||
HoldTimer(ms, token) => set_timeout(ms, fn() { feed(Hold(token)) })
|
||||
@@ -216,10 +201,11 @@ fn render() -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
fn sync_measure() -> Unit {
|
||||
fn after_render() -> Unit {
|
||||
let st = state.val
|
||||
fill_icons()
|
||||
if measure() {
|
||||
let key = "\{measured(0)},\{measured(1)},\{measured(2)},\{measured(3)},\{measured(4)},\{measured(5)},\{measured(6)}"
|
||||
let key = "\{measured(0)},\{measured(1)},\{measured(2)},\{measured(3)},\{measured(4)},\{measured(5)}"
|
||||
if key != st.measured {
|
||||
st.measured = key
|
||||
dispatch(
|
||||
@@ -230,18 +216,10 @@ fn sync_measure() -> 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()
|
||||
@@ -273,38 +251,28 @@ fn place() -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
/// Native widgets sit above the page, so the shell hides them while the drawer is open.
|
||||
/// 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.
|
||||
fn cover() -> Unit {
|
||||
let st = state.val
|
||||
let y = if drawer_covering() { -1 } else { 0 }
|
||||
let y = drawer_cover(st.cover_last).to_int()
|
||||
st.cover_last = drawer_bottom()
|
||||
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
|
||||
@@ -390,7 +358,6 @@ 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))))
|
||||
}
|
||||
})
|
||||
@@ -449,12 +416,9 @@ fn wire_events() -> Unit {
|
||||
})
|
||||
listen("window", "resize", true, fn(_) { schedule_render() })
|
||||
listen("window", "scroll", true, fn(_) {
|
||||
request_frame(fn() {
|
||||
sync_measure()
|
||||
if is_android() {
|
||||
place()
|
||||
}
|
||||
})
|
||||
if is_android() {
|
||||
request_frame(place)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -472,14 +436,8 @@ 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) {
|
||||
sync_measure()
|
||||
dispatch(WidgetMenu(id))
|
||||
})
|
||||
expose1("widgetGrab", fn(id) {
|
||||
sync_measure()
|
||||
dispatch(WidgetGrab(id))
|
||||
})
|
||||
expose1("widgetMenu", fn(id) { dispatch(WidgetMenu(id)) })
|
||||
expose1("widgetGrab", fn(id) { dispatch(WidgetGrab(id)) })
|
||||
expose_dd("widgetDrag", fn(x, y) { dispatch(NativeDrag(x, y)) })
|
||||
expose_b("widgetDrop", fn(moved) { dispatch(NativeDrop(moved)) })
|
||||
expose0("place", fn() {
|
||||
@@ -520,12 +478,7 @@ fn main {
|
||||
None
|
||||
}
|
||||
let legacy = if saved is None { Some(storage_legacy()) } else { None }
|
||||
let icon_size = if storage_has("launcher.iconSize") {
|
||||
Some(storage_get("launcher.iconSize"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
dispatch(Restore(saved~, legacy~, icon_size~))
|
||||
dispatch(Restore(saved~, legacy~))
|
||||
if is_android() {
|
||||
// the shell keeps the build whose install the user cancelled (-1: none)
|
||||
let declined = h_declined_version()
|
||||
|
||||
+24
-65
@@ -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 { color: var(--foreground); }
|
||||
.light, .dark { background: var(--background); 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, html.dark, html.light, body { background: transparent; }
|
||||
html, 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;
|
||||
@@ -135,19 +135,14 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
|
||||
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: .4rem;
|
||||
padding: .35rem .15rem; border-radius: calc(var(--radius) + 4px); cursor: pointer; }
|
||||
.tile:active { background: rgb(255 255 255 / .12); }
|
||||
/* --s is the icon size setting as a factor (1 = the original size); the model sets it on
|
||||
the home grid, the drawer list and the sheet's preview, and picks the row height and
|
||||
column count to match (app/view.mbt, grid/scale.mbt). */
|
||||
.icon { width: calc(3.25rem * var(--s, 1)); height: calc(3.25rem * var(--s, 1)); object-fit: contain; pointer-events: none;
|
||||
.icon { width: 3.25rem; height: 3.25rem; object-fit: contain; pointer-events: none;
|
||||
filter: drop-shadow(0 2px 4px rgb(0 0 0 / .3)); }
|
||||
.icon.missing { border-radius: 999px; background: rgb(255 255 255 / .18); object-position: -999px 0; }
|
||||
.name { max-width: 100%; font-size: calc(.75rem * var(--s, 1)); line-height: 1.2; text-align: center;
|
||||
.name { max-width: 100%; font-size: .75rem; line-height: 1.2; text-align: center;
|
||||
text-shadow: var(--shadow-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.slots .tile, .icon-preview .tile { gap: calc(.25rem * var(--s, 1)); padding: calc(.2rem * var(--s, 1)) .1rem; }
|
||||
.slots .icon, .icon-preview .icon { width: calc(2.5rem * var(--s, 1)); height: calc(2.5rem * var(--s, 1)); }
|
||||
.slots .name, .icon-preview .name { font-size: calc(.68rem * var(--s, 1)); }
|
||||
.drawer .apps { gap: calc(1.25rem * var(--s, 1)) .5rem; }
|
||||
.drawer .tile { gap: calc(.4rem * var(--s, 1)); }
|
||||
.slots .tile { gap: .25rem; padding: .2rem .1rem; }
|
||||
.slots .icon { width: 2.5rem; height: 2.5rem; }
|
||||
.slots .name { font-size: .68rem; }
|
||||
|
||||
/* A widget takes whole rows. On a phone the native widget view covers the slot;
|
||||
the label only shows while the slot is not live (or in a desktop browser). */
|
||||
@@ -162,37 +157,25 @@ 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: generous 36-40px handles straddle the widget border (inset enough
|
||||
to stay inside the viewport on full-width widgets); WidgetView passes edge touches through. */
|
||||
/* 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. */
|
||||
.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);
|
||||
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; }
|
||||
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; }
|
||||
.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 .75rem; border-radius: 999px;
|
||||
background: rgb(0 0 0 / .82); color: #fff; font-size: .875rem; white-space: nowrap;
|
||||
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;
|
||||
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; }
|
||||
@@ -221,21 +204,12 @@ 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: GPU-composited slide+fade over the home screen */
|
||||
/* ---- drawer: slides down 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 / .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); }
|
||||
}
|
||||
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; } }
|
||||
.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; }
|
||||
@@ -268,16 +242,6 @@ button { cursor: pointer; }
|
||||
background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
||||
.sheet-item:hover, .sheet-item:active { background: var(--accent); }
|
||||
.sheet .empty { text-shadow: none; color: var(--muted-foreground); }
|
||||
/* ---- icon size sheet */
|
||||
.icon-preview { list-style: none; margin: 0 0 1rem; padding: .75rem .5rem; display: flex; justify-content: space-around;
|
||||
align-items: flex-start; min-height: 6rem; overflow: hidden; border-radius: var(--radius);
|
||||
background: rgb(10 10 14 / .84); color: #fff; }
|
||||
.icon-preview .tile { flex: 1 1 0; min-width: 0; cursor: default; }
|
||||
.icon-size-row { display: flex; align-items: center; gap: .75rem; margin: 0 .5rem 1rem; }
|
||||
.icon-size-slider { flex: 1; min-width: 0; height: 2rem; accent-color: var(--primary); touch-action: pan-y; }
|
||||
.icon-size-value { min-width: 3.25rem; text-align: center; background: var(--secondary); }
|
||||
.icon-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0 .25rem 1rem; }
|
||||
.icon-error { margin: 0 .25rem 1rem; }
|
||||
.widget-list { list-style: none; margin: 0; padding: 0; display: grid; }
|
||||
.widget-list li { display: flex; align-items: center; gap: .75rem; padding: .5rem; border-radius: var(--radius);
|
||||
cursor: pointer; }
|
||||
@@ -286,11 +250,6 @@ 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;
|
||||
@@ -299,4 +258,4 @@ button { cursor: pointer; }
|
||||
#toast { opacity: 0; transition: opacity .2s; animation: none; }
|
||||
#toast.show { opacity: 1; }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) { .drawer, .drawer.closing, .sheet { animation: none; } }
|
||||
@media (prefers-reduced-motion: reduce) { .drawer, .sheet { animation: none; } }
|
||||
Reference in new issue
Block a user