last changes
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import 'package:coda_project/screens/user_settings_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_svg/flutter_svg.dart';
|
||||
import '../screens/notifications_screen.dart';
|
||||
import '../widgets/app_background.dart';
|
||||
import '../widgets/floatingnavbar.dart';
|
||||
import '../widgets/settings_bar.dart';
|
||||
import '../screens/attendence_screen.dart';
|
||||
import '../screens/finance_screen.dart';
|
||||
import '../screens/holiday_screen.dart';
|
||||
@@ -18,83 +14,63 @@ class MainPage extends StatefulWidget {
|
||||
|
||||
class _MainPageState extends State<MainPage> {
|
||||
int _currentIndex = 0;
|
||||
int _settingsIndex = 0;
|
||||
|
||||
final List<Widget> _screens = [
|
||||
const AttendanceScreen(),
|
||||
const FinanceScreen(),
|
||||
const HolidayScreen(),
|
||||
];
|
||||
|
||||
final List<NavBarItem> _navItems = [
|
||||
NavBarItem(iconPath: 'assets/images/attendance.svg', label: 'الحضور'),
|
||||
NavBarItem(iconPath: 'assets/images/finance.svg', label: 'المالية'),
|
||||
NavBarItem(iconPath: 'assets/images/holiday.svg', label: 'الإجازة'),
|
||||
];
|
||||
|
||||
final List<String> _settingsIconPaths = [
|
||||
'assets/images/user.svg',
|
||||
'assets/images/ball.svg',
|
||||
];
|
||||
Widget _buildScreen() {
|
||||
switch (_currentIndex) {
|
||||
case 0:
|
||||
return const AttendanceScreen();
|
||||
case 1:
|
||||
return const FinanceScreen(); // no need for scroll callback anymore
|
||||
case 2:
|
||||
return const HolidayScreen(); // SettingsBar is inside the screen now
|
||||
default:
|
||||
return const AttendanceScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: AppBackground(
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
SettingsBar(
|
||||
selectedIndex: _settingsIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_settingsIndex = index;
|
||||
});
|
||||
body: Stack(
|
||||
children: [
|
||||
/// BACKGROUND
|
||||
const AppBackground(child: SizedBox()),
|
||||
|
||||
// 🟢 If user clicked the first icon (user.svg), open settings screen
|
||||
if (index == 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const UserSettingsScreen(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 🔔 Ball icon → Notifications screen
|
||||
if (index == 1) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(_) => const NotificationsScreen(), // placeholder
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
showBackButton: false,
|
||||
iconPaths: _settingsIconPaths,
|
||||
),
|
||||
|
||||
// Main content area
|
||||
Expanded(
|
||||
child: IndexedStack(index: _currentIndex, children: _screens),
|
||||
),
|
||||
|
||||
// const SizedBox(height: 20),
|
||||
Floatingnavbar(
|
||||
items: _navItems,
|
||||
selectedIndex: _currentIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
/// ACTIVE SCREEN (fills everything except navbar area)
|
||||
Positioned.fill(
|
||||
bottom: 100, // space for floating navbar
|
||||
child: _buildScreen(),
|
||||
),
|
||||
),
|
||||
|
||||
/// FLOATING NAVBAR
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 20,
|
||||
child: Floatingnavbar(
|
||||
items: [
|
||||
NavBarItem(
|
||||
iconPath: 'assets/images/attendance.svg',
|
||||
label: 'الحضور',
|
||||
),
|
||||
NavBarItem(
|
||||
iconPath: 'assets/images/finance.svg',
|
||||
label: 'المالية',
|
||||
),
|
||||
NavBarItem(
|
||||
iconPath: 'assets/images/holiday.svg',
|
||||
label: 'الإجازة',
|
||||
),
|
||||
],
|
||||
selectedIndex: _currentIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user