mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 22:17:55 +00:00
profile page with HomeCubit
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:syncrow_app/features/auth/model/token.dart';
|
||||
|
||||
class UserModel {
|
||||
@@ -6,7 +9,7 @@ class UserModel {
|
||||
final String? email;
|
||||
final String? firstName;
|
||||
final String? lastName;
|
||||
final String? profilePicture;
|
||||
final Uint8List? profilePicture;
|
||||
final String? phoneNumber;
|
||||
final bool? isEmailVerified;
|
||||
final String? regionName;
|
||||
@@ -33,38 +36,39 @@ class UserModel {
|
||||
email: json['email'],
|
||||
firstName: json['firstName'],
|
||||
lastName: json['lastName'],
|
||||
profilePicture: json['profilePicture'],
|
||||
profilePicture: UserModel.decodeBase64Image(json['profilePicture']),
|
||||
phoneNumber: json['phoneNumber'],
|
||||
isEmailVerified: json['isEmailVerified'],
|
||||
isAgreementAccepted: json['isAgreementAccepted'],
|
||||
regionName: json['region']?['regionName'], // Extract regionName
|
||||
timeZone: json['timeZone']?['timeZoneOffset'], // Extract regionName
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
//uuid to json
|
||||
|
||||
//from token
|
||||
factory UserModel.fromToken(Token token) {
|
||||
factory UserModel.fromToken(Token token) {
|
||||
Map<String, dynamic> tempJson = Token.decodeToken(token.accessToken);
|
||||
|
||||
return UserModel(
|
||||
uuid: tempJson['uuid'].toString(),
|
||||
email: tempJson['email'],
|
||||
lastName: tempJson['lastName'],
|
||||
firstName:tempJson['firstName'] ,
|
||||
profilePicture: tempJson['profilePicture'],
|
||||
profilePicture: UserModel.decodeBase64Image(tempJson['profilePicture']),
|
||||
phoneNumber: null,
|
||||
isEmailVerified: null,
|
||||
isAgreementAccepted: null,
|
||||
regionName: tempJson['region']?['regionName'],
|
||||
timeZone: tempJson['timezone']?['timeZoneOffset'],
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
static Uint8List? decodeBase64Image(String? base64String) {
|
||||
if (base64String != null) {
|
||||
return base64.decode(base64String);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': uuid,
|
||||
|
||||
Reference in New Issue
Block a user