1111
This commit is contained in:
@@ -27,7 +27,6 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
bool _showActions = true;
|
||||
bool _showSettings = true; // NEW — local control for SettingsBar
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -39,24 +38,27 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
|
||||
if (direction == ScrollDirection.reverse) {
|
||||
if (_showActions) setState(() => _showActions = false);
|
||||
setState(() => _showSettings = false);
|
||||
widget.onScrollEvent?.call(true);
|
||||
} else if (direction == ScrollDirection.forward) {
|
||||
if (!_showActions) setState(() => _showActions = true);
|
||||
setState(() => _showSettings = true);
|
||||
widget.onScrollEvent?.call(false);
|
||||
}
|
||||
|
||||
if (_scrollController.position.pixels <= 5) {
|
||||
setState(() {
|
||||
_showActions = true;
|
||||
_showSettings = true;
|
||||
});
|
||||
widget.onScrollEvent?.call(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _initializeData() async {
|
||||
_leaveRequests = await _requestService.getLeaveRequests();
|
||||
_advanceRequests = await _requestService.getAdvanceRequests();
|
||||
@@ -73,118 +75,114 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Stack(
|
||||
children: [
|
||||
// ---------------------------------------------------------
|
||||
// ⭐ SETTINGS BAR (now inside Holiday screen)
|
||||
// ⭐ MAIN CONTENT - CUSTOM SCROLL VIEW
|
||||
// ---------------------------------------------------------
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
top: _showSettings ? 0 : -80,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: SettingsBar(
|
||||
selectedIndex: 0,
|
||||
showBackButton: false,
|
||||
iconPaths: [
|
||||
'assets/images/user.svg',
|
||||
'assets/images/ball.svg',
|
||||
],
|
||||
onTap: (index) {
|
||||
// do your navigation logic
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ⭐ TABS SECTION
|
||||
// Directly under SettingsBar, NO GAP
|
||||
// ---------------------------------------------------------
|
||||
Positioned(
|
||||
top: 70,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: 55,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// الأجازات
|
||||
GestureDetector(
|
||||
onTap: () => setState(() => activeTab = 1),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"الأجازات",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600,
|
||||
color:
|
||||
activeTab == 1
|
||||
? const Color(0xFF8EFDC2)
|
||||
: const Color(0x9EFFFFFF),
|
||||
),
|
||||
),
|
||||
if (activeTab == 1)
|
||||
Container(
|
||||
width: 60,
|
||||
height: 2,
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
color: const Color(0xFF8EFDC2),
|
||||
),
|
||||
],
|
||||
SafeArea(
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
slivers: [
|
||||
// SETTINGS BAR
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: SettingsBar(
|
||||
selectedIndex: 0,
|
||||
showBackButton: false,
|
||||
iconPaths: [
|
||||
'assets/images/user.svg',
|
||||
'assets/images/ball.svg',
|
||||
],
|
||||
onTap: (index) {
|
||||
// do your navigation logic
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 70),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 5)),
|
||||
|
||||
// السلف
|
||||
GestureDetector(
|
||||
onTap: () => setState(() => activeTab = 0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"السلف",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600,
|
||||
color:
|
||||
activeTab == 0
|
||||
? const Color(0xFF8EFDC2)
|
||||
: const Color(0x9EFFFFFF),
|
||||
// TABS SECTION
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 55,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// الأجازات
|
||||
GestureDetector(
|
||||
onTap: () => setState(() => activeTab = 1),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"الأجازات",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: activeTab == 1
|
||||
? const Color(0xFF8EFDC2)
|
||||
: const Color(0x9EFFFFFF),
|
||||
),
|
||||
),
|
||||
if (activeTab == 1)
|
||||
Container(
|
||||
width: 60,
|
||||
height: 2,
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
color: const Color(0xFF8EFDC2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (activeTab == 0)
|
||||
Container(
|
||||
width: 60,
|
||||
height: 2,
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
color: const Color(0xFF8EFDC2),
|
||||
|
||||
const SizedBox(width: 70),
|
||||
|
||||
// السلف
|
||||
GestureDetector(
|
||||
onTap: () => setState(() => activeTab = 0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"السلف",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: activeTab == 0
|
||||
? const Color(0xFF8EFDC2)
|
||||
: const Color(0x9EFFFFFF),
|
||||
),
|
||||
),
|
||||
if (activeTab == 0)
|
||||
Container(
|
||||
width: 60,
|
||||
height: 2,
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
color: const Color(0xFF8EFDC2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 20)),
|
||||
|
||||
// CONTENT LISTS
|
||||
activeTab == 1
|
||||
? _buildLeaveRequestsSliver()
|
||||
: _buildAdvanceRequestsSliver(),
|
||||
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 120)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ⭐ CONTENT AREA (LISTS)
|
||||
// Starts right under the TABS
|
||||
// ---------------------------------------------------------
|
||||
Positioned.fill(
|
||||
top: 130,
|
||||
child:
|
||||
activeTab == 1
|
||||
? _buildLeaveRequestsTab()
|
||||
: _buildAdvanceRequestsTab(),
|
||||
),
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// ⭐ FLOATING ACTION BUTTONS
|
||||
// ---------------------------------------------------------
|
||||
@@ -239,42 +237,68 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// LISTS
|
||||
// SLIVERS FOR LISTS
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
Widget _buildLeaveRequestsTab() {
|
||||
Widget _buildLeaveRequestsSliver() {
|
||||
if (_leaveRequests.isEmpty) {
|
||||
return const Center(
|
||||
child:
|
||||
Text("لا توجد طلبات أجازة", style: TextStyle(color: Colors.white)),
|
||||
return SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"لا توجد طلبات أجازة",
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
controller: _scrollController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 20),
|
||||
itemCount: _leaveRequests.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildLeaveRequestCard(_leaveRequests[index]);
|
||||
},
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: _buildLeaveRequestCard(_leaveRequests[index]),
|
||||
);
|
||||
},
|
||||
childCount: _leaveRequests.length,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAdvanceRequestsTab() {
|
||||
Widget _buildAdvanceRequestsSliver() {
|
||||
if (_advanceRequests.isEmpty) {
|
||||
return const Center(
|
||||
child:
|
||||
Text("لا توجد طلبات سلف", style: TextStyle(color: Colors.white)),
|
||||
return SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"لا توجد طلبات سلف",
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
controller: _scrollController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 20),
|
||||
itemCount: _advanceRequests.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildAdvanceRequestCard(_advanceRequests[index]);
|
||||
},
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: _buildAdvanceRequestCard(_advanceRequests[index]),
|
||||
);
|
||||
},
|
||||
childCount: _advanceRequests.length,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -297,7 +321,6 @@ class _HolidayScreenState extends State<HolidayScreen> {
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
|
||||
Reference in New Issue
Block a user