Implement FCM [WIP]

This commit is contained in:
2024-05-31 15:22:27 +02:00
parent 0ad82bb248
commit dfcee5dfc7
33 changed files with 665 additions and 337 deletions

View File

@@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:simplecloudnotifier/api/api_client.dart';
import 'package:simplecloudnotifier/models/client.dart';
import 'package:simplecloudnotifier/models/key_token_auth.dart';
import 'package:simplecloudnotifier/models/user.dart';
import 'package:simplecloudnotifier/state/globals.dart';
@@ -9,10 +10,19 @@ class UserAccount extends ChangeNotifier {
User? _user;
User? get user => _user;
Client? _client;
Client? get client => _client;
KeyTokenAuth? _auth;
KeyTokenAuth? get auth => _auth;
UserAccount() {
static UserAccount? _singleton = UserAccount._internal();
factory UserAccount() {
return _singleton ?? (_singleton = UserAccount._internal());
}
UserAccount._internal() {
load();
}
@@ -38,6 +48,16 @@ class UserAccount extends ChangeNotifier {
notifyListeners();
}
void setClient(Client client) {
_client = client;
notifyListeners();
}
void clearClient() {
_client = null;
notifyListeners();
}
void load() {
final uid = Globals().sharedPrefs.getString('auth.userid');
final tok = Globals().sharedPrefs.getString('auth.token');