From d3bf2d09f740221771806789b00bf915c9f5f2e3 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 26 Jan 2024 14:51:36 +0100 Subject: initial commit --- mobile-ns/app/main-view-model.ts | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 mobile-ns/app/main-view-model.ts (limited to 'mobile-ns/app/main-view-model.ts') diff --git a/mobile-ns/app/main-view-model.ts b/mobile-ns/app/main-view-model.ts new file mode 100644 index 0000000..a354a5d --- /dev/null +++ b/mobile-ns/app/main-view-model.ts @@ -0,0 +1,50 @@ +import { Application, Frame, Http, Observable, Utils } from '@nativescript/core'; +import * as permissions from '@nativescript-community/perms'; + +export class LoginModel extends Observable { + public server: string = 'http://192.168.178.59:8080'; + public username: string; + public password: string; + + constructor() { + super(); + } + + async onLogin() { + const content = new FormData(); + content.append('username', this.username); + content.append('password', this.password); + const response = await Http.request({ + url: this.server, + method: 'POST', + content: content, + }); + + console.log(response.content?.toString()); + + console.log( + Application.android.foregroundActivity.requestPermissions([ + android.Manifest.permission.READ_EXTERNAL_STORAGE, + ], 3765) + ); + console.log( + Application.android.foregroundActivity.shouldShowRequestPermissionRationale(android.Manifest.permission.READ_EXTERNAL_STORAGE) + ); + + console.log( + Utils.android.getApplicationContext().checkPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE, android.os.Process.myPid(), android.os.Process.myUid()) + ); + + console.log( + permissions.request({ + storage: { read: true, write: false }, + photo: { reason: 'to pick images' }, + }) + ); + } + + goToGalleries() { + const frame = Frame.topmost(); + frame.navigate('gallery-page'); + } +} -- cgit v1.2.3