diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-26 14:51:36 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-26 14:52:57 +0100 |
commit | d3bf2d09f740221771806789b00bf915c9f5f2e3 (patch) | |
tree | 95f99eabd763dff1907f107393504ee75aa747d7 /mobile-ns/app/main-view-model.ts | |
parent | 466d03a38cb01e9ff9a2d11be113a81c2bdce34a (diff) |
Diffstat (limited to 'mobile-ns/app/main-view-model.ts')
-rw-r--r-- | mobile-ns/app/main-view-model.ts | 50 |
1 files changed, 50 insertions, 0 deletions
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'); + } +} |