summaryrefslogtreecommitdiff
path: root/mobile-ns/app/main-view-model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'mobile-ns/app/main-view-model.ts')
-rw-r--r--mobile-ns/app/main-view-model.ts50
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');
+ }
+}