commit dfd2bf1f118a6dfc2ad3e93bab793791ec1d9ac6
parent 8ea6d17f6eebbf2a533efa6695e45384cbde535d
Author: triesap <137732411+triesap@users.noreply.github.com>
Date: Thu, 29 Aug 2024 09:55:39 +0000
Edit `/models/location-gcs` adding a test suite to create and list saved location_gcs models using device geolocation
Diffstat:
9 files changed, 150 insertions(+), 90 deletions(-)
diff --git a/android/app/capacitor.build.gradle b/android/app/capacitor.build.gradle
@@ -17,6 +17,7 @@ dependencies {
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-share')
implementation project(':capacitor-status-bar')
+ implementation project(':radroots-capacitor-native-settings')
implementation project(':radroots-capacitor-sqlite')
implementation project(':radroots-capacitor-secure-storage')
implementation project(':radroots-capacitor-wifi')
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
@@ -38,4 +38,7 @@
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-feature android:name="android.hardware.location.gps" />
</manifest>
diff --git a/android/capacitor.settings.gradle b/android/capacitor.settings.gradle
@@ -26,6 +26,9 @@ project(':capacitor-share').projectDir = new File('../../../node_modules/.pnpm/@
include ':capacitor-status-bar'
project(':capacitor-status-bar').projectDir = new File('../../../node_modules/.pnpm/@capacitor+status-bar@6.0.1_@capacitor+core@6.1.2/node_modules/@capacitor/status-bar/android')
+include ':radroots-capacitor-native-settings'
+project(':radroots-capacitor-native-settings').projectDir = new File('../../../packages/capacitor-native-settings/android')
+
include ':radroots-capacitor-sqlite'
project(':radroots-capacitor-sqlite').projectDir = new File('../../../packages/capacitor-sqlite/android')
diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj
@@ -348,7 +348,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 13;
+ CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = AR84X5Z9HU;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Radroots;
@@ -370,7 +370,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 13;
+ CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = AR84X5Z9HU;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Radroots;
diff --git a/ios/App/Podfile b/ios/App/Podfile
@@ -19,6 +19,7 @@ def capacitor_pods
pod 'CapacitorSplashScreen', :path => '../../../../node_modules/.pnpm/@capacitor+splash-screen@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/splash-screen'
pod 'CapacitorShare', :path => '../../../../node_modules/.pnpm/@capacitor+share@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/share'
pod 'CapacitorStatusBar', :path => '../../../../node_modules/.pnpm/@capacitor+status-bar@6.0.1_@capacitor+core@6.1.2/node_modules/@capacitor/status-bar'
+ pod 'RadrootsCapacitorNativeSettings', :path => '../../../../packages/capacitor-native-settings'
pod 'RadrootsCapacitorSqlite', :path => '../../../../packages/capacitor-sqlite'
pod 'RadrootsCapacitorSecureStorage', :path => '../../../../packages/capacitor-secure-storage'
pod 'RadrootsCapacitorWifi', :path => '../../../../packages/capacitor-wifi'
diff --git a/ios/App/Podfile.lock b/ios/App/Podfile.lock
@@ -19,6 +19,8 @@ PODS:
- CapacitorStatusBar (6.0.1):
- Capacitor
- KeychainSwift (21.0.0)
+ - RadrootsCapacitorNativeSettings (6.0.1):
+ - Capacitor
- RadrootsCapacitorSecureStorage (6.0.1):
- Capacitor
- KeychainSwift (~> 21.0)
@@ -46,6 +48,7 @@ DEPENDENCIES:
- "CapacitorShare (from `../../../../node_modules/.pnpm/@capacitor+share@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/share`)"
- "CapacitorSplashScreen (from `../../../../node_modules/.pnpm/@capacitor+splash-screen@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/splash-screen`)"
- "CapacitorStatusBar (from `../../../../node_modules/.pnpm/@capacitor+status-bar@6.0.1_@capacitor+core@6.1.2/node_modules/@capacitor/status-bar`)"
+ - RadrootsCapacitorNativeSettings (from `../../../../packages/capacitor-native-settings`)
- RadrootsCapacitorSecureStorage (from `../../../../packages/capacitor-secure-storage`)
- RadrootsCapacitorSqlite (from `../../../../packages/capacitor-sqlite`)
- RadrootsCapacitorWifi (from `../../../../packages/capacitor-wifi`)
@@ -77,6 +80,8 @@ EXTERNAL SOURCES:
:path: "../../../../node_modules/.pnpm/@capacitor+splash-screen@6.0.2_@capacitor+core@6.1.2/node_modules/@capacitor/splash-screen"
CapacitorStatusBar:
:path: "../../../../node_modules/.pnpm/@capacitor+status-bar@6.0.1_@capacitor+core@6.1.2/node_modules/@capacitor/status-bar"
+ RadrootsCapacitorNativeSettings:
+ :path: "../../../../packages/capacitor-native-settings"
RadrootsCapacitorSecureStorage:
:path: "../../../../packages/capacitor-secure-storage"
RadrootsCapacitorSqlite:
@@ -96,12 +101,13 @@ SPEC CHECKSUMS:
CapacitorSplashScreen: 250df9ef8014fac5c7c1fd231f0f8b1d8f0b5624
CapacitorStatusBar: b81d4fb5d4e0064c712018071b3ab4b810b39a63
KeychainSwift: 4a71a45c802fd9e73906457c2dcbdbdc06c9419d
+ RadrootsCapacitorNativeSettings: 0c099fd9e4b3ff04cde651e94c4057295066dbeb
RadrootsCapacitorSecureStorage: d95a1648c105ddf18a1b0612528e0ce1f77b789e
RadrootsCapacitorSqlite: 11b1be8786af151612ee8e058d16f4979c2e3b1c
RadrootsCapacitorWifi: b655736c72ac2ed083635544e6ceddb875c01518
SQLCipher: 77fbe633cd84db04b07876dd50766b4924b57d61
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c
-PODFILE CHECKSUM: e77f3eee0f3fe0258bffb67c5384108a83230f66
+PODFILE CHECKSUM: 34db81164faae86cd39fa914520554892f82ec41
COCOAPODS: 1.15.2
diff --git a/package.json b/package.json
@@ -46,6 +46,7 @@
"@capacitor/status-bar": "^6.0.0",
"@capacitor/ios": "^6.0.0",
"@ionic/pwa-elements": "^3.3.0",
+ "@radroots/capacitor-native-settings": "workspace:*",
"@radroots/capacitor-sqlite": "workspace:*",
"@radroots/capacitor-secure-storage": "workspace:*",
"@radroots/capacitor-wifi": "workspace:*",
diff --git a/src/app.css b/src/app.css
@@ -19,6 +19,15 @@
background-color: hsl(var(--layer-0-surface));
}
+ body {
+ -ms-overflow-style: none;
+ scrollbar-width: none;
+ }
+
+ body::-webkit-scrollbar {
+ display: none;
+ }
+
p {
@apply select-none cursor-none;
}
diff --git a/src/routes/(app)/models/location-gcs/+page.svelte b/src/routes/(app)/models/location-gcs/+page.svelte
@@ -2,103 +2,139 @@
import { goto } from "$app/navigation";
import { cl } from "$lib/client";
import LayoutTrellis from "$lib/components/layout-trellis.svelte";
- import { type LocationGcsFormFields } from "@radroots/client/src/capacitor/sql";
- import { trellis } from "@radroots/svelte-lib";
+ import { type LocationGcs, type LocationGcsFormFields } from "@radroots/client";
+ import { trellis as Trellis } from "@radroots/svelte-lib";
import { location_geohash } from "@radroots/utils";
+
+ let locations_all = $state<LocationGcs[]>([]);
+
+ $effect(() => {
+ (async () => {
+ try {
+ const res = await cl.db.location_gcs_get({
+ list: [`all`],
+ });
+ if(typeof res !== `string`) locations_all = res;
+ } catch (e) { }
+ })();
+ });
</script>
-<svelte:component this={LayoutTrellis}>
- <svelte:component
- this={trellis}
- basis={{
- args: {
- layer: 1,
- title: {
- value: `Location GCS`,
- },
- list: [
- {
- offset: {
- mod: {
- key: `caret-left`,
- },
- },
- touch: {
- label: {
- left: [
- {
- value: "Back",
- },
- ],
- },
- callback: async () => {
- await goto(`/`);
- },
+<LayoutTrellis>
+ <Trellis
+ basis={{
+ args: {
+ layer: 1,
+ title: {
+ value: `Location GCS`,
+ },
+ list: [
+ {
+ offset: {
+ mod: {
+ key: `caret-left`,
},
},
- {
- touch: {
- label: {
- left: [
- {
- value: `Read Logs`,
- classes: `capitalize`,
- },
- ],
- },
- callback: async () => {
- await cl.dialog.alert(JSON.stringify(cl.db.logs));
- },
+ touch: {
+ label: {
+ left: [
+ {
+ value: "Back",
+ },
+ ],
+ },
+ callback: async () => {
+ await goto(`/`);
},
},
- {
- touch: {
- label: {
- left: [
- {
- value: `Add Current Location`,
- classes: `capitalize`,
- },
- ],
- },
- callback: async () => {
- const pos = await cl.geo.current();
- console.log(JSON.stringify(pos,null,4), `pos`)
- if (pos) {
- const { lat, lng } = pos;
- const geohash = location_geohash(lat, lng);
- const fields: LocationGcsFormFields = {
- lat: lat.toString(),
- lng: lng.toString(),
- geohash
- };
- console.log(JSON.stringify(fields,null,4), `fields`)
- const res = await cl.db.location_gcs_add(fields);
- await cl.dialog.alert(JSON.stringify(res));
+ },
+ {
+ touch: {
+ label: {
+ left: [
+ {
+ value: `Add Current Location`,
+ classes: `capitalize`,
+ },
+ ],
+ },
+ callback: async () => {
+ const loc_gcs = await cl.geo.current();
+ if (loc_gcs && typeof loc_gcs !== `string`) {
+ const loc_gcs_label = await cl.dialog.prompt({
+ title: `Geolocation Label`,
+ message: `What is the name of the location.`,
+ input_placeholder: `Enter location name`,
+ });
+ if(loc_gcs_label === false) return;
+
+
+ const { lat, lng } = loc_gcs;
+ const geohash = location_geohash(lat, lng);
+ const fields: LocationGcsFormFields = {
+ lat: lat.toString(),
+ lng: lng.toString(),
+ geohash,
+ label: loc_gcs_label
+ };
+ const exe_res = await cl.db.location_gcs_add(fields);
+ if(typeof exe_res !== `string` && `id` in exe_res) {
+ await cl.dialog.alert(`Added new location (${exe_res.id})`);
+ } else if(typeof exe_res === `string` && exe_res === `*-location-gcs-geohash-unique`) {
+ await cl.dialog.alert(`This location has already been added.`);
}
- },
+ } else if (loc_gcs && typeof loc_gcs === `string`) {
+ const dcf_res = await cl.dialog.confirm(`Enable location permission is required.`);
+ if (dcf_res) {
+ await cl.settings.open(
+ cl.platform === `ios`
+ ? { ios: { setting: `LocationServices` } }
+ : { android: { setting: `Location` } },
+ );
+ }
+ }
},
},
- {
- touch: {
- label: {
- left: [
- {
- value: `Read All`,
- classes: `capitalize`,
- },
- ],
- },
- callback: async () => {
- const res = await cl.db.location_gcs_get({
- list: [`all`],
- });
- await cl.dialog.alert(JSON.stringify(res));
- },
+ },
+ {
+ touch: {
+ label: {
+ left: [
+ {
+ value: `Read Saved Locations`,
+ classes: `capitalize`,
+ },
+ ],
+ },
+ callback: async () => {
+ const res = await cl.db.location_gcs_get({
+ list: [`all`],
+ });
+ if(typeof res !== `string`) locations_all = res;
+
},
},
- ],
- },
- }}
+ },
+ ],
+ },
+ }}
/>
-</svelte:component>
+ <div class={`flex flex-col justify-center items-center`}>
+ {#if locations_all.length > 0}
+ {#each locations_all as location}
+ <div class={`flex flex-col justify-center items-center`}>
+ <pre
+ class={`glyph font-sans font-[400] text-layer-0-glyph`}>{JSON.stringify(
+ location,
+ null,
+ 4,
+ )}</pre>
+ </div>
+ {/each}
+ {:else}
+ <p class={`glyph font-sans font-[400] text-layer-0-glyph`}>
+ {"No locations saved"}
+ </p>
+ {/if}
+ </div>
+</LayoutTrellis>