chnages has been made and net salary is being displayed

This commit is contained in:
Daniah Ayad Al-sultani
2026-02-11 14:31:03 +03:00
parent 1002937045
commit a7930d19e5
23 changed files with 691 additions and 141 deletions

View File

@@ -1,4 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../core/di/injection_container.dart';
import '../../domain/models/change_password_request.dart';
import '../blocs/change_password/change_password_bloc.dart';
import '../blocs/change_password/change_password_event.dart';
import '../blocs/change_password/change_password_state.dart';
import 'onboarding_button.dart';
class ChangePasswordModal extends StatefulWidget {
@@ -10,7 +16,17 @@ class ChangePasswordModal extends StatefulWidget {
class _ChangePasswordModalState extends State<ChangePasswordModal> {
bool _oldObscure = true;
// bool _newObscure = true;
bool _newObscure = true;
final TextEditingController _oldPasswordController = TextEditingController();
final TextEditingController _newPasswordController = TextEditingController();
@override
void dispose() {
_oldPasswordController.dispose();
_newPasswordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
@@ -73,10 +89,11 @@ class _ChangePasswordModalState extends State<ChangePasswordModal> {
const SizedBox(height: 8),
_buildField(
controller: _oldPasswordController,
hint: "أدخل كلمة المرور",
obscure: _oldObscure,
fontSize: fieldFontSize,
hasEye: true, // ✅ eye here
hasEye: true,
onEyeTap:
() => setState(() => _oldObscure = !_oldObscure),
),
@@ -98,21 +115,75 @@ class _ChangePasswordModalState extends State<ChangePasswordModal> {
const SizedBox(height: 8),
_buildField(
controller: _newPasswordController,
hint: "كلمة المرور",
obscure: false,
obscure: _newObscure,
fontSize: fieldFontSize,
hasEye: false,
onEyeTap: () {}, // unused
hasEye: true,
onEyeTap:
() => setState(() => _newObscure = !_newObscure),
),
SizedBox(height: buttonSpacing),
Center(
child: OnboardingButton(
text: "حفظ التغيير",
backgroundColor: const Color(0xEE23574A),
onPressed: () {
Navigator.pop(context);
BlocProvider(
create: (context) => sl<ChangePasswordBloc>(),
child: BlocConsumer<
ChangePasswordBloc,
ChangePasswordState
>(
listener: (context, state) {
if (state is ChangePasswordSuccess) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(state.message),
backgroundColor: Colors.green,
),
);
Navigator.pop(context);
} else if (state is ChangePasswordError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(state.message),
backgroundColor: Colors.red,
),
);
}
},
builder: (context, state) {
if (state is ChangePasswordLoading) {
return const Center(
child: CircularProgressIndicator(),
);
}
return Center(
child: OnboardingButton(
text: "حفظ التغيير",
backgroundColor: const Color(0xEE23574A),
onPressed: () {
if (_oldPasswordController.text.isEmpty ||
_newPasswordController.text.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("يرجى ملء جميع الحقول"),
backgroundColor: Colors.orange,
),
);
return;
}
context.read<ChangePasswordBloc>().add(
ChangePasswordSubmitted(
ChangePasswordRequest(
oldPassword: _oldPasswordController.text,
newPassword: _newPasswordController.text,
),
),
);
},
),
);
},
),
),
@@ -127,6 +198,7 @@ class _ChangePasswordModalState extends State<ChangePasswordModal> {
}
Widget _buildField({
required TextEditingController controller,
required String hint,
required bool obscure,
required double fontSize,
@@ -142,6 +214,7 @@ class _ChangePasswordModalState extends State<ChangePasswordModal> {
],
),
child: TextField(
controller: controller,
obscureText: obscure,
textAlign: TextAlign.right,
style: TextStyle(fontSize: fontSize),