api integration
This commit is contained in:
@@ -9,7 +9,7 @@ class NetworkApiService {
|
||||
final Dio _dio = Dio(BaseOptions(
|
||||
validateStatus: (status) {
|
||||
return status != null &&
|
||||
status < 500; // Allow any status code less than 500
|
||||
status <= 500; // Allow any status code less than 500
|
||||
},
|
||||
));
|
||||
|
||||
@@ -25,6 +25,14 @@ class NetworkApiService {
|
||||
if (response.statusCode == 201 || response.statusCode == 200) {
|
||||
return ResponseData<dynamic>("success", ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 500) {
|
||||
return ResponseData<dynamic>(
|
||||
"Internal server error", ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 400) {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else {
|
||||
try {
|
||||
return ResponseData<dynamic>(
|
||||
@@ -80,6 +88,10 @@ class NetworkApiService {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['error']['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 500) {
|
||||
return ResponseData<dynamic>(
|
||||
"Internal server error", ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else {
|
||||
try {
|
||||
return ResponseData<dynamic>(
|
||||
|
||||
@@ -6,13 +6,13 @@ import 'package:gap/gap.dart';
|
||||
import 'package:tanami_app/core/styles/app_color.dart';
|
||||
import 'package:tanami_app/core/styles/app_text.dart';
|
||||
import 'package:tanami_app/core/utils/secure/secure_storage_service.dart';
|
||||
import 'package:tanami_app/features/biometric/presentation/bloc/biometric_bloc.dart';
|
||||
import 'package:tanami_app/features/biometric/bloc/biometric_bloc.dart';
|
||||
|
||||
import '../../Globalconst.dart';
|
||||
import '../../core/routes/route_name.dart';
|
||||
import '../../core/routes/routes.dart';
|
||||
import '../../core/utils/language/localizations_delegate.dart';
|
||||
import '../../features/biometric/presentation/bloc/biometric_state.dart';
|
||||
import '../../features/biometric/bloc/biometric_state.dart';
|
||||
import 'text_widget.dart';
|
||||
|
||||
deviceLockedDialog(
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:tanami_app/shared/components/text_widget.dart';
|
||||
import '../../core/routes/route_name.dart';
|
||||
import '../../core/routes/routes.dart';
|
||||
import '../../core/utils/language/localizations_delegate.dart';
|
||||
import '../../features/forgotPassword/presentation/bloc/restore_password_phone_verification_bloc.dart';
|
||||
import '../../features/forgotPassword/bloc/restore_password_phone_verification_bloc.dart';
|
||||
import '../../features/register/presentation/bloc/register_bloc.dart';
|
||||
import 'text_from_field_widget.dart';
|
||||
|
||||
@@ -60,11 +60,14 @@ class FormLabelTextField extends StatelessWidget {
|
||||
txtAlign: type == "description" ? TextAlign.start : TextAlign.center,
|
||||
),
|
||||
const Gap(10),
|
||||
(type == "password" || type == "repeat-password")
|
||||
(type == "password" ||
|
||||
type == "repeat-password" ||
|
||||
type == "login-password")
|
||||
? PasswordField(
|
||||
controller: textEditingController,
|
||||
hintText: hintText,
|
||||
originalPasswordController: originalPasswordController,
|
||||
type: type,
|
||||
)
|
||||
: textFormField(
|
||||
onInput: onChangeFun,
|
||||
@@ -139,25 +142,29 @@ class FormLabelTextField extends StatelessWidget {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
inputFormatters: (type == "phone number")
|
||||
? registerBloc.isdcode.isNotEmpty
|
||||
? [
|
||||
LengthLimitingTextInputFormatter(
|
||||
countryPhoneLengths[registerBloc.isdcode]),
|
||||
]
|
||||
: restorePasswordBloc.isdcode.isNotEmpty
|
||||
inputFormatters: (type == "first name")
|
||||
? [
|
||||
LengthLimitingTextInputFormatter(35),
|
||||
]
|
||||
: (type == "phone number")
|
||||
? registerBloc.isdcode.isNotEmpty
|
||||
? [
|
||||
LengthLimitingTextInputFormatter(
|
||||
countryPhoneLengths[
|
||||
restorePasswordBloc.isdcode]),
|
||||
countryPhoneLengths[registerBloc.isdcode]),
|
||||
]
|
||||
: [
|
||||
LengthLimitingTextInputFormatter(
|
||||
countryPhoneLengths[loginBloc.isdcode]),
|
||||
]
|
||||
: [
|
||||
LengthLimitingTextInputFormatter(350),
|
||||
],
|
||||
: restorePasswordBloc.isdcode.isNotEmpty
|
||||
? [
|
||||
LengthLimitingTextInputFormatter(
|
||||
countryPhoneLengths[
|
||||
restorePasswordBloc.isdcode]),
|
||||
]
|
||||
: [
|
||||
LengthLimitingTextInputFormatter(
|
||||
countryPhoneLengths[loginBloc.isdcode]),
|
||||
]
|
||||
: [
|
||||
LengthLimitingTextInputFormatter(350),
|
||||
],
|
||||
maxlines: type == "description" ? 6 : 1,
|
||||
texttype: type == "phone number"
|
||||
? TextInputType.phone
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:tanami_app/core/utils/secure/secure_storage_service.dart';
|
||||
import 'package:tanami_app/features/welcome/presentation/pages/weclome_screen.dart';
|
||||
import 'package:tanami_app/shared/components/text_widget.dart';
|
||||
|
||||
import '../../Globalconst.dart';
|
||||
import 'bloc/language/lng_bloc.dart';
|
||||
import 'bloc/language/lng_event.dart';
|
||||
|
||||
@@ -49,6 +50,7 @@ void showLanguageBottomSheet(BuildContext context) {
|
||||
await secureStorageService.write(
|
||||
'languageSelected', "en");
|
||||
goRouter.pop();
|
||||
Globalconst.languageSelected = "en";
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => const WelcomeScreen()));
|
||||
},
|
||||
@@ -67,7 +69,7 @@ void showLanguageBottomSheet(BuildContext context) {
|
||||
context
|
||||
.read<LocalizationBloc>()
|
||||
.add(const ChangeLanguage(Locale('ar')));
|
||||
|
||||
Globalconst.languageSelected = "ar";
|
||||
await secureStorageService.write(
|
||||
'languageSelected', "ar");
|
||||
goRouter.pop();
|
||||
|
||||
@@ -17,11 +17,13 @@ class PasswordField extends StatelessWidget {
|
||||
final TextEditingController controller;
|
||||
final String hintText;
|
||||
final TextEditingController? originalPasswordController;
|
||||
final String? type;
|
||||
const PasswordField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hintText,
|
||||
this.originalPasswordController,
|
||||
this.type,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -31,29 +33,36 @@ class PasswordField extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return TextFormField(
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return localizations.translate(AppText.enterPassword);
|
||||
}
|
||||
if (type == "login-password") {
|
||||
if (value == null || value.isEmpty) {
|
||||
return localizations.translate(AppText.enterPassword);
|
||||
}
|
||||
} else {
|
||||
if (value == null || value.isEmpty) {
|
||||
return localizations.translate(AppText.enterPassword);
|
||||
}
|
||||
|
||||
// Password validation rules
|
||||
if (value.length < 8 || value.length > 20) {
|
||||
return localizations.translate(AppText.passwordLength);
|
||||
}
|
||||
if (!RegExp(r'[a-z]').hasMatch(value)) {
|
||||
return localizations.translate(AppText.passwordLowerCase);
|
||||
}
|
||||
if (!RegExp(r'[A-Z]').hasMatch(value)) {
|
||||
return localizations.translate(AppText.passwordUpperCase);
|
||||
}
|
||||
if (!RegExp(r'\d').hasMatch(value)) {
|
||||
return localizations.translate(AppText.passwordDigit);
|
||||
}
|
||||
if (!RegExp(r'[!@#$%&*()\-+=^]').hasMatch(value)) {
|
||||
return localizations.translate(AppText.passwordSpecialCharacter);
|
||||
}
|
||||
if (originalPasswordController != null &&
|
||||
value != originalPasswordController!.text) {
|
||||
return localizations.translate("Passwords do not match");
|
||||
// Password validation rules
|
||||
if (value.length < 8 || value.length > 20) {
|
||||
return localizations.translate(AppText.passwordLength);
|
||||
}
|
||||
if (!RegExp(r'[a-z]').hasMatch(value)) {
|
||||
return localizations.translate(AppText.passwordLowerCase);
|
||||
}
|
||||
if (!RegExp(r'[A-Z]').hasMatch(value)) {
|
||||
return localizations.translate(AppText.passwordUpperCase);
|
||||
}
|
||||
if (!RegExp(r'\d').hasMatch(value)) {
|
||||
return localizations.translate(AppText.passwordDigit);
|
||||
}
|
||||
if (!RegExp(r'[!@#$%&*()\-+=^]').hasMatch(value)) {
|
||||
return localizations
|
||||
.translate(AppText.passwordSpecialCharacter);
|
||||
}
|
||||
if (originalPasswordController != null &&
|
||||
value != originalPasswordController!.text) {
|
||||
return localizations.translate("Passwords do not match");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user