personal data ui fix and endpoint

This commit is contained in:
2026-03-11 17:35:00 +01:00
parent ffc0a1f103
commit f9d8f59195
33 changed files with 430 additions and 402 deletions

View File

@@ -1,10 +1,10 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:sf_shared/sf_shared.dart';
abstract class AccountRemoteDatasource {
abstract class UsersRemoteDatasource {
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request});
Future<List<UserEntity>> getAppUsers({required String userId});
Future<List<UserEntity>> getUsers({required String userId});
Future<void> deleteAppUser({required String userId});
Future<void> deleteUser({required String userId});
}

View File

@@ -1,4 +1,4 @@
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
import 'package:account/src/core/data/datasource/users_remote_datasource.dart';
import 'package:account/src/core/data/models/get_app_users_response_model.dart';
import 'package:account/src/core/data/models/update_user_request_model.dart';
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
@@ -7,11 +7,32 @@ import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:sf_shared/sf_shared.dart';
class AccountRemoteDatasourceImpl implements AccountRemoteDatasource {
AccountRemoteDatasourceImpl(this._repository);
class UsersRemoteDatasourceImpl implements UsersRemoteDatasource {
UsersRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<List<UserEntity>> getUsers({required String userId}) async {
try {
final response = await _repository.get<Map<String, dynamic>>(
'/$userId/devices',
);
final data = response.data!['items'];
if (data == null || data.isEmpty) {
throw Exception('Empty response from /:userId/devices');
}
final model = GetAppUsersResponseModel.fromJson(data);
return model.toEntity();
} on DioException catch (error) {
throw mapDioError(
error,
defaultMessage: error.message ?? 'Error getting devices',
);
}
}
@override
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) async {
try {
@@ -26,61 +47,7 @@ class AccountRemoteDatasourceImpl implements AccountRemoteDatasource {
}
@override
Future<List<UserEntity>> getAppUsers({required String userId}) async {
try {
final response = await _repository.get<Map<String, dynamic>>(
'/$userId/devices',
);
final data = response.data!['items'];
if (data == null || data.isEmpty) {
throw Exception('Empty response from /:userId/devices');
}
final model = GetAppUsersResponseModel.fromJson(data);
/*final model = GetAppUsersResponseModel(items: [
GetAppUsersItemResponseModel(
id: 'id',
delegationId: 'delegationId',
email: 'carlos@test.com',
createdAt: 'createdAt',
updatedAt: 'updatedAt',
status: 'status',
role: 'role',
lastLogin: 'lastLogin',
currentLogin: 'currentLogin',
language: 'language',
firstName: 'Carlos',
lastName: 'lastName',
hasApiKey: 'hasApiKey',
phone: 'phone',),
GetAppUsersItemResponseModel(
id: 'id',
delegationId: 'delegationId',
email: 'ana@test.com',
createdAt: 'createdAt',
updatedAt: 'updatedAt',
status: 'status',
role: 'role',
lastLogin: 'lastLogin',
currentLogin: 'currentLogin',
language: 'language',
firstName: 'Ana',
lastName: 'lastName',
hasApiKey: 'hasApiKey',
phone: 'phone',),
]);*/
return model.toEntity();
} on DioException catch (error) {
throw mapDioError(
error,
defaultMessage: error.message ?? 'Error getting devices',
);
}
}
@override
Future<void> deleteAppUser({required String userId}) async {
throw UnimplementedError();
Future<void> deleteUser({required String userId}) async {
try {
await _repository.delete<void>(
'/users/$userId',

View File

@@ -8,18 +8,10 @@ part 'update_user_request_model.g.dart';
abstract class UpdateUserRequestModel with _$UpdateUserRequestModel {
const factory UpdateUserRequestModel({
required String id,
String? delegationId,
String? email,
String? createdAt,
String? updatedAt,
String? status,
String? role,
String? lastLogin,
String? currentLogin,
String? language,
String? firstName,
String? lastName,
String? hasApiKey,
String? phone,
}) = _UpdateUserRequestModel;
@@ -30,18 +22,10 @@ abstract class UpdateUserRequestModel with _$UpdateUserRequestModel {
extension UpdateUserRequestModelMapper on UpdateUserRequestEntity {
UpdateUserRequestModel toModel() => UpdateUserRequestModel(
id: id,
delegationId: delegationId,
email: email,
createdAt: createdAt,
updatedAt: updatedAt,
status: status,
role: role,
lastLogin: lastLogin,
currentLogin: currentLogin,
language: language,
firstName: firstName,
lastName: lastName,
hasApiKey: hasApiKey,
phone: phone,
);
}

View File

@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$UpdateUserRequestModel {
String get id; String? get delegationId; String? get email; String? get createdAt; String? get updatedAt; String? get status; String? get role; String? get lastLogin; String? get currentLogin; String? get language; String? get firstName; String? get lastName; String? get hasApiKey; String? get phone;
String get id; String? get email; String? get language; String? get firstName; String? get lastName; String? get phone;
/// Create a copy of UpdateUserRequestModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,16 +28,16 @@ $UpdateUserRequestModelCopyWith<UpdateUserRequestModel> get copyWith => _$Update
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestModel&&(identical(other.id, id) || other.id == id)&&(identical(other.email, email) || other.email == email)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
int get hashCode => Object.hash(runtimeType,id,email,language,firstName,lastName,phone);
@override
String toString() {
return 'UpdateUserRequestModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
return 'UpdateUserRequestModel(id: $id, email: $email, language: $language, firstName: $firstName, lastName: $lastName, phone: $phone)';
}
@@ -48,7 +48,7 @@ abstract mixin class $UpdateUserRequestModelCopyWith<$Res> {
factory $UpdateUserRequestModelCopyWith(UpdateUserRequestModel value, $Res Function(UpdateUserRequestModel) _then) = _$UpdateUserRequestModelCopyWithImpl;
@useResult
$Res call({
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
String id, String? email, String? language, String? firstName, String? lastName, String? phone
});
@@ -65,21 +65,13 @@ class _$UpdateUserRequestModelCopyWithImpl<$Res>
/// Create a copy of UpdateUserRequestModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? email = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? phone = freezed,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
as String,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,
));
@@ -166,10 +158,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? email, String? language, String? firstName, String? lastName, String? phone)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _UpdateUserRequestModel() when $default != null:
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
return $default(_that.id,_that.email,_that.language,_that.firstName,_that.lastName,_that.phone);case _:
return orElse();
}
@@ -187,10 +179,10 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? email, String? language, String? firstName, String? lastName, String? phone) $default,) {final _that = this;
switch (_that) {
case _UpdateUserRequestModel():
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
return $default(_that.id,_that.email,_that.language,_that.firstName,_that.lastName,_that.phone);case _:
throw StateError('Unexpected subclass');
}
@@ -207,10 +199,10 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? email, String? language, String? firstName, String? lastName, String? phone)? $default,) {final _that = this;
switch (_that) {
case _UpdateUserRequestModel() when $default != null:
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
return $default(_that.id,_that.email,_that.language,_that.firstName,_that.lastName,_that.phone);case _:
return null;
}
@@ -222,22 +214,14 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
@JsonSerializable()
class _UpdateUserRequestModel implements UpdateUserRequestModel {
const _UpdateUserRequestModel({required this.id, this.delegationId, this.email, this.createdAt, this.updatedAt, this.status, this.role, this.lastLogin, this.currentLogin, this.language, this.firstName, this.lastName, this.hasApiKey, this.phone});
const _UpdateUserRequestModel({required this.id, this.email, this.language, this.firstName, this.lastName, this.phone});
factory _UpdateUserRequestModel.fromJson(Map<String, dynamic> json) => _$UpdateUserRequestModelFromJson(json);
@override final String id;
@override final String? delegationId;
@override final String? email;
@override final String? createdAt;
@override final String? updatedAt;
@override final String? status;
@override final String? role;
@override final String? lastLogin;
@override final String? currentLogin;
@override final String? language;
@override final String? firstName;
@override final String? lastName;
@override final String? hasApiKey;
@override final String? phone;
/// Create a copy of UpdateUserRequestModel
@@ -253,16 +237,16 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestModel&&(identical(other.id, id) || other.id == id)&&(identical(other.email, email) || other.email == email)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
int get hashCode => Object.hash(runtimeType,id,email,language,firstName,lastName,phone);
@override
String toString() {
return 'UpdateUserRequestModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
return 'UpdateUserRequestModel(id: $id, email: $email, language: $language, firstName: $firstName, lastName: $lastName, phone: $phone)';
}
@@ -273,7 +257,7 @@ abstract mixin class _$UpdateUserRequestModelCopyWith<$Res> implements $UpdateUs
factory _$UpdateUserRequestModelCopyWith(_UpdateUserRequestModel value, $Res Function(_UpdateUserRequestModel) _then) = __$UpdateUserRequestModelCopyWithImpl;
@override @useResult
$Res call({
String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone
String id, String? email, String? language, String? firstName, String? lastName, String? phone
});
@@ -290,21 +274,13 @@ class __$UpdateUserRequestModelCopyWithImpl<$Res>
/// Create a copy of UpdateUserRequestModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = freezed,Object? email = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? status = freezed,Object? role = freezed,Object? lastLogin = freezed,Object? currentLogin = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? hasApiKey = freezed,Object? phone = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? email = freezed,Object? language = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? phone = freezed,}) {
return _then(_UpdateUserRequestModel(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
as String,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,
));

View File

@@ -10,18 +10,10 @@ _UpdateUserRequestModel _$UpdateUserRequestModelFromJson(
Map<String, dynamic> json,
) => _UpdateUserRequestModel(
id: json['id'] as String,
delegationId: json['delegationId'] as String?,
email: json['email'] as String?,
createdAt: json['createdAt'] as String?,
updatedAt: json['updatedAt'] as String?,
status: json['status'] as String?,
role: json['role'] as String?,
lastLogin: json['lastLogin'] as String?,
currentLogin: json['currentLogin'] as String?,
language: json['language'] as String?,
firstName: json['firstName'] as String?,
lastName: json['lastName'] as String?,
hasApiKey: json['hasApiKey'] as String?,
phone: json['phone'] as String?,
);
@@ -29,17 +21,9 @@ Map<String, dynamic> _$UpdateUserRequestModelToJson(
_UpdateUserRequestModel instance,
) => <String, dynamic>{
'id': instance.id,
'delegationId': instance.delegationId,
'email': instance.email,
'createdAt': instance.createdAt,
'updatedAt': instance.updatedAt,
'status': instance.status,
'role': instance.role,
'lastLogin': instance.lastLogin,
'currentLogin': instance.currentLogin,
'language': instance.language,
'firstName': instance.firstName,
'lastName': instance.lastName,
'hasApiKey': instance.hasApiKey,
'phone': instance.phone,
};

View File

@@ -1,25 +0,0 @@
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:sf_shared/sf_shared.dart';
class AccountRepositoryImpl implements AccountRepository {
const AccountRepositoryImpl(this._remote);
final AccountRemoteDatasource _remote;
@override
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
return _remote.updateUser(userId: userId, request: request);
}
@override
Future<List<UserEntity>> getAppUsers({required String userId}) {
return _remote.getAppUsers(userId: userId);
}
@override
Future<void> deleteAppUser({required String userId}) {
return _remote.deleteAppUser(userId: userId);
}
}

View File

@@ -0,0 +1,26 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:sf_shared/sf_shared.dart';
import '../../domain/repositories/users_repository.dart';
import '../datasource/users_remote_datasource.dart';
class UsersRepositoryImpl implements UsersRepository {
const UsersRepositoryImpl(this._remote);
final UsersRemoteDatasource _remote;
@override
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
return _remote.updateUser(userId: userId, request: request);
}
@override
Future<List<UserEntity>> getUsers({required String userId}) {
return _remote.getUsers(userId: userId);
}
@override
Future<void> deleteUser({required String userId}) {
return _remote.deleteUser(userId: userId);
}
}

View File

@@ -1,13 +1,13 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:sf_shared/sf_shared.dart';
abstract class AccountRepository {
abstract class UsersRepository {
Future<void> updateUser({
required String userId,
required UpdateUserRequestEntity request
});
Future<List<UserEntity>> getAppUsers({required String userId});
Future<List<UserEntity>> getUsers({required String userId});
Future<void> deleteAppUser({required String userId});
Future<void> deleteUser({required String userId});
}

View File

@@ -1,9 +0,0 @@
import 'package:account/src/core/data/datasource/account_remote_datasource.dart';
import 'package:account/src/core/data/datasource/account_remote_datasource_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
final accountRemoteDatasourceProvider = Provider<AccountRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return AccountRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -1,9 +0,0 @@
import 'package:account/src/core/data/repositories/account_repository_impl.dart';
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/core/providers/account_remote_datasource_provider.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final accountRepositoryProvider = Provider<AccountRepository>((ref) {
final remote = ref.read(accountRemoteDatasourceProvider);
return AccountRepositoryImpl(remote);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasource/users_remote_datasource.dart';
import '../data/datasource/users_remote_datasource_impl.dart';
final usersRemoteDatasourceProvider = Provider<UsersRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return UsersRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../data/repositories/users_repository_impl.dart';
import '../domain/repositories/users_repository.dart';
import 'users_remote_datasource_provider.dart';
final usersRepositoryProvider = Provider<UsersRepository>((ref) {
final remote = ref.read(usersRemoteDatasourceProvider);
return UsersRepositoryImpl(remote);
});

View File

@@ -1,4 +0,0 @@
abstract class DeleteAppUserUseCase {
Future<void> deleteAppUser({required String userId});
}

View File

@@ -1,13 +0,0 @@
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/features/app_users/domain/delete_app_user_use_case.dart';
class DeleteAppUserUseCaseImpl implements DeleteAppUserUseCase {
DeleteAppUserUseCaseImpl(this._repository);
final AccountRepository _repository;
@override
Future<void> deleteAppUser({required String userId}) {
return _repository.deleteAppUser(userId: userId);
}
}

View File

@@ -1,5 +0,0 @@
import 'package:sf_shared/sf_shared.dart';
abstract class GetAppUsersUseCase {
Future<List<UserEntity>> getAppUsers({required String userId});
}

View File

@@ -1,14 +0,0 @@
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/features/app_users/domain/get_app_users_use_case.dart';
import 'package:sf_shared/sf_shared.dart';
class GetAppUsersUseCaseImpl implements GetAppUsersUseCase {
GetAppUsersUseCaseImpl(this._repository);
final AccountRepository _repository;
@override
Future<List<UserEntity>> getAppUsers({required String userId}) {
return _repository.getAppUsers(userId: userId);
}
}

View File

@@ -1,9 +0,0 @@
import 'package:account/src/core/providers/account_repository_provider.dart';
import 'package:account/src/features/app_users/domain/delete_app_user_use_case.dart';
import 'package:account/src/features/app_users/domain/delete_app_user_use_case_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final deleteAppUserUseCaseProvider = Provider.autoDispose<DeleteAppUserUseCase>((ref) {
final authRepository = ref.read(accountRepositoryProvider);
return DeleteAppUserUseCaseImpl(authRepository);
});

View File

@@ -1,9 +0,0 @@
import 'package:account/src/core/providers/account_repository_provider.dart';
import 'package:account/src/features/app_users/domain/get_app_users_use_case.dart';
import 'package:account/src/features/app_users/domain/get_app_users_use_case_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final getAppUsersUseCaseProvider = Provider.autoDispose<GetAppUsersUseCase>((ref) {
final authRepository = ref.read(accountRepositoryProvider);
return GetAppUsersUseCaseImpl(authRepository);
});

View File

@@ -1,8 +1,5 @@
import 'package:legacy_shared/legacy_shared.dart';
import 'package:account/src/features/app_users/domain/delete_app_user_use_case.dart';
import 'package:account/src/features/app_users/domain/get_app_users_use_case.dart';
import 'package:account/src/features/app_users/presentation/providers/delete_app_user_use_case_provider.dart';
import 'package:account/src/features/app_users/presentation/providers/get_app_users_use_case_provider.dart';
import 'package:account/src/core/domain/repositories/users_repository.dart';
import 'package:account/src/core/providers/users_repository_provider.dart';
import 'package:account/src/features/app_users/presentation/state/app_users_view_state.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_shared/sf_shared.dart';
@@ -13,13 +10,11 @@ NotifierProvider.autoDispose<AppUsersViewModel, AppUsersViewState>(
);
class AppUsersViewModel extends Notifier<AppUsersViewState> {
late final GetAppUsersUseCase _getAppUsersUseCase;
late final DeleteAppUserUseCase _deleteAppUserUseCase;
late final UsersRepository _usersRepository;
@override
AppUsersViewState build() {
_getAppUsersUseCase = ref.read(getAppUsersUseCaseProvider);
_deleteAppUserUseCase = ref.read(deleteAppUserUseCaseProvider);
_usersRepository = ref.read(usersRepositoryProvider);
_init();
@@ -30,7 +25,7 @@ class AppUsersViewModel extends Notifier<AppUsersViewState> {
final user = await ref.read(userInfoProvider.future);
setUser(user);
final appUsers = await _getAppUsersUseCase.getAppUsers(userId: user.id);
final appUsers = await _usersRepository.getUsers(userId: user.id);
setAppUsers(appUsers);
}
@@ -49,7 +44,7 @@ class AppUsersViewModel extends Notifier<AppUsersViewState> {
state = state.copyWith(isEditing: !state.isEditing);
}
void deleteAppUser() {
_deleteAppUserUseCase.deleteAppUser(userId: state.loggedUser!.id);
void deleteUser() {
_usersRepository.deleteUser(userId: state.loggedUser!.id);
}
}

View File

@@ -1,6 +0,0 @@
abstract class DeleteAccountUseCase {
Future<void> deleteAccount({
required String userId,
});
}

View File

@@ -1,13 +0,0 @@
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/features/delete_account/domain/delete_account_use_case.dart';
class DeleteAccountUseCaseImpl implements DeleteAccountUseCase {
DeleteAccountUseCaseImpl(this._repository);
final AccountRepository _repository;
@override
Future<void> deleteAccount({required String userId}) {
return _repository.deleteAppUser(userId: userId);
}
}

View File

@@ -1,9 +0,0 @@
import 'package:account/src/core/providers/account_repository_provider.dart';
import 'package:account/src/features/delete_account/domain/delete_account_use_case.dart';
import 'package:account/src/features/delete_account/domain/delete_account_use_case_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final deleteAccountUseCaseProvider = Provider.autoDispose<DeleteAccountUseCase>((ref) {
final accountRepository = ref.read(accountRepositoryProvider);
return DeleteAccountUseCaseImpl(accountRepository);
});

View File

@@ -1,5 +1,5 @@
import 'package:account/src/features/delete_account/domain/delete_account_use_case.dart';
import 'package:account/src/features/delete_account/presentation/providers/delete_account_use_case_provider.dart';
import 'package:account/src/core/domain/repositories/users_repository.dart';
import 'package:account/src/core/providers/users_repository_provider.dart';
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -12,14 +12,13 @@ NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
);
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
late final DeleteAccountUseCase _deleteAccountUseCase;
late final UsersRepository _usersRepository;
late final SharedDevicesRepository _devicesRepository;
late final TextEditingController passwordController;
@override
DeleteAccountViewState build() {
_deleteAccountUseCase = ref.read(deleteAccountUseCaseProvider);
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
_usersRepository = ref.read(usersRepositoryProvider);
passwordController = TextEditingController();
passwordController.addListener(_onPasswordChanged);
@@ -99,7 +98,7 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
try {
state = state.copyWith(isLoading: true);
await _deleteAccountUseCase.deleteAccount(userId: state.loggedUser!.id);
await _usersRepository.deleteUser(userId: state.loggedUser!.id);
if (!ref.mounted) return false;
ref.invalidate(userInfoProvider);

View File

@@ -1,5 +0,0 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
abstract class UpdateUserUseCase {
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request});
}

View File

@@ -1,13 +0,0 @@
import 'package:account/src/core/domain/repositories/account_repository.dart';
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:account/src/features/personal_data/domain/update_user_use_case.dart';
class UpdateUserUseCaseImpl implements UpdateUserUseCase {
UpdateUserUseCaseImpl(this._repository);
final AccountRepository _repository;
@override
Future<void> updateUser({required String userId, required UpdateUserRequestEntity request}) {
return _repository.updateUser(userId: userId, request: request);
}
}

View File

@@ -15,13 +15,11 @@ class PersonalDataScreen extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(personalDataViewModelProvider.notifier);
final state = ref.watch(personalDataViewModelProvider);
final theme = ref.watch(themePortProvider);
return LegacyPageLayout(
theme: theme,
theme: theme,
title: context.translate(I18n.personalData),
body: Container(
padding: SizeUtils.getByScreen(
@@ -31,65 +29,261 @@ theme: theme,
child: SingleChildScrollView(child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Stack(
children: [
Center(child: SvgPicture.asset('assets/images/ui/profile.svg')),
Center(child: SizedBox(
width: 160,
height: 160,
child: Align(alignment: Alignment.bottomRight,
child: IconButton(
onPressed: (){},
icon: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFCAC9C9)
),
padding: EdgeInsets.all(8),
child: Icon(
Icons.edit_outlined,
color: Colors.white,
size: SizeUtils.getByScreen(small: 32, big: 30),
),
),
)
)
))
],
),
const _ProfilePictureSection(),
SizedBox(height: SizeUtils.getByScreen(small: 18, big: 16)),
Text(context.translate(I18n.emailLabel),
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 14, big: 13))
),
Text(state.user?.email ?? '',
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 18, big: 17))
),
const _EmailLabelSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
CustomTextField(
controller: vm.nameController,
hint: state.user?.firstName ?? '',
label: context.translate(I18n.firstNameLabel),
),
const _GenderSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
CustomTextField(
controller: vm.phoneController,
hint: state.user?.phone ?? '',
label: context.translate(I18n.phoneLabel),
),
const _NameSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
CustomTextField(
controller: vm.emailController,
hint: state.user?.email ?? '',
label: context.translate(I18n.emailLabel),
),
const _PhoneSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
const _EmailSection(),
],
))
),
footer: PrimaryButton(
onPressed: vm.updateUser,
footer: Column(
children: [
Text(context.translate(I18n.personalDataMessage)),
SizedBox(height: 14),
const _SaveSection(),
],
)
);
}
}
class _ProfilePictureSection extends ConsumerWidget {
const _ProfilePictureSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
return Stack(
children: [
Center(child: Container(
decoration: BoxDecoration(shape: BoxShape.circle),
child: SvgPicture.asset('assets/images/ui/profile.svg')),
),
Center(child: SizedBox(
width: 160,
height: 160,
child: Align(alignment: Alignment.bottomRight,
child: IconButton(
onPressed: (){},
icon: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFCAC9C9)
),
padding: EdgeInsets.all(8),
child: Icon(
Icons.edit_outlined,
color: Colors.white,
size: SizeUtils.getByScreen(small: 32, big: 30),
),
),
)
)
))
],
);
}
}
class _EmailLabelSection extends ConsumerWidget {
const _EmailLabelSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final email = ref.watch(
personalDataViewModelProvider.select((s)=>s.user?.email ?? '')
);
return Column(
children: [
Text(context.translate(I18n.emailLabel),
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 14, big: 13))
),
Text(email,
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 18, big: 17))
),
],
);
}
}
class _GenderSection extends ConsumerWidget {
const _GenderSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final vm = ref.read(personalDataViewModelProvider.notifier);
final gender = ref.watch(
personalDataViewModelProvider.select((s)=>s.gender)
);
Map<String, String> genderOptions = <String, String>{
'M': context.translate(I18n.male),
'F': context.translate(I18n.female),
'O': context.translate(I18n.ratherNotSay),
};
final setGender = (value){vm.setGender(value.toString());};
return Column(
children: [
Align(
alignment: Alignment.bottomLeft,
child: Text(context.translate(I18n.genderLabel),),
),
Container(
decoration: BoxDecoration(
border: Border.fromBorderSide(BorderSide(
color: theme.getColorFor(ThemeCode.legacyPrimary),
width: 3
)),
borderRadius: BorderRadius.all(Radius.circular(32)),
),
padding: EdgeInsets.symmetric(horizontal: 10),
child: RadioGroup(
onChanged: setGender,
groupValue: gender,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List<Widget>.generate(genderOptions.length, (int index)=>
Row(
children: [
Radio(
value: genderOptions.keys.elementAt(index),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
TextButton(
onPressed: (){setGender(genderOptions.keys.elementAt(index));},
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
minimumSize: Size.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
child: Text(genderOptions.values.elementAt(index),
style: TextStyle(fontSize: 10),
),
),
],
)
)
),
),
)
],
);
}
}
class _NameSection extends ConsumerWidget {
const _NameSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(personalDataViewModelProvider.notifier);
final name = ref.watch(
personalDataViewModelProvider.select((s)=>s.user?.firstName ?? '')
);
return CustomTextField(
controller: vm.nameController,
hint: name,
label: context.translate(I18n.firstNameLabel),
);
}
}
class _PhoneSection extends ConsumerWidget {
const _PhoneSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(personalDataViewModelProvider.notifier);
final phone = ref.watch(
personalDataViewModelProvider.select((s)=>s.user?.phone ?? '')
);
return CustomTextField(
controller: vm.phoneController,
hint: phone,
label: context.translate(I18n.phoneLabel),
keyboardType: TextInputType.phone,
);
}
}
class _EmailSection extends ConsumerWidget {
const _EmailSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(personalDataViewModelProvider.notifier);
final email = ref.watch(
personalDataViewModelProvider.select((s)=>s.user?.email ?? '')
);
return CustomTextField(
controller: vm.emailController,
hint: email,
label: context.translate(I18n.emailLabel),
keyboardType: TextInputType.emailAddress,
);
}
}
class _SaveSection extends ConsumerWidget {
const _SaveSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final vm = ref.read(personalDataViewModelProvider.notifier);
return Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 10),
child: PrimaryButton(
onPressed: () async {
await vm.updateUser();
final errorMessage = ref.read(
personalDataViewModelProvider.select((s)=>s.errorMessage)
);
if (errorMessage.isNotEmpty) {
showTopSnackbar(context, message: errorMessage);
return;
}
final isComplete = ref.read(
personalDataViewModelProvider.select((s)=>s.isComplete)
);
if (isComplete) {
Navigator.pop(context);
}
},
text: context.translate(I18n.submit),
color: theme.getColorFor(ThemeCode.legacyPrimary)
),
);
}
}

