diff --git a/ng-app/src/lib/Login.svelte b/ng-app/src/lib/Login.svelte index 8bdf5ed..cee8837 100644 --- a/ng-app/src/lib/Login.svelte +++ b/ng-app/src/lib/Login.svelte @@ -22,7 +22,7 @@ import { PuzzlePiece, XCircle, - ArrowLeftCircle, + Backspace, ArrowPath, LockOpen, } from "svelte-heros-v2"; @@ -31,7 +31,6 @@ export let for_import = false; let tauri_platform = import.meta.env.TAURI_PLATFORM; - let mobile = tauri_platform == "android" || tauri_platform == "ios"; const dispatch = createEventDispatcher(); @@ -87,8 +86,6 @@ let ordered = []; - let last_one = {}; - let shuffle_pin; let error; @@ -98,14 +95,9 @@ function order() { step = "order"; ordered = []; - last_one = {}; // In case, this is called by the cancel button, we need to reset the selection. selection.forEach((emoji) => (emoji.sel = undefined)); selection = selection; - - for (let i = 0; i < pazzle_length; i++) { - last_one[i] = true; - } } async function start_pin() { @@ -230,23 +222,16 @@ dispatch("cancel"); } - function to_previous_pazzle() { - pazzlePage = pazzlePage - 1; - } - async function on_pin_key(val) { pin_code = [...pin_code, val]; } - async function select_order(val, pos) { - delete last_one[pos]; - console.debug(last_one, val); - + async function select_order(val) { ordered.push(val); val.sel = ordered.length; selection = selection; if (ordered.length == pazzle_length - 1) { - let last = selection[Object.keys(last_one)[0]]; + let last = selection.find((emoji) => !emoji.sel); ordered.push(last); last.sel = ordered.length; selection = selection; @@ -254,9 +239,58 @@ await start_pin(); } } + + function go_back() { + if (step === "pazzle") { + // Go to previous pazzle or init page, if on first pazzle. + if (pazzlePage === 0) { + init(); + } else { + pazzlePage -= 1; + } + } else if (step === "order") { + if (ordered.length === 0) { + step = "pazzle"; + } else { + const last_selected = ordered.pop(); + last_selected.sel = null; + ordered = ordered; + selection = selection; + } + } else if (step === "pin") { + if (pin_code.length === 0) { + // Unselect the last two elements. + const to_unselect = ordered.slice(-2); + to_unselect.forEach((val) => { + val.sel = null; + }); + + ordered = ordered.slice(0, -2); + selection = selection; + step = "order"; + } else { + pin_code = pin_code.slice(0, pin_code.length - 1); + } + } + } + + let width: number; + let breakPoint: number = 361; + let mobile = false; + $: if (width >= breakPoint) { + mobile = false; + } else { + mobile = true; + } -
+
{#if step == "load"}

How to open your wallet, step by step:

@@ -322,6 +356,14 @@ {:else}
+ -
{/if}
@@ -362,60 +396,8 @@

{/if} - {:else if step == "pazzle"} -
-
-

- - - Select your emoji of category: {emoji_cat[ - shuffle.category_indices[pazzlePage] - ]} -

- {#each [0, 1, 2, 3, 4] as row} -
- {#each emojis2[pazzlePage]?.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i (pazzlePage + "-" + row + "-" + i)} -
select(row * 3 + i)} - on:keypress={() => select(row * 3 + i)} - > - -
- {/each} -
- {/each} -
-
- - -
-
- {:else if step == "order"} - + + {:else if step == "pazzle" || step == "order" || step == "pin" || step == "mnemonic"}
-
-

- Click your emojis in the correct order -

- {#each [0, 1, 2] as row} -
- {#each selection.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i} - {#if !emoji.sel} +
+ {#if step == "pazzle"} +

+ + + Select your emoji of category: {emoji_cat[ + shuffle.category_indices[pazzlePage] + ]} +

+ {#each [0, 1, 2, 3, 4] as row} +
+ {#each emojis2[pazzlePage]?.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i (pazzlePage + "-" + row + "-" + i)}
select_order(emoji, row * 3 + i)} - on:keypress={() => select_order(emoji, row * 3 + i)} + on:click={() => select(row * 3 + i)} + on:keypress={() => select(row * 3 + i)} > - +
- {:else} -
- - {emoji.sel} + {/each} + {:else if step == "order"} +

+ Click your emojis in the correct order +

+ {#each [0, 1, 2] as row} +
+ {#each selection.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i} + {#if !emoji.sel} +
select_order(emoji)} + on:keypress={() => select_order(emoji)} > -
- {/if} - {/each} + +
+ {:else} +
+ + {emoji.sel} +
+ {/if} + {/each} +
+ {/each} + {:else if step == "pin"} +

+ Enter your PIN code: + {#each pin_code as pin_key}*{/each} +

+ {#each [0, 1, 2] as row} +
+ {#each shuffle_pin.slice(0 + row * 3, 3 + row * 3) as num} + + {/each} +
+ {/each} +
+
+ +
- {/each} + {/if}
+
- - -
-
- {:else if step == "pin"} -
-
-

- Enter your PIN code -

- {#each [0, 1, 2] as row} -
- {#each shuffle_pin.slice(0 + row * 3, 3 + row * 3) as num} - - {/each} -
- {/each} -
-
- - -
-
-
- -
{:else if step == "opening"} @@ -660,6 +626,8 @@ {/if}
+ +