feat : auth package

This commit is contained in:
2025-05-11 11:50:01 +03:30
parent 9ec761e6eb
commit 114f8a1ada
12 changed files with 310 additions and 74 deletions

View File

@@ -0,0 +1,18 @@
// Generated by Hive CE
// Do not modify
// Check in to version control
import 'package:hive_ce/hive.dart';
import 'package:auth/src/data/models/user_local/user_local_model.dart';
extension HiveRegistrar on HiveInterface {
void registerAdapters() {
registerAdapter(UserLocalModelAdapter());
}
}
extension IsolatedHiveRegistrar on IsolatedHiveInterface {
void registerAdapters() {
registerAdapter(UserLocalModelAdapter());
}
}

View File

@@ -0,0 +1,160 @@
// dart format width=80
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'auth_response_dto.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$AuthResponseDto {
String? get refresh; String? get access;@JsonKey(name: 'otp_status') bool? get otpStatus;
/// Create a copy of AuthResponseDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$AuthResponseDtoCopyWith<AuthResponseDto> get copyWith => _$AuthResponseDtoCopyWithImpl<AuthResponseDto>(this as AuthResponseDto, _$identity);
/// Serializes this AuthResponseDto to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthResponseDto&&(identical(other.refresh, refresh) || other.refresh == refresh)&&(identical(other.access, access) || other.access == access)&&(identical(other.otpStatus, otpStatus) || other.otpStatus == otpStatus));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,refresh,access,otpStatus);
@override
String toString() {
return 'AuthResponseDto(refresh: $refresh, access: $access, otpStatus: $otpStatus)';
}
}
/// @nodoc
abstract mixin class $AuthResponseDtoCopyWith<$Res> {
factory $AuthResponseDtoCopyWith(AuthResponseDto value, $Res Function(AuthResponseDto) _then) = _$AuthResponseDtoCopyWithImpl;
@useResult
$Res call({
String? refresh, String? access,@JsonKey(name: 'otp_status') bool? otpStatus
});
}
/// @nodoc
class _$AuthResponseDtoCopyWithImpl<$Res>
implements $AuthResponseDtoCopyWith<$Res> {
_$AuthResponseDtoCopyWithImpl(this._self, this._then);
final AuthResponseDto _self;
final $Res Function(AuthResponseDto) _then;
/// Create a copy of AuthResponseDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? refresh = freezed,Object? access = freezed,Object? otpStatus = freezed,}) {
return _then(_self.copyWith(
refresh: freezed == refresh ? _self.refresh : refresh // ignore: cast_nullable_to_non_nullable
as String?,access: freezed == access ? _self.access : access // ignore: cast_nullable_to_non_nullable
as String?,otpStatus: freezed == otpStatus ? _self.otpStatus : otpStatus // ignore: cast_nullable_to_non_nullable
as bool?,
));
}
}
/// @nodoc
@JsonSerializable()
class _AuthResponseDto implements AuthResponseDto {
const _AuthResponseDto({this.refresh, this.access, @JsonKey(name: 'otp_status') this.otpStatus});
factory _AuthResponseDto.fromJson(Map<String, dynamic> json) => _$AuthResponseDtoFromJson(json);
@override final String? refresh;
@override final String? access;
@override@JsonKey(name: 'otp_status') final bool? otpStatus;
/// Create a copy of AuthResponseDto
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$AuthResponseDtoCopyWith<_AuthResponseDto> get copyWith => __$AuthResponseDtoCopyWithImpl<_AuthResponseDto>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$AuthResponseDtoToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AuthResponseDto&&(identical(other.refresh, refresh) || other.refresh == refresh)&&(identical(other.access, access) || other.access == access)&&(identical(other.otpStatus, otpStatus) || other.otpStatus == otpStatus));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,refresh,access,otpStatus);
@override
String toString() {
return 'AuthResponseDto(refresh: $refresh, access: $access, otpStatus: $otpStatus)';
}
@override
AuthResponseEntity toEntity() {
// TODO: implement toEntity
throw UnimplementedError();
}
}
/// @nodoc
abstract mixin class _$AuthResponseDtoCopyWith<$Res> implements $AuthResponseDtoCopyWith<$Res> {
factory _$AuthResponseDtoCopyWith(_AuthResponseDto value, $Res Function(_AuthResponseDto) _then) = __$AuthResponseDtoCopyWithImpl;
@override @useResult
$Res call({
String? refresh, String? access,@JsonKey(name: 'otp_status') bool? otpStatus
});
}
/// @nodoc
class __$AuthResponseDtoCopyWithImpl<$Res>
implements _$AuthResponseDtoCopyWith<$Res> {
__$AuthResponseDtoCopyWithImpl(this._self, this._then);
final _AuthResponseDto _self;
final $Res Function(_AuthResponseDto) _then;
/// Create a copy of AuthResponseDto
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? refresh = freezed,Object? access = freezed,Object? otpStatus = freezed,}) {
return _then(_AuthResponseDto(
refresh: freezed == refresh ? _self.refresh : refresh // ignore: cast_nullable_to_non_nullable
as String?,access: freezed == access ? _self.access : access // ignore: cast_nullable_to_non_nullable
as String?,otpStatus: freezed == otpStatus ? _self.otpStatus : otpStatus // ignore: cast_nullable_to_non_nullable
as bool?,
));
}
}
// dart format on

View File

@@ -0,0 +1,21 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'auth_response_dto.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_AuthResponseDto _$AuthResponseDtoFromJson(Map<String, dynamic> json) =>
_AuthResponseDto(
refresh: json['refresh'] as String?,
access: json['access'] as String?,
otpStatus: json['otp_status'] as bool?,
);
Map<String, dynamic> _$AuthResponseDtoToJson(_AuthResponseDto instance) =>
<String, dynamic>{
'refresh': instance.refresh,
'access': instance.access,
'otp_status': instance.otpStatus,
};

View File

@@ -1,35 +1,44 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_model.dart';
part of 'user_local_model.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class UserModelAdapter extends TypeAdapter<UserModel> {
class UserLocalModelAdapter extends TypeAdapter<UserLocalModel> {
@override
final int typeId = 0;
final typeId = 0;
@override
UserModel read(BinaryReader reader) {
UserLocalModel read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return UserModel(
token: fields[0] as String?,
refreshToken: fields[1] as String?,
return UserLocalModel(
username: fields[0] as String?,
password: fields[1] as String?,
token: fields[2] as String?,
refreshToken: fields[3] as String?,
name: fields[4] as String?,
);
}
@override
void write(BinaryWriter writer, UserModel obj) {
void write(BinaryWriter writer, UserLocalModel obj) {
writer
..writeByte(2)
..writeByte(5)
..writeByte(0)
..write(obj.token)
..write(obj.username)
..writeByte(1)
..write(obj.refreshToken);
..write(obj.password)
..writeByte(2)
..write(obj.token)
..writeByte(3)
..write(obj.refreshToken)
..writeByte(4)
..write(obj.name);
}
@override
@@ -38,7 +47,7 @@ class UserModelAdapter extends TypeAdapter<UserModel> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is UserModelAdapter &&
other is UserLocalModelAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}

View File

@@ -0,0 +1,16 @@
import 'package:rasadyar_core/core.dart';
class ModulesLogic extends GetxController {
@override
void onReady() {
super.onReady();
}
@override
void onClose() {
super.onClose();
}
}

View File

@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'logic.dart';
class ModulesPage extends GetView<ModulesLogic> {
const ModulesPage({super.key});
@override
Widget build(BuildContext context) {
final ModulesLogic logic = Get.put(ModulesLogic());
return Container();
}
}

View File

@@ -1,20 +0,0 @@
import 'package:get/get.dart';
import 'package:inspection/presentation/routes/app_pages.dart';
import 'package:rasadyar_app/presentation/pages/auth/auth_with_use_and_pass/logic.dart';
import 'package:rasadyar_app/presentation/pages/auth/auth_with_use_and_pass/view.dart';
import 'package:rasadyar_app/presentation/pages/splash/logic.dart';
import 'package:rasadyar_app/presentation/pages/splash/view.dart';
import 'package:rasadyar_app/presentation/pages/system_design/system_design.dart';
part 'app_paths.dart';
sealed class AppPages {
AppPages._();
static const String initRoutes = AppPaths.splash;
static const String initDesignSystem = AppPaths.systemDesignPage;
static List<GetPage> pages = [
];
}

View File

@@ -1,10 +0,0 @@
part of 'app_pages.dart';
sealed class AppPaths {
AppPaths._();
static const String splash = '/splash';
static const String authWithUserAndPass = '/authWithUserAndPass';
static const String authWithOtp = '/authWithOtp';
static const String systemDesignPage = '/systemDesignPage';
}

View File

@@ -0,0 +1,26 @@
import 'package:auth/src/presentation/pages/auth/logic.dart';
import 'package:auth/src/presentation/pages/auth/view.dart';
import 'package:rasadyar_core/core.dart';
part 'paths.dart';
sealed class AuthPages {
AuthPages._();
static List<GetPage> pages = [
GetPage(
name: AuthPaths.moduleList,
page: () => AuthPage(),
binding: BindingsBuilder(() {
Get.lazyPut(() => AuthLogic());
}),
),
GetPage(
name: AuthPaths.auth,
page: () => AuthPage(),
binding: BindingsBuilder(() {
Get.lazyPut(() => AuthLogic());
}),
),
];
}

View File

@@ -0,0 +1,8 @@
part of 'pages.dart';
sealed class AuthPaths {
AuthPaths._();
static const String moduleList = '/moduleList';
static const String auth = '/Auth';
}

View File

@@ -1,32 +0,0 @@
import 'package:get_it/get_it.dart';
import 'package:hive_ce_flutter/hive_flutter.dart';
import 'package:logger/logger.dart';
final di = GetIt.instance;
void setupInjection() {
// di.registerLazySingleton(() => HiveProvider(), instanceName: 'HiveProvider');
di.registerSingleton<Logger>( Logger());
}
Future<void> setupAllProvider() async {
//await _setupLocalStorage();
await di.allReady();
}
// Future<void> _setupLocalStorage() async {
// final hiveProvider = di.get<HiveProvider>(instanceName: 'HiveProvider');
// await hiveProvider.init();
// Hive.registerAdapter(UserModelAdapter());
//
// await Hive.openBox<UserModel>(HiveBoxNames.user.name);
//
// //user
// di.registerLazySingleton<IUserLocalStorage>(() => UserLocalStorage());
// di.registerLazySingleton<IUserRepository>(
// () => UserRepository(di.get<IUserLocalStorage>()),
// );
//
// //
// }

View File

@@ -0,0 +1,25 @@
import 'package:get_it/get_it.dart';
import 'package:logger/logger.dart';
import 'package:rasadyar_core/infrastructure/local/hive_local_storage.dart';
final diCore = GetIt.instance;
Future<void> setupAllProvider() async {
await _setUpLogger();
await _setupLocalStorage();
await diCore.allReady();
}
Future<void> _setUpLogger() async{
diCore.registerSingleton<Logger>(Logger());
}
Future<void> _setupLocalStorage() async {
diCore.registerSingleton<HiveLocalStorage>(HiveLocalStorage());
}
Future<void> _setupRemote() async {
diCore.registerSingleton<HiveLocalStorage>(HiveLocalStorage());
}