View File

@@ -1,9 +0,0 @@
import 'package:account/src/core/providers/account_repository_provider.dart';
import 'package:account/src/features/personal_data/domain/update_user_use_case.dart';
import 'package:account/src/features/personal_data/domain/update_user_use_case_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final updateUserUseCaseProvider = Provider.autoDispose<UpdateUserUseCase>((ref) {
final authRepository = ref.read(accountRepositoryProvider);
return UpdateUserUseCaseImpl(authRepository);
});

View File

@@ -1,12 +1,11 @@
import 'package:account/src/features/personal_data/domain/entities/update_user_request_entity.dart';
import 'package:account/src/features/personal_data/domain/update_user_use_case.dart';
import 'package:account/src/features/personal_data/presentation/providers/update_user_use_case_provider.dart';
import 'package:account/src/features/personal_data/presentation/state/personal_data_view_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_shared/sf_shared.dart';
// import 'package:sf_localizations/sf_localizations.dart';
import '../../../../core/domain/repositories/users_repository.dart';
import '../../../../core/providers/users_repository_provider.dart';
final personalDataViewModelProvider =
NotifierProvider.autoDispose<PersonalDataViewModel, PersonalDataViewState>(
@@ -14,7 +13,7 @@ NotifierProvider.autoDispose<PersonalDataViewModel, PersonalDataViewState>(
);
class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
late final UpdateUserUseCase _updateUserUseCase;
late final UsersRepository _usersRepository;
late final TextEditingController nameController;
late final TextEditingController emailController;
@@ -23,7 +22,7 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
@override
PersonalDataViewState build() {
_updateUserUseCase = ref.read(updateUserUseCaseProvider);
_usersRepository = ref.read(usersRepositoryProvider);
nameController = TextEditingController();
nameController.addListener(_onNameChanged);
@@ -53,6 +52,14 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
state = state.copyWith(user: user);
}
void setGender(String value) {
if (value == state.gender) return;
state = state.copyWith(
gender: value,
);
}
void _onNameChanged() {
final value = nameController.text;
@@ -114,21 +121,28 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
);
}
Future<bool> updateUser() async {
if (state.isLoading) return false;
if (!_validateForm()) return false;
Future<void> updateUser() async {
try {
state = state.copyWith(
isLoading: true,
isComplete: false,
);
if (!_validateForm()) return;
final request = _toRequest();
_updateUserUseCase.updateUser(userId: state.user!.id, request: request);
_usersRepository.updateUser(userId: state.user!.id, request: request);
ref.invalidate(userInfoProvider);
return true;
state = state.copyWith(
isLoading: false,
isComplete: true,
);
return;
} catch (e) {
if (!ref.mounted) return false;
if (!ref.mounted) return;
_finishWithError(message: e.toString());
return false;
}
}
@@ -136,6 +150,7 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
void _finishWithError({required String message}) {
state = state.copyWith(
isLoading: false,
isComplete: false,
errorMessage: message,
);
}

View File

@@ -7,7 +7,9 @@ part 'personal_data_view_state.freezed.dart';
abstract class PersonalDataViewState with _$PersonalDataViewState {
const factory PersonalDataViewState({
@Default(true) bool isLoading,
@Default(null) UserEntity? user,
@Default(false) bool isComplete,
UserEntity? user,
@Default('O') String gender,
@Default('') String name,
@Default('') String phoneNumber,
@Default('') String email,

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$PersonalDataViewState {
bool get isLoading; UserEntity? get user; String get name; String get phoneNumber; String get email; String get password; bool get showPassword; String get errorMessage;
bool get isLoading; bool get isComplete; UserEntity? get user; String get gender; String get name; String get phoneNumber; String get email; String get password; bool get showPassword; String get errorMessage;
/// Create a copy of PersonalDataViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $PersonalDataViewStateCopyWith<PersonalDataViewState> get copyWith => _$Personal
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.user, user) || other.user == user)&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.showPassword, showPassword) || other.showPassword == showPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.user, user) || other.user == user)&&(identical(other.gender, gender) || other.gender == gender)&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.showPassword, showPassword) || other.showPassword == showPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,user,name,phoneNumber,email,password,showPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,user,gender,name,phoneNumber,email,password,showPassword,errorMessage);
@override
String toString() {
return 'PersonalDataViewState(isLoading: $isLoading, user: $user, name: $name, phoneNumber: $phoneNumber, email: $email, password: $password, showPassword: $showPassword, errorMessage: $errorMessage)';
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, user: $user, gender: $gender, name: $name, phoneNumber: $phoneNumber, email: $email, password: $password, showPassword: $showPassword, errorMessage: $errorMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $PersonalDataViewStateCopyWith<$Res> {
factory $PersonalDataViewStateCopyWith(PersonalDataViewState value, $Res Function(PersonalDataViewState) _then) = _$PersonalDataViewStateCopyWithImpl;
@useResult
$Res call({
bool isLoading, UserEntity? user, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage
bool isLoading, bool isComplete, UserEntity? user, String gender, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage
});
@@ -62,11 +62,13 @@ class _$PersonalDataViewStateCopyWithImpl<$Res>
/// Create a copy of PersonalDataViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? user = freezed,Object? name = null,Object? phoneNumber = null,Object? email = null,Object? password = null,Object? showPassword = null,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? user = freezed,Object? gender = null,Object? name = null,Object? phoneNumber = null,Object? email = null,Object? password = null,Object? showPassword = null,Object? errorMessage = null,}) {
return _then(_self.copyWith(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
as UserEntity?,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as UserEntity?,gender: null == gender ? _self.gender : gender // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
@@ -169,10 +171,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, UserEntity? user, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? user, String gender, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PersonalDataViewState() when $default != null:
return $default(_that.isLoading,_that.user,_that.name,_that.phoneNumber,_that.email,_that.password,_that.showPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.user,_that.gender,_that.name,_that.phoneNumber,_that.email,_that.password,_that.showPassword,_that.errorMessage);case _:
return orElse();
}
@@ -190,10 +192,10 @@ return $default(_that.isLoading,_that.user,_that.name,_that.phoneNumber,_that.em
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, UserEntity? user, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? user, String gender, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _PersonalDataViewState():
return $default(_that.isLoading,_that.user,_that.name,_that.phoneNumber,_that.email,_that.password,_that.showPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.user,_that.gender,_that.name,_that.phoneNumber,_that.email,_that.password,_that.showPassword,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -210,10 +212,10 @@ return $default(_that.isLoading,_that.user,_that.name,_that.phoneNumber,_that.em
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, UserEntity? user, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, UserEntity? user, String gender, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _PersonalDataViewState() when $default != null:
return $default(_that.isLoading,_that.user,_that.name,_that.phoneNumber,_that.email,_that.password,_that.showPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.user,_that.gender,_that.name,_that.phoneNumber,_that.email,_that.password,_that.showPassword,_that.errorMessage);case _:
return null;
}
@@ -225,11 +227,13 @@ return $default(_that.isLoading,_that.user,_that.name,_that.phoneNumber,_that.em
class _PersonalDataViewState implements PersonalDataViewState {
const _PersonalDataViewState({this.isLoading = true, this.user = null, this.name = '', this.phoneNumber = '', this.email = '', this.password = '', this.showPassword = false, this.errorMessage = ''});
const _PersonalDataViewState({this.isLoading = true, this.isComplete = true, this.user, this.gender = 'O', this.name = '', this.phoneNumber = '', this.email = '', this.password = '', this.showPassword = false, this.errorMessage = ''});
@override@JsonKey() final bool isLoading;
@override@JsonKey() final UserEntity? user;
@override@JsonKey() final bool isComplete;
@override final UserEntity? user;
@override@JsonKey() final String gender;
@override@JsonKey() final String name;
@override@JsonKey() final String phoneNumber;
@override@JsonKey() final String email;
@@ -247,16 +251,16 @@ _$PersonalDataViewStateCopyWith<_PersonalDataViewState> get copyWith => __$Perso
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.user, user) || other.user == user)&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.showPassword, showPassword) || other.showPassword == showPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.user, user) || other.user == user)&&(identical(other.gender, gender) || other.gender == gender)&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.showPassword, showPassword) || other.showPassword == showPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,user,name,phoneNumber,email,password,showPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,user,gender,name,phoneNumber,email,password,showPassword,errorMessage);
@override
String toString() {
return 'PersonalDataViewState(isLoading: $isLoading, user: $user, name: $name, phoneNumber: $phoneNumber, email: $email, password: $password, showPassword: $showPassword, errorMessage: $errorMessage)';
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, user: $user, gender: $gender, name: $name, phoneNumber: $phoneNumber, email: $email, password: $password, showPassword: $showPassword, errorMessage: $errorMessage)';
}
@@ -267,7 +271,7 @@ abstract mixin class _$PersonalDataViewStateCopyWith<$Res> implements $PersonalD
factory _$PersonalDataViewStateCopyWith(_PersonalDataViewState value, $Res Function(_PersonalDataViewState) _then) = __$PersonalDataViewStateCopyWithImpl;
@override @useResult
$Res call({
bool isLoading, UserEntity? user, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage
bool isLoading, bool isComplete, UserEntity? user, String gender, String name, String phoneNumber, String email, String password, bool showPassword, String errorMessage
});
@@ -284,11 +288,13 @@ class __$PersonalDataViewStateCopyWithImpl<$Res>
/// Create a copy of PersonalDataViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? user = freezed,Object? name = null,Object? phoneNumber = null,Object? email = null,Object? password = null,Object? showPassword = null,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? user = freezed,Object? gender = null,Object? name = null,Object? phoneNumber = null,Object? email = null,Object? password = null,Object? showPassword = null,Object? errorMessage = null,}) {
return _then(_PersonalDataViewState(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
as UserEntity?,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as UserEntity?,gender: null == gender ? _self.gender : gender // ignore: cast_nullable_to_non_nullable
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable

View File

@@ -543,6 +543,10 @@
"deviceSetup_heightLabel": "Height (cm)",
"deviceSetup_heightHint": "120",
"activationKeyLabel": "Activation key",
"rewardsMessage": "Send rewards",
"sendRewards": "Send rewards!"
"rewardsMessage": "Send rewards",
"sendRewards": "Send rewards!",
"male": "Male",
"female": "Female",
"ratherNotSay": "I'd rather not say",
"personalDataMessage": "*This is the app user's personal data"
}

View File

@@ -541,6 +541,10 @@
"deviceSetup_heightLabel": "Altura (cm)",
"deviceSetup_heightHint": "120",
"activationKeyLabel": "Clave de activación",
"rewardsMessage": "Envía una recompensa",
"sendRewards": "¡Enviar recompensas!"
"rewardsMessage": "Envía una recompensa",
"sendRewards": "¡Enviar recompensas!",
"male": "Hombre",
"female": "Mujer",
"ratherNotSay": "Prefiero no decirlo",
"personalDataMessage": "*Estos son los datos personales del usuario de la aplicación"
}

View File

@@ -663,4 +663,8 @@ class I18n {
static const String activationKeyLabel = 'activationKeyLabel';
static const String rewardsMessage = 'rewardsMessage';
static const String sendRewards = 'sendRewards';
static const String male = 'male';
static const String female = 'female';
static const String ratherNotSay = 'ratherNotSay';
static const String personalDataMessage = 'personalDataMessage';
}