chore : change app archticle

This commit is contained in:
2025-05-12 16:55:55 +03:30
parent 114f8a1ada
commit e11ef1990c
56 changed files with 873 additions and 1247 deletions

View File

@@ -1,7 +0,0 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

View File

@@ -1,3 +0,0 @@
## 1.0.0
- Initial version.

View File

@@ -1,39 +0,0 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/to/develop-packages).
-->
TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.
## Features
TODO: List what your package can do. Maybe include images, gifs, or videos.
## Getting started
TODO: List prerequisites and provide or point to information on how to
start using the package.
## Usage
TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.
```dart
const like = 'sample';
```
## Additional information
TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.

View File

@@ -1,30 +0,0 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options

View File

@@ -1,5 +0,0 @@
import 'package:auth/auth.dart';
void main() {
}

View File

@@ -1,5 +0,0 @@
/// Support for doing something awesome.
///
/// More dartdocs go here.
library;

View File

@@ -1,18 +0,0 @@
// 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

@@ -1,23 +0,0 @@
import 'package:auth/src/domain/entity/auth_response_entity.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'auth_response_dto.freezed.dart';
part 'auth_response_dto.g.dart';
@freezed
abstract class AuthResponseDto with _$AuthResponseDto {
const factory AuthResponseDto({
String? refresh,
String? access,
@JsonKey(name: 'otp_status') bool? otpStatus,
}) = _AuthResponseDto;
factory AuthResponseDto.fromJson(Map<String, dynamic> json) =>
_$AuthResponseDtoFromJson(json);
AuthResponseEntity toEntity() => AuthResponseEntity(
access: access,
otpStatus: otpStatus,
refresh: refresh,
);
}

View File

@@ -1,160 +0,0 @@
// 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

@@ -1,21 +0,0 @@
// 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,21 +0,0 @@
import 'package:rasadyar_core/core.dart';
part 'login_request_model.freezed.dart';
part 'login_request_model.g.dart';
@freezed
abstract class LoginRequestModel with _$LoginRequestModel {
const factory LoginRequestModel({
required String username,
required String password,
required String captchaCode,
required String captchaKey,
}) = _LoginRequestModel;
factory LoginRequestModel.fromJson(Map<String, dynamic> json) =>
_$LoginRequestModelFromJson(json);
const LoginRequestModel._();
String get formattedCaptchaKey => 'rest_captcha_$captchaKey.0';
}

View File

