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