profile page with HomeCubit

This commit is contained in:
mohammad
2024-07-24 16:03:22 +03:00
parent 1044775066
commit 69b901afed
10 changed files with 153 additions and 159 deletions
+14 -10
View File
@@ -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,