@@ -1,157 +0,0 @@
// 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 'login_request_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LoginRequestModel {
String get username; String get password; String get captchaCode; String get captchaKey;
/// Create a copy of LoginRequestModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LoginRequestModelCopyWith<LoginRequestModel> get copyWith => _$LoginRequestModelCopyWithImpl<LoginRequestModel>(this as LoginRequestModel, _$identity);
/// Serializes this LoginRequestModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginRequestModel&&(identical(other.username, username) || other.username == username)&&(identical(other.password, password) || other.password == password)&&(identical(other.captchaCode, captchaCode) || other.captchaCode == captchaCode)&&(identical(other.captchaKey, captchaKey) || other.captchaKey == captchaKey));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,username,password,captchaCode,captchaKey);
@override
String toString() {
return 'LoginRequestModel(username: $username, password: $password, captchaCode: $captchaCode, captchaKey: $captchaKey)';
}
}
/// @nodoc
abstract mixin class $LoginRequestModelCopyWith<$Res> {
factory $LoginRequestModelCopyWith(LoginRequestModel value, $Res Function(LoginRequestModel) _then) = _$LoginRequestModelCopyWithImpl;
@useResult
$Res call({
String username, String password, String captchaCode, String captchaKey
});
}
/// @nodoc
class _$LoginRequestModelCopyWithImpl<$Res>
implements $LoginRequestModelCopyWith<$Res> {
_$LoginRequestModelCopyWithImpl(this._self, this._then);
final LoginRequestModel _self;
final $Res Function(LoginRequestModel) _then;
/// Create a copy of LoginRequestModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? username = null,Object? password = null,Object? captchaCode = null,Object? captchaKey = null,}) {
return _then(_self.copyWith(
username: null == username ? _self.username : username // ignore: cast_nullable_to_non_nullable
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
as String,captchaCode: null == captchaCode ? _self.captchaCode : captchaCode // ignore: cast_nullable_to_non_nullable
as String,captchaKey: null == captchaKey ? _self.captchaKey : captchaKey // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _LoginRequestModel extends LoginRequestModel {
const _LoginRequestModel({required this.username, required this.password, required this.captchaCode, required this.captchaKey}): super._();
factory _LoginRequestModel.fromJson(Map<String, dynamic> json) => _$LoginRequestModelFromJson(json);
@override final String username;
@override final String password;
@override final String captchaCode;
@override final String captchaKey;
/// Create a copy of LoginRequestModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoginRequestModelCopyWith<_LoginRequestModel> get copyWith => __$LoginRequestModelCopyWithImpl<_LoginRequestModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$LoginRequestModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginRequestModel&&(identical(other.username, username) || other.username == username)&&(identical(other.password, password) || other.password == password)&&(identical(other.captchaCode, captchaCode) || other.captchaCode == captchaCode)&&(identical(other.captchaKey, captchaKey) || other.captchaKey == captchaKey));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,username,password,captchaCode,captchaKey);
@override
String toString() {
return 'LoginRequestModel(username: $username, password: $password, captchaCode: $captchaCode, captchaKey: $captchaKey)';
}
}
/// @nodoc
abstract mixin class _$LoginRequestModelCopyWith<$Res> implements $LoginRequestModelCopyWith<$Res> {
factory _$LoginRequestModelCopyWith(_LoginRequestModel value, $Res Function(_LoginRequestModel) _then) = __$LoginRequestModelCopyWithImpl;
@override @useResult
$Res call({
String username, String password, String captchaCode, String captchaKey
});
}
/// @nodoc
class __$LoginRequestModelCopyWithImpl<$Res>
implements _$LoginRequestModelCopyWith<$Res> {
__$LoginRequestModelCopyWithImpl(this._self, this._then);
final _LoginRequestModel _self;
final $Res Function(_LoginRequestModel) _then;
/// Create a copy of LoginRequestModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? username = null,Object? password = null,Object? captchaCode = null,Object? captchaKey = null,}) {
return _then(_LoginRequestModel(
username: null == username ? _self.username : username // ignore: cast_nullable_to_non_nullable
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
as String,captchaCode: null == captchaCode ? _self.captchaCode : captchaCode // ignore: cast_nullable_to_non_nullable
as String,captchaKey: null == captchaKey ? _self.captchaKey : captchaKey // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View File

@@ -1,23 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'login_request_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_LoginRequestModel _$LoginRequestModelFromJson(Map<String, dynamic> json) =>
_LoginRequestModel(
username: json['username'] as String,
password: json['password'] as String,
captchaCode: json['captchaCode'] as String,
captchaKey: json['captchaKey'] as String,
);
Map<String, dynamic> _$LoginRequestModelToJson(_LoginRequestModel instance) =>
<String, dynamic>{
'username': instance.username,
'password': instance.password,
'captchaCode': instance.captchaCode,
'captchaKey': instance.captchaKey,
};

View File

@@ -1,41 +0,0 @@
import 'package:rasadyar_core/core.dart';
part 'user_local_model.g.dart';
@HiveType(typeId: 0)
class UserLocalModel extends HiveObject {
@HiveField(0)
String? username;
@HiveField(1)
String? password;
@HiveField(2)
String? token;
@HiveField(3)
String? refreshToken;
@HiveField(4)
String? name;
UserLocalModel({
this.username,
this.password,
this.token,
this.refreshToken,
this.name,
});
UserLocalModel copyWith({
String? username,
String? password,
String? token,
String? refreshToken,
String? name,
}) {
return UserLocalModel(
username: username ?? this.username,
password: password ?? this.password,
token: token ?? this.token,
refreshToken: refreshToken ?? this.refreshToken,
name: name ?? this.name,
);
}
}

View File

@@ -1,53 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_local_model.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class UserLocalModelAdapter extends TypeAdapter<UserLocalModel> {
@override
final typeId = 0;
@override
UserLocalModel read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
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, UserLocalModel obj) {
writer
..writeByte(5)
..writeByte(0)
..write(obj.username)
..writeByte(1)
..write(obj.password)
..writeByte(2)
..write(obj.token)
..writeByte(3)
..write(obj.refreshToken)
..writeByte(4)
..write(obj.name);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is UserLocalModelAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}

View File

@@ -1,12 +0,0 @@
class AuthResponseEntity {
final String? access;
final String? refresh;
final bool? otpStatus;
AuthResponseEntity({this.access, this.refresh, this.otpStatus});
@override
String toString() {
return 'AuthResponseEntity{accessToken: $access, refreshToken: $refresh, expiresIn: $otpStatus}';
}
}

View File

@@ -1,7 +0,0 @@
import 'package:auth/src/domain/entity/auth_response_entity.dart';
abstract class AuthRepository {
Future<AuthResponseEntity> signIn({
required Map<String, dynamic> authRequest,
});
}

View File

@@ -1,69 +0,0 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
enum AuthType { useAndPass, otp }
enum AuthStatus { init }
enum OtpStatus { init, sent, verified, reSend }
class AuthLogic extends GetxController {
Rx<GlobalKey<FormState>> formKey = GlobalKey<FormState>().obs;
Rx<GlobalKey<FormState>> formKeyOtp = GlobalKey<FormState>().obs;
Rx<GlobalKey<FormState>> formKeySentOtp = GlobalKey<FormState>().obs;
Rx<TextEditingController> phoneNumberController = TextEditingController().obs;
Rx<TextEditingController> passwordController = TextEditingController().obs;
Rx<TextEditingController> phoneOtpNumberController =
TextEditingController().obs;
Rx<TextEditingController> otpCodeController = TextEditingController().obs;
CaptchaController captchaController = CaptchaController();
CaptchaController captchaOtpController = CaptchaController();
RxnString phoneNumber = RxnString(null);
RxnString password = RxnString(null);
RxBool isOnError = false.obs;
RxBool hidePassword = true.obs;
Rx<AuthType> authType = AuthType.useAndPass.obs;
Rx<AuthStatus> authStatus = AuthStatus.init.obs;
Rx<OtpStatus> otpStatus = OtpStatus.init.obs;
RxInt secondsRemaining = 120.obs;
Timer? _timer;
void startTimer() {
_timer?.cancel();
secondsRemaining.value = 120;
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (secondsRemaining.value > 0) {
secondsRemaining.value--;
} else {
timer.cancel();
}
});
}
void stopTimer() {
_timer?.cancel();
}
String get timeFormatted {
final minutes = secondsRemaining.value ~/ 60;
final seconds = secondsRemaining.value % 60;
return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}';
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
}
@override
void onClose() {
_timer?.cancel();
super.onClose();
}
}

View File

@@ -1,524 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class AuthPage extends GetView<AuthLogic> {
const AuthPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
SizedBox(height: 80),
logoWidget(),
ObxValue((types) {
switch (types.value) {
case AuthType.otp:
return otpForm();
case AuthType.useAndPass:
return useAndPassFrom();
}
}, controller.authType),
SizedBox(height: 50),
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'مطالعه بیانیه ',
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDark,
),
),
TextSpan(
recognizer: TapGestureRecognizer()..onTap = () {},
text: 'حریم خصوصی',
style: AppFonts.yekan14.copyWith(
color: AppColor.blueNormal,
),
),
],
),
),
SizedBox(height: 18),
ObxValue((types) {
return RichText(
text: TextSpan(
children: [
TextSpan(
recognizer:
TapGestureRecognizer()
..onTap = () {
if (controller.authType.value == AuthType.otp) {
controller.authType.value = AuthType.useAndPass;
if (controller.otpStatus.value !=
OtpStatus.init) {
controller.otpStatus.value = OtpStatus.init;
}
} else {
controller.authType.value = AuthType.otp;
}
},
text:
controller.authType.value == AuthType.otp
? 'ورود با رمز ثابت'
: 'ورود با رمز یکبار مصرف',
style: AppFonts.yekan14.copyWith(
color: AppColor.blueNormal,
),
),
],
),
);
}, controller.authType),
],
),
),
);
}
Widget useAndPassFrom() {
return ObxValue((data) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 50),
child: Form(
key: data.value,
child: Column(
children: [
ObxValue((phoneController) {
return TextFormField(
controller: controller.phoneNumberController.value,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
gapPadding: 11,
),
labelText: 'شماره موبایل',
labelStyle: AppFonts.yekan13,
errorStyle: AppFonts.yekan13.copyWith(
color: AppColor.redNormal,
),
prefixIconConstraints: BoxConstraints(
maxHeight: 40,
minHeight: 40,
maxWidth: 40,
minWidth: 40,
),
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
child: vecWidget(Assets.vecCallSvg),
),
suffix:
phoneController.value.text.trim().isNotEmpty
? clearButton(() {
phoneController.value.clear();
phoneController.refresh();
})
: null,
counterText: '',
),
keyboardType: TextInputType.numberWithOptions(
decimal: false,
signed: false,
),
maxLines: 1,
maxLength: 11,
onChanged: (value) {
if (controller.isOnError.value) {
controller.isOnError.value = !controller.isOnError.value;
data.value.currentState?.reset();
data.refresh();
phoneController.value.text = value;
}
phoneController.refresh();
},
textInputAction: TextInputAction.next,
validator: (value) {
if (value == null) {
return '⚠️ شماره موبایل را وارد کنید';
} else if (value.length < 11) {
return '⚠️ شماره موبایل باید 11 رقم باشد';
}
return null;
},
style: AppFonts.yekan13,
);
}, controller.phoneNumberController),
SizedBox(height: 26),
ObxValue((passwordController) {
return TextFormField(
controller: passwordController.value,
obscureText: controller.hidePassword.value,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
gapPadding: 11,
),
labelText: 'رمز عبور',
labelStyle: AppFonts.yekan13,
errorStyle: AppFonts.yekan13.copyWith(
color: AppColor.redNormal,
),
prefixIconConstraints: BoxConstraints(
maxHeight: 34,
minHeight: 34,
maxWidth: 34,
minWidth: 34,
),
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 8, 8),
child: vecWidget(Assets.vecKeySvg),
),
suffix:
passwordController.value.text.trim().isNotEmpty
? GestureDetector(
onTap: () {
controller.hidePassword.value =
!controller.hidePassword.value;
},
child: Icon(
controller.hidePassword.value
? CupertinoIcons.eye
: CupertinoIcons.eye_slash,
),
)
: null,
counterText: '',
),
textInputAction: TextInputAction.done,
keyboardType: TextInputType.visiblePassword,
maxLines: 1,
onChanged: (value) {
if (controller.isOnError.value) {
controller.isOnError.value = !controller.isOnError.value;
data.value.currentState?.reset();
passwordController.value.text = value;
}
passwordController.refresh();
},
validator: (value) {
if (value == null || value.isEmpty) {
return '⚠️ رمز عبور را وارد کنید'; // "Please enter the password"
}
return null;
},
style: AppFonts.yekan13,
);
}, controller.passwordController),
SizedBox(height: 26),
CaptchaWidget(controller: controller.captchaController),
SizedBox(height: 23),
RElevated(
text: 'ورود',
onPressed: () async {
Jalali? picked = await showPersianDatePicker(
context: Get.context!,
initialDate: Jalali.now(),
firstDate: Jalali(1385, 8),
lastDate: Jalali(1450, 9),
initialEntryMode: PersianDatePickerEntryMode.calendarOnly,
initialDatePickerMode: PersianDatePickerMode.year,
);
if (data.value.currentState?.validate() == true &&
controller.captchaController.validate()) {}
},
width: Get.width,
height: 48,
),
],
),
),
);
}, controller.formKey);
}
Widget otpForm() {
return ObxValue((status) {
switch (status.value) {
case OtpStatus.init:
return sendCodeForm();
case OtpStatus.sent:
case OtpStatus.verified:
case OtpStatus.reSend:
return confirmCodeForm();
}
}, controller.otpStatus);
}
Widget sendCodeForm() {
return ObxValue((data) {
return Form(
key: data.value,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 50),
child: Column(
children: [
SizedBox(height: 26),
ObxValue((phoneController) {
return TextFormField(
controller: phoneController.value,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
gapPadding: 11,
),
labelText: 'شماره موبایل',
labelStyle: AppFonts.yekan13,
errorStyle: AppFonts.yekan13.copyWith(
color: AppColor.redNormal,
),
prefixIconConstraints: BoxConstraints(
maxHeight: 40,
minHeight: 40,
maxWidth: 40,
minWidth: 40,
),
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
child: vecWidget(Assets.vecCallSvg),
),
suffix:
phoneController.value.text.trim().isNotEmpty
? clearButton(() {
phoneController.value.clear();
phoneController.refresh();
})
: null,
counterText: '',
),
keyboardType: TextInputType.numberWithOptions(
decimal: false,
signed: false,
),
maxLines: 1,
maxLength: 11,
onChanged: (value) {
if (controller.isOnError.value) {
controller.isOnError.value = !controller.isOnError.value;
data.value.currentState?.reset();
data.refresh();
phoneController.value.text = value;
}
phoneController.refresh();
},
textInputAction: TextInputAction.next,
validator: (value) {
if (value == null) {
return '⚠️ شماره موبایل را وارد کنید';
} else if (value.length < 11) {
return '⚠️ شماره موبایل باید 11 رقم باشد';
}
return null;
},
style: AppFonts.yekan13,
);
}, controller.phoneOtpNumberController),
SizedBox(height: 26),
CaptchaWidget(controller: controller.captchaOtpController),
SizedBox(height: 23),
RElevated(
text: 'ارسال رمز یکبار مصرف',
onPressed: () {
if (data.value.currentState?.validate() == true &&
controller.captchaOtpController.validate()) {
controller.otpStatus.value = OtpStatus.sent;
controller.startTimer();
}
},
width: Get.width,
height: 48,
),
],
),
),
);
}, controller.formKeyOtp);
}
Widget confirmCodeForm() {
return ObxValue((data) {
return Form(
key: data.value,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 50),
child: Column(
children: [
SizedBox(height: 26),
ObxValue((passwordController) {
return TextFormField(
controller: passwordController.value,
obscureText: controller.hidePassword.value,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
gapPadding: 11,
),
labelText: 'رمز عبور',
labelStyle: AppFonts.yekan13,
errorStyle: AppFonts.yekan13.copyWith(
color: AppColor.redNormal,
),
prefixIconConstraints: BoxConstraints(
maxHeight: 34,
minHeight: 34,
maxWidth: 34,
minWidth: 34,
),
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 8, 8),
child: vecWidget(Assets.vecKeySvg),
),
suffix:
passwordController.value.text.trim().isNotEmpty
? GestureDetector(
onTap: () {
controller.hidePassword.value =
!controller.hidePassword.value;
},
child: Icon(
controller.hidePassword.value
? CupertinoIcons.eye
: CupertinoIcons.eye_slash,
),
)
: null,
counterText: '',
),
textInputAction: TextInputAction.done,
keyboardType: TextInputType.visiblePassword,
maxLines: 1,
onChanged: (value) {
if (controller.isOnError.value) {
controller.isOnError.value = !controller.isOnError.value;
data.value.currentState?.reset();
passwordController.value.text = value;
}
passwordController.refresh();
},
validator: (value) {
if (value == null || value.isEmpty) {
return '⚠️ رمز عبور را وارد کنید'; // "Please enter the password"
}
return null;
},
style: AppFonts.yekan13,
);
}, controller.passwordController),
SizedBox(height: 23),
ObxValue((timer) {
if (timer.value == 0) {
return TextButton(
onPressed: () {
controller.otpStatus.value = OtpStatus.reSend;
controller.startTimer();
},
child: Text(
style: AppFonts.yekan13.copyWith(
color: AppColor.blueNormal,
),
'ارسال مجدد کد یکبار مصرف',
),
);
} else {
return Text(
'اعتبار رمز ارسال شده ${controller.timeFormatted}',
style: AppFonts.yekan13,
);
}
}, controller.secondsRemaining),
RichText(
text: TextSpan(
children: [
TextSpan(
text: ' کد ارسال شده به شماره ',
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDark,
),
),
TextSpan(
text: controller.phoneOtpNumberController.value.text,
style: AppFonts.yekan13Bold.copyWith(
color: AppColor.darkGreyDark,
),
),
TextSpan(
recognizer:
TapGestureRecognizer()
..onTap = () {
controller.otpStatus.value = OtpStatus.init;
controller.captchaOtpController.clear();
},
text: ' ویرایش',
style: AppFonts.yekan14.copyWith(
color: AppColor.blueNormal,
),
),
],
),
),
SizedBox(height: 23),
RElevated(
text: 'ورود',
onPressed: () {
if (controller.formKeyOtp.value.currentState?.validate() ==
true &&
controller.captchaOtpController.validate()) {}
},
width: Get.width,
height: 48,
),
],
),
),
);
}, controller.formKeySentOtp);
}
Widget logoWidget() {
return Column(
children: [
Row(),
Image.asset(Assets.imagesInnerSplash, width: 120, height: 120),
Text(
'سامانه رصدیار',
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyNormal),
),
],
);
}
Widget clearButton(VoidCallback onTap) {
return GestureDetector(
onTap: onTap,
child: Icon(CupertinoIcons.multiply_circle, size: 24),
);
}
}

View File

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

View File

@@ -1,15 +0,0 @@
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,26 +0,0 @@
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

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

View File

@@ -1,33 +0,0 @@
name: auth
description: A starting point for Dart libraries or applications.
publish_to: 'none'
version: 1.0.0
# repository: https://github.com/my_org/my_repo
environment:
sdk: ^3.7.2
dependencies:
# path: ^1.8.0
rasadyar_core:
path: ../core
dev_dependencies:
lints: ^5.0.0
test: ^1.24.0
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
##code generation
build_runner: ^2.4.15
hive_ce_generator: ^1.9.1
freezed: ^3.0.3
json_serializable: ^6.9.4
##test
mocktail: ^1.0.4
get_test: ^4.0.1
flutter:
uses-material-design: true

View File

@@ -1,8 +0,0 @@
import 'package:auth/auth.dart';
import 'package:test/test.dart';
void main() {
group('A group of tests', () {
});
}