bug was fixed in the holiday screen
This commit is contained in:
@@ -19,8 +19,8 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
int activeTab = 0; // 0 = السلف | 1 = الأجازات
|
int activeTab = 0; // 0 = السلف | 1 = الأجازات
|
||||||
|
|
||||||
final RequestService _requestService = RequestService();
|
final RequestService _requestService = RequestService();
|
||||||
late List<LeaveRequest> _leaveRequests;
|
List<LeaveRequest> _leaveRequests = [];
|
||||||
late List<AdvanceRequest> _advanceRequests;
|
List<AdvanceRequest> _advanceRequests = [];
|
||||||
|
|
||||||
/// ⭐ Telegram-style FAB animation
|
/// ⭐ Telegram-style FAB animation
|
||||||
final ScrollController _scrollController = ScrollController();
|
final ScrollController _scrollController = ScrollController();
|
||||||
@@ -82,7 +82,8 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: active ? activeColor : const Color(0xFFD6D6D6),
|
color: active ? activeColor : const Color(0xFFD6D6D6),
|
||||||
boxShadow: active
|
boxShadow:
|
||||||
|
active
|
||||||
? [
|
? [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: glowColor.withOpacity(0.6),
|
color: glowColor.withOpacity(0.6),
|
||||||
@@ -92,7 +93,8 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
),
|
),
|
||||||
child: active && svgPath != null
|
child:
|
||||||
|
active && svgPath != null
|
||||||
? Center(
|
? Center(
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
svgPath,
|
svgPath,
|
||||||
@@ -134,7 +136,8 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: activeTab == 1
|
color:
|
||||||
|
activeTab == 1
|
||||||
? const Color(0xFF8EFDC2)
|
? const Color(0xFF8EFDC2)
|
||||||
: const Color(0x9EFFFFFF),
|
: const Color(0x9EFFFFFF),
|
||||||
),
|
),
|
||||||
@@ -162,7 +165,8 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: activeTab == 0
|
color:
|
||||||
|
activeTab == 0
|
||||||
? const Color(0xFF8EFDC2)
|
? const Color(0xFF8EFDC2)
|
||||||
: const Color(0x9EFFFFFF),
|
: const Color(0x9EFFFFFF),
|
||||||
),
|
),
|
||||||
@@ -187,7 +191,8 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: activeTab == 1
|
child:
|
||||||
|
activeTab == 1
|
||||||
? _buildLeaveRequestsTab()
|
? _buildLeaveRequestsTab()
|
||||||
: _buildAdvanceRequestsTab(),
|
: _buildAdvanceRequestsTab(),
|
||||||
),
|
),
|
||||||
@@ -218,8 +223,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
await Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => const RequestAdvanceScreen(),
|
||||||
const RequestAdvanceScreen(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -236,8 +240,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
await Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => const RequestLeaveScreen(),
|
||||||
const RequestLeaveScreen(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -312,8 +315,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width * 0.8,
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
margin: const EdgeInsets.only(bottom: 16),
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: bgColor,
|
color: bgColor,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -328,8 +330,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
buildStatusCircle(
|
buildStatusCircle(
|
||||||
active: isWaiting,
|
active: isWaiting,
|
||||||
label: "قيد الانتظار",
|
label: "قيد الانتظار",
|
||||||
svgPath:
|
svgPath: isWaiting ? "assets/images/waiting.svg" : null,
|
||||||
isWaiting ? "assets/images/waiting.svg" : null,
|
|
||||||
activeColor: const Color(0xFFF9C8A01B),
|
activeColor: const Color(0xFFF9C8A01B),
|
||||||
glowColor: const Color(0xB4FFDC69),
|
glowColor: const Color(0xB4FFDC69),
|
||||||
),
|
),
|
||||||
@@ -337,8 +338,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
buildStatusCircle(
|
buildStatusCircle(
|
||||||
active: isApproved,
|
active: isApproved,
|
||||||
label: "موافقة",
|
label: "موافقة",
|
||||||
svgPath:
|
svgPath: isApproved ? "assets/images/yes.svg" : null,
|
||||||
isApproved ? "assets/images/yes.svg" : null,
|
|
||||||
activeColor: const Color(0xFF0A8A60),
|
activeColor: const Color(0xFF0A8A60),
|
||||||
glowColor: const Color(0xFF00D7A3),
|
glowColor: const Color(0xFF00D7A3),
|
||||||
),
|
),
|
||||||
@@ -346,8 +346,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
buildStatusCircle(
|
buildStatusCircle(
|
||||||
active: isDenied,
|
active: isDenied,
|
||||||
label: "تم الرفض",
|
label: "تم الرفض",
|
||||||
svgPath:
|
svgPath: isDenied ? "assets/images/no.svg" : null,
|
||||||
isDenied ? "assets/images/no.svg" : null,
|
|
||||||
activeColor: const Color(0xFFE63946),
|
activeColor: const Color(0xFFE63946),
|
||||||
glowColor: const Color(0xFFE63946),
|
glowColor: const Color(0xFFE63946),
|
||||||
),
|
),
|
||||||
@@ -459,8 +458,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width * 0.8,
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
margin: const EdgeInsets.only(bottom: 16),
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14),
|
||||||
const EdgeInsets.symmetric(horizontal: 10, vertical: 14),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: bgColor,
|
color: bgColor,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -474,8 +472,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
buildStatusCircle(
|
buildStatusCircle(
|
||||||
active: isWaiting,
|
active: isWaiting,
|
||||||
label: "قيد الانتظار",
|
label: "قيد الانتظار",
|
||||||
svgPath:
|
svgPath: isWaiting ? "assets/images/waiting.svg" : null,
|
||||||
isWaiting ? "assets/images/waiting.svg" : null,
|
|
||||||
activeColor: const Color(0xFFF9C8A01B),
|
activeColor: const Color(0xFFF9C8A01B),
|
||||||
glowColor: const Color(0xB4FFDC69),
|
glowColor: const Color(0xB4FFDC69),
|
||||||
),
|
),
|
||||||
@@ -483,8 +480,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
buildStatusCircle(
|
buildStatusCircle(
|
||||||
active: isApproved,
|
active: isApproved,
|
||||||
label: "موافقة",
|
label: "موافقة",
|
||||||
svgPath:
|
svgPath: isApproved ? "assets/images/yes.svg" : null,
|
||||||
isApproved ? "assets/images/yes.svg" : null,
|
|
||||||
activeColor: const Color(0xFF0A8A60),
|
activeColor: const Color(0xFF0A8A60),
|
||||||
glowColor: const Color(0xFF00D7A3),
|
glowColor: const Color(0xFF00D7A3),
|
||||||
),
|
),
|
||||||
@@ -492,8 +488,7 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
|||||||
buildStatusCircle(
|
buildStatusCircle(
|
||||||
active: isDenied,
|
active: isDenied,
|
||||||
label: "تم الرفض",
|
label: "تم الرفض",
|
||||||
svgPath:
|
svgPath: isDenied ? "assets/images/no.svg" : null,
|
||||||
isDenied ? "assets/images/no.svg" : null,
|
|
||||||
activeColor: const Color(0xFFE63946),
|
activeColor: const Color(0xFFE63946),
|
||||||
glowColor: const Color(0xFFE63946),
|
glowColor: const Color(0xFFE63946),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ class RequestService {
|
|||||||
factory RequestService() => _instance;
|
factory RequestService() => _instance;
|
||||||
RequestService._internal();
|
RequestService._internal();
|
||||||
|
|
||||||
final List<LeaveRequest> _leaveRequests = [];
|
// Initialize as empty lists (this should already be working, but let's make it explicit)
|
||||||
final List<AdvanceRequest> _advanceRequests = [];
|
final List<LeaveRequest> _leaveRequests = <LeaveRequest>[];
|
||||||
|
final List<AdvanceRequest> _advanceRequests = <AdvanceRequest>[];
|
||||||
|
|
||||||
// Stream controllers to notify listeners of changes
|
// Stream controllers to notify listeners of changes
|
||||||
final _leaveRequestsController = StreamController<List<LeaveRequest>>.broadcast();
|
final _leaveRequestsController = StreamController<List<LeaveRequest>>.broadcast();
|
||||||
@@ -21,29 +22,23 @@ class RequestService {
|
|||||||
|
|
||||||
// Get all leave requests as a Future
|
// Get all leave requests as a Future
|
||||||
Future<List<LeaveRequest>> getLeaveRequests() async {
|
Future<List<LeaveRequest>> getLeaveRequests() async {
|
||||||
print("Getting ${_leaveRequests.length} leave requests");
|
|
||||||
return List.from(_leaveRequests);
|
return List.from(_leaveRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all advance requests as a Future
|
// Get all advance requests as a Future
|
||||||
Future<List<AdvanceRequest>> getAdvanceRequests() async {
|
Future<List<AdvanceRequest>> getAdvanceRequests() async {
|
||||||
print("Getting ${_advanceRequests.length} advance requests");
|
|
||||||
return List.from(_advanceRequests);
|
return List.from(_advanceRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new leave request
|
// Add a new leave request
|
||||||
Future<void> addLeaveRequest(LeaveRequest request) async {
|
Future<void> addLeaveRequest(LeaveRequest request) async {
|
||||||
_leaveRequests.add(request);
|
_leaveRequests.add(request);
|
||||||
print("Added leave request: ${request.id}, total: ${_leaveRequests.length}");
|
|
||||||
// Notify listeners
|
|
||||||
_leaveRequestsController.add(List.from(_leaveRequests));
|
_leaveRequestsController.add(List.from(_leaveRequests));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new advance request
|
// Add a new advance request
|
||||||
Future<void> addAdvanceRequest(AdvanceRequest request) async {
|
Future<void> addAdvanceRequest(AdvanceRequest request) async {
|
||||||
_advanceRequests.add(request);
|
_advanceRequests.add(request);
|
||||||
print("Added advance request: ${request.id}, total: ${_advanceRequests.length}");
|
|
||||||
// Notify listeners
|
|
||||||
_advanceRequestsController.add(List.from(_advanceRequests));
|
_advanceRequestsController.add(List.from(_advanceRequests));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +46,6 @@ class RequestService {
|
|||||||
Future<void> updateLeaveRequestStatus(String id, String status) async {
|
Future<void> updateLeaveRequestStatus(String id, String status) async {
|
||||||
final index = _leaveRequests.indexWhere((request) => request.id == id);
|
final index = _leaveRequests.indexWhere((request) => request.id == id);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
// Create a new request with the updated status
|
|
||||||
final updatedRequest = LeaveRequest(
|
final updatedRequest = LeaveRequest(
|
||||||
id: _leaveRequests[index].id,
|
id: _leaveRequests[index].id,
|
||||||
leaveType: _leaveRequests[index].leaveType,
|
leaveType: _leaveRequests[index].leaveType,
|
||||||
@@ -62,13 +56,9 @@ class RequestService {
|
|||||||
toTime: _leaveRequests[index].toTime,
|
toTime: _leaveRequests[index].toTime,
|
||||||
reason: _leaveRequests[index].reason,
|
reason: _leaveRequests[index].reason,
|
||||||
requestDate: _leaveRequests[index].requestDate,
|
requestDate: _leaveRequests[index].requestDate,
|
||||||
status: status, // Updated status
|
status: status,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Replace the old request with the updated one
|
|
||||||
_leaveRequests[index] = updatedRequest;
|
_leaveRequests[index] = updatedRequest;
|
||||||
print("Updated leave request status: $id to $status");
|
|
||||||
// Notify listeners
|
|
||||||
_leaveRequestsController.add(List.from(_leaveRequests));
|
_leaveRequestsController.add(List.from(_leaveRequests));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,18 +67,13 @@ class RequestService {
|
|||||||
Future<void> updateAdvanceRequestStatus(String id, String status) async {
|
Future<void> updateAdvanceRequestStatus(String id, String status) async {
|
||||||
final index = _advanceRequests.indexWhere((request) => request.id == id);
|
final index = _advanceRequests.indexWhere((request) => request.id == id);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
// Create a new request with the updated status
|
|
||||||
final updatedRequest = AdvanceRequest(
|
final updatedRequest = AdvanceRequest(
|
||||||
id: _advanceRequests[index].id,
|
id: _advanceRequests[index].id,
|
||||||
amount: _advanceRequests[index].amount,
|
amount: _advanceRequests[index].amount,
|
||||||
reason: _advanceRequests[index].reason,
|
reason: _advanceRequests[index].reason,
|
||||||
status: status, // Updated status
|
status: status,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Replace the old request with the updated one
|
|
||||||
_advanceRequests[index] = updatedRequest;
|
_advanceRequests[index] = updatedRequest;
|
||||||
print("Updated advance request status: $id to $status");
|
|
||||||
// Notify listeners
|
|
||||||
_advanceRequestsController.add(List.from(_advanceRequests));
|
_advanceRequestsController.add(List.from(_advanceRequests));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user