commit 84eb32bae127a7f8e57ab6e5585a4d8125a5e90a
parent 44639175084b64c030107584203c2ee31f289eef
Author: triesap <137732411+triesap@users.noreply.github.com>
Date: Mon, 26 Aug 2024 13:48:57 +0000
Update (conf) adding simple nostr key management, add splash screen control to root layout, temporarily move stores to local lib
Diffstat:
11 files changed, 80 insertions(+), 45 deletions(-)
diff --git a/android/app/capacitor.build.gradle b/android/app/capacitor.build.gradle
@@ -11,6 +11,7 @@ apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-dialog')
implementation project(':capacitor-preferences')
+ implementation project(':capacitor-splash-screen')
implementation project(':radroots-capacitor-sqlite')
implementation project(':radroots-capacitor-secure-storage')
diff --git a/android/capacitor.settings.gradle b/android/capacitor.settings.gradle
@@ -8,6 +8,9 @@ project(':capacitor-dialog').projectDir = new File('../../../node_modules/.pnpm/
include ':capacitor-preferences'
project(':capacitor-preferences').projectDir = new File('../../../node_modules/.pnpm/@capacitor+preferences@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/preferences/android')
+include ':capacitor-splash-screen'
+project(':capacitor-splash-screen').projectDir = new File('../../../node_modules/.pnpm/@capacitor+splash-screen@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/splash-screen/android')
+
include ':radroots-capacitor-sqlite'
project(':radroots-capacitor-sqlite').projectDir = new File('../../../packages/capacitor-sqlite/android')
diff --git a/capacitor.config.ts b/capacitor.config.ts
@@ -16,6 +16,9 @@ const config: CapacitorConfig = {
androidScheme: `radroots`,
},
plugins: {
+ SplashScreen: {
+ launchAutoHide: false,
+ },
CapacitorSQLite: {
iosDatabaseLocation: 'Library/radroots',
iosIsEncryption: true,
diff --git a/ios/App/Podfile b/ios/App/Podfile
@@ -13,6 +13,7 @@ def capacitor_pods
pod 'CapacitorCordova', :path => '../../../../node_modules/.pnpm/@capacitor+ios@6.1.2_@capacitor+core@6.1.2/node_modules/@capacitor/ios'
pod 'CapacitorDialog', :path => '../../../../node_modules/.pnpm/@capacitor+dialog@6.0.1_@capacitor+core@6.1.2/node_modules/@capacitor/dialog'
pod 'CapacitorPreferences', :path => '../../../../node_modules/.pnpm/@capacitor+preferences@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/preferences'
+ pod 'CapacitorSplashScreen', :path => '../../../../node_modules/.pnpm/@capacitor+splash-screen@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/splash-screen'
pod 'RadrootsCapacitorSqlite', :path => '../../../../packages/capacitor-sqlite'
pod 'RadrootsCapacitorSecureStorage', :path => '../../../../packages/capacitor-secure-storage'
end
diff --git a/ios/App/Podfile.lock b/ios/App/Podfile.lock
@@ -6,6 +6,8 @@ PODS:
- Capacitor
- CapacitorPreferences (6.0.2):
- Capacitor
+ - CapacitorSplashScreen (6.0.2):
+ - Capacitor
- KeychainSwift (21.0.0)
- RadrootsCapacitorSecureStorage (6.0.1):
- Capacitor
@@ -26,6 +28,7 @@ DEPENDENCIES:
- "CapacitorCordova (from `../../../../node_modules/.pnpm/@capacitor+ios@6.1.2_@capacitor+core@6.1.2/node_modules/@capacitor/ios`)"
- "CapacitorDialog (from `../../../../node_modules/.pnpm/@capacitor+dialog@6.0.1_@capacitor+core@6.1.2/node_modules/@capacitor/dialog`)"
- "CapacitorPreferences (from `../../../../node_modules/.pnpm/@capacitor+preferences@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/preferences`)"
+ - "CapacitorSplashScreen (from `../../../../node_modules/.pnpm/@capacitor+splash-screen@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/splash-screen`)"
- RadrootsCapacitorSecureStorage (from `../../../../packages/capacitor-secure-storage`)
- RadrootsCapacitorSqlite (from `../../../../packages/capacitor-sqlite`)
@@ -44,6 +47,8 @@ EXTERNAL SOURCES:
:path: "../../../../node_modules/.pnpm/@capacitor+dialog@6.0.1_@capacitor+core@6.1.2/node_modules/@capacitor/dialog"
CapacitorPreferences:
:path: "../../../../node_modules/.pnpm/@capacitor+preferences@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/preferences"
+ CapacitorSplashScreen:
+ :path: "../../../../node_modules/.pnpm/@capacitor+splash-screen@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/splash-screen"
RadrootsCapacitorSecureStorage:
:path: "../../../../packages/capacitor-secure-storage"
RadrootsCapacitorSqlite:
@@ -54,12 +59,13 @@ SPEC CHECKSUMS:
CapacitorCordova: f48c89f96c319101cd2f0ce8a2b7449b5fb8b3dd
CapacitorDialog: ad752191fdb22a8d0ac199b0754b8a021d86dbf9
CapacitorPreferences: e8284bf740cf8c6d3f25409af3c01df87dfeb5a1
+ CapacitorSplashScreen: 250df9ef8014fac5c7c1fd231f0f8b1d8f0b5624
KeychainSwift: 4a71a45c802fd9e73906457c2dcbdbdc06c9419d
RadrootsCapacitorSecureStorage: d95a1648c105ddf18a1b0612528e0ce1f77b789e
RadrootsCapacitorSqlite: 11b1be8786af151612ee8e058d16f4979c2e3b1c
SQLCipher: 77fbe633cd84db04b07876dd50766b4924b57d61
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c
-PODFILE CHECKSUM: 14a558b382b7f20a2046b97a573c98b48162394f
+PODFILE CHECKSUM: 02f2d73cce219aad5bc9f8b13e42eeca55d710ce
COCOAPODS: 1.15.2
diff --git a/package.json b/package.json
@@ -38,6 +38,7 @@
"@capacitor/core": "^6.1.2",
"@capacitor/dialog": "^6.0.0",
"@capacitor/preferences": "^6.0.0",
+ "@capacitor/splash-screen": "^6.0.0",
"@capacitor/ios": "^6.0.0",
"@ionic/pwa-elements": "^3.3.0",
"@radroots/capacitor-sqlite": "workspace:*",
diff --git a/src/app.css b/src/app.css
@@ -6,6 +6,12 @@
.button-simple {
@apply flex flex-row h-line w-line justify-center items-center bg-layer-1-surface font-mono text-sm lowercase text-layer-2-glyph;
}
+
+ .flex-fill {
+ width: 100%;
+ height: 100%;
+ flex: 1 0 100%;
+ }
}
@layer base {
diff --git a/src/app.html b/src/app.html
@@ -1,5 +1,5 @@
<!doctype html>
-<html lang="en" data-theme="os_light">
+<html lang="en" data-theme="">
<head>
<meta charset="utf-8" />
diff --git a/src/lib/stores.ts b/src/lib/stores.ts
@@ -0,0 +1,24 @@
+import type { AppLayoutKey, NavigationPreviousParam } from "@radroots/svelte-lib";
+import { type ColorMode, type ThemeKey } from "@radroots/theme";
+import { writable } from "svelte/store";
+
+export const app_thc = writable<ColorMode>(`light`);
+export const app_thm = writable<ThemeKey>(`os`);
+
+export const app_config = writable<boolean>(true);
+export const app_render = writable<boolean>(true);
+export const app_lo = writable<AppLayoutKey>(`base`);
+export const app_win = writable<[number, number]>([0, 0]);
+
+export const app_nav_visible = writable<boolean>(false);
+export const app_nav_blur = writable<boolean>(false);
+
+export const app_tabs_visible = writable<boolean>(false);
+export const app_tabs_blur = writable<boolean>(false);
+export const app_tab_active = writable<number>(0);
+
+export const app_key = writable<string>(``);
+export const app_pwa_polyfills = writable<boolean>(false);
+export const app_sqlite = writable<boolean>(false);
+
+export const app_nav = writable<NavigationPreviousParam[]>([]);
diff --git a/src/routes/(conf)/+layout.ts b/src/routes/(conf)/+layout.ts
@@ -0,0 +1,20 @@
+import { goto } from '$app/navigation';
+import { cl } from '$lib/client';
+import { _cf } from '$lib/conf';
+import type { LayoutLoad, LayoutLoadEvent } from '../$types';
+
+export const load: LayoutLoad = async ({ url }: LayoutLoadEvent) => {
+ try {
+ const key_active = await cl.preferences.get(_cf.pref_key_active);
+ if (key_active) {
+ const ks_keys = await cl.keystore.keys();
+ const active_nostr_key = ks_keys?.find(
+ (i) => i === `nostr:key:${key_active}`,
+ );
+ if (active_nostr_key) return await goto(`/`);
+ }
+
+ } catch (e) { } finally {
+ return {};
+ };
+};
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
@@ -4,26 +4,18 @@
import { PUBLIC_DATABASE_NAME } from "$env/static/public";
import { cl } from "$lib/client";
import LayoutWindow from "$lib/components/layout-window.svelte";
+ import { _cf } from "$lib/conf";
+ import { app_config, app_key, app_lo, app_pwa_polyfills, app_render, app_sqlite, app_thc, app_thm, app_win } from "$lib/stores";
import {
- app_config,
- app_key,
- app_lo,
- app_pwa_polyfills,
- app_render,
- app_sqlite,
- app_thc,
- app_thm,
- app_win,
css_static as CssStatic,
theme_set,
type PropChildren,
} from "@radroots/svelte-lib";
+ import { parse_color_mode, parse_theme_key } from "@radroots/theme/src/utils";
import "../app.css";
let { children }: PropChildren = $props();
- let app_visible = $state(false);
-
let render_pwa = browser && cl.platform === `web`;
if (render_pwa) {
const el = document.createElement(`jeep-sqlite`);
@@ -55,11 +47,11 @@
});
app_thc.subscribe((color_mode) => {
- theme_set($app_thm, color_mode);
+ theme_set(parse_theme_key($app_thm), parse_color_mode(color_mode));
});
app_thm.subscribe((theme_key) => {
- theme_set(theme_key, $app_thc);
+ theme_set(parse_theme_key(theme_key), parse_color_mode($app_thc));
});
app_config.subscribe(async (app_config) => {
@@ -67,12 +59,13 @@
if (!app_config) return;
app_sqlite.set(!!(await cl.db.connect(PUBLIC_DATABASE_NAME)));
- const key_active = await cl.preferences.get("nostr:key:active");
+ const key_active = await cl.preferences.get(_cf.pref_key_active);
console.log(`key_active `, key_active)
const nostr_key = await cl.keystore.get(`nostr:key:${key_active}`);
- console.log(`nostr_key `, nostr_key);
+ console.log(`nostr_key `, nostr_key)
if(typeof nostr_key === `string` && nostr_key) app_key.set(nostr_key);
else {
+ await cl.preferences.remove(_cf.pref_key_active);
await goto(`/conf/nostr`);
return;
}
@@ -85,11 +78,7 @@
app_render.subscribe(async (app_render) => {
try {
- if (!app_render) {
- app_visible = false;
- return;
- }
-
+ if (!app_render) return;
let dev_routes = false;
let route = "/";
if (dev_routes) route = `/`;
@@ -97,31 +86,12 @@
} catch (e) {
console.log(`(app_render) error `, e);
} finally {
- app_visible = true;
+ await cl.window.splash_hide();
}
});
</script>
-{#if app_visible}
- <LayoutWindow>
- {@render children()}
- </LayoutWindow>
-{:else}
- <div class={`flex flex-col w-full justify-center items-center`}>
- <button
- class={`flex flex-row justify-center items-center`}
- onclick={async () => {
- location.reload();
- }}
- >
- <div
- class={`flex flex-col h-line w-line justify-center items-center bg-layer-1-surface`}
- >
- <p class={`font-mono text-sm lowercase text-layer-2-glyph`}>
- {`There was an error loading the app. Click to reload.`}
- </p>
- </div>
- </button>
- </div>
-{/if}
+<LayoutWindow>
+ {@render children()}
+</LayoutWindow>
<CssStatic />