From 4c21600576a009024d5e179f6191212438b38e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Broks=20Randolfs=20Gail=C4=ABtis?= Date: Sun, 2 Mar 2025 15:05:30 +0200 Subject: [PATCH] Initial nativescript testing --- apps/blakus-nativescript/.gitignore | 1 - .../Android/src/main/AndroidManifest.xml | 3 + .../src/main/res/values-en/strings.xml | 14 ++ .../Android/src/main/res/values/strings.xml | 14 ++ apps/blakus-nativescript/package.json | 7 +- apps/blakus-nativescript/src/app.css | 8 +- apps/blakus-nativescript/src/app.ts | 4 + apps/blakus-nativescript/src/i18n/en.json | 13 ++ .../src/i18n/lv.default.json | 13 ++ apps/blakus-nativescript/src/location.ts | 32 ++++ apps/blakus-nativescript/src/main-page.xml | 15 +- .../src/main-view-model.ts | 163 ++++++++++++++++-- apps/blakus-nativescript/tailwind.config.js | 13 -- 13 files changed, 270 insertions(+), 30 deletions(-) create mode 100644 apps/blakus-nativescript/App_Resources/Android/src/main/res/values-en/strings.xml create mode 100644 apps/blakus-nativescript/App_Resources/Android/src/main/res/values/strings.xml create mode 100644 apps/blakus-nativescript/src/i18n/en.json create mode 100644 apps/blakus-nativescript/src/i18n/lv.default.json create mode 100644 apps/blakus-nativescript/src/location.ts delete mode 100644 apps/blakus-nativescript/tailwind.config.js diff --git a/apps/blakus-nativescript/.gitignore b/apps/blakus-nativescript/.gitignore index 2c6c794..646bfd5 100644 --- a/apps/blakus-nativescript/.gitignore +++ b/apps/blakus-nativescript/.gitignore @@ -8,7 +8,6 @@ platforms/ *.js !eslint.config.js !webpack.config.js -!tailwind.config.js # Logs logs diff --git a/apps/blakus-nativescript/App_Resources/Android/src/main/AndroidManifest.xml b/apps/blakus-nativescript/App_Resources/Android/src/main/AndroidManifest.xml index 2756e53..84664c4 100644 --- a/apps/blakus-nativescript/App_Resources/Android/src/main/AndroidManifest.xml +++ b/apps/blakus-nativescript/App_Resources/Android/src/main/AndroidManifest.xml @@ -14,6 +14,9 @@ + + + + + "Restaurant" + "Pub" + "Ice Cream" + "Food Court" + "Fast Food" + "Cafe" + "Beer Garden" + "Bar" + "Blakus" + "Blakus" + "Blakus" + diff --git a/apps/blakus-nativescript/App_Resources/Android/src/main/res/values/strings.xml b/apps/blakus-nativescript/App_Resources/Android/src/main/res/values/strings.xml new file mode 100644 index 0000000..83a40b2 --- /dev/null +++ b/apps/blakus-nativescript/App_Resources/Android/src/main/res/values/strings.xml @@ -0,0 +1,14 @@ + + + "Restorāns" + "Krogs" + "Saldējums" + "Ēdināšanas laukums" + "Ātras uzkodas" + "Kafejnīca" + "Biergarten" + "Bārs" + "Blakus" + "Blakus" + "Blakus" + diff --git a/apps/blakus-nativescript/package.json b/apps/blakus-nativescript/package.json index 36a442d..62022dd 100644 --- a/apps/blakus-nativescript/package.json +++ b/apps/blakus-nativescript/package.json @@ -4,11 +4,12 @@ "license": "SEE LICENSE IN ", "repository": "", "dependencies": { - "@nativescript/core": "*" + "@nativescript/core": "*", + "@nativescript/geolocation": "^9.0.0", + "@nativescript/localize": "^5.2.0" }, "devDependencies": { "@nativescript/android": "~8.8.0", - "@nativescript/ios": "~8.8.0", - "@nativescript/tailwind": "^2.1.0" + "@nativescript/ios": "~8.8.0" } } diff --git a/apps/blakus-nativescript/src/app.css b/apps/blakus-nativescript/src/app.css index e02abfc..ec2684e 100644 --- a/apps/blakus-nativescript/src/app.css +++ b/apps/blakus-nativescript/src/app.css @@ -1 +1,7 @@ - +.ns-root { + --base-color: red; +} + +Button { + background-color: var(--base-color); +} \ No newline at end of file diff --git a/apps/blakus-nativescript/src/app.ts b/apps/blakus-nativescript/src/app.ts index a4c5c52..2275cac 100644 --- a/apps/blakus-nativescript/src/app.ts +++ b/apps/blakus-nativescript/src/app.ts @@ -1,3 +1,7 @@ import { Application } from '@nativescript/core'; +import { localize } from '@nativescript/localize'; + +Application.setResources({ L: localize }) Application.run({ moduleName: 'app-root' }); +console.log(localize('app.name')); \ No newline at end of file diff --git a/apps/blakus-nativescript/src/i18n/en.json b/apps/blakus-nativescript/src/i18n/en.json new file mode 100644 index 0000000..af22dc5 --- /dev/null +++ b/apps/blakus-nativescript/src/i18n/en.json @@ -0,0 +1,13 @@ +{ + "app.name": "Blakus", + "amenity": { + "bar": "Bar", + "biergarten": "Beer Garden", + "cafe": "Cafe", + "fast_food": "Fast Food", + "food_court": "Food Court", + "ice_cream": "Ice Cream", + "pub": "Pub", + "restaurant": "Restaurant" + } +} \ No newline at end of file diff --git a/apps/blakus-nativescript/src/i18n/lv.default.json b/apps/blakus-nativescript/src/i18n/lv.default.json new file mode 100644 index 0000000..2079b73 --- /dev/null +++ b/apps/blakus-nativescript/src/i18n/lv.default.json @@ -0,0 +1,13 @@ +{ + "app.name": "Blakus", + "amenity": { + "bar": "Bārs", + "biergarten": "Biergarten", + "cafe": "Kafejnīca", + "fast_food": "Ātras uzkodas", + "food_court": "Ēdināšanas laukums", + "ice_cream": "Saldējums", + "pub": "Krogs", + "restaurant": "Restorāns" + } +} \ No newline at end of file diff --git a/apps/blakus-nativescript/src/location.ts b/apps/blakus-nativescript/src/location.ts new file mode 100644 index 0000000..87e80bc --- /dev/null +++ b/apps/blakus-nativescript/src/location.ts @@ -0,0 +1,32 @@ +import * as geolocation from '@nativescript/geolocation'; +import { CoreTypes } from '@nativescript/core' + +export class DeviceLocation { + static async getDeviceLocation() { + try { + + // Enable location services + await geolocation.enableLocationRequest(false, true); + + const enabled = await geolocation.isEnabled(); + + console.log('what do we got?', enabled) + + // Get the current location + const location = await geolocation.getCurrentLocation({ + desiredAccuracy: CoreTypes.Accuracy.high, + maximumAge: 5000, + timeout: 20000, + }); + + if (location) { + console.log(`Latitude: ${location.latitude}, Longitude: ${location.longitude}`); + return location; + } else { + throw new Error('Could not get the location.'); + } + } catch (error) { + console.error('Error obtaining location:', error); + } + } +} \ No newline at end of file diff --git a/apps/blakus-nativescript/src/main-page.xml b/apps/blakus-nativescript/src/main-page.xml index 5970ee7..4f0c4ef 100644 --- a/apps/blakus-nativescript/src/main-page.xml +++ b/apps/blakus-nativescript/src/main-page.xml @@ -1,11 +1,22 @@ - +