second commit
This commit is contained in:
96
lib/View/Home/Homeview.dart
Normal file
96
lib/View/Home/Homeview.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../Controller/Home/Homecontroller.dart';
|
||||
import '../../Helper/Constants/Colorconstants.dart';
|
||||
import '../../Helper/toast.dart';
|
||||
import '../Customers/Customersview.dart';
|
||||
import '../Dashboard/Dashboardview.dart';
|
||||
import '../Dashboard/Tabs/Createdview.dart';
|
||||
import '../More/Moreview.dart';
|
||||
import '../Orders/Orderspage.dart';
|
||||
|
||||
|
||||
class HomeView extends StatelessWidget {
|
||||
final int selectedIndex;
|
||||
|
||||
HomeView({super.key, required this.selectedIndex});
|
||||
|
||||
HomeController homeController = Get.put(HomeController());
|
||||
|
||||
DateTime? currentBackPressTime;
|
||||
|
||||
Future<bool> _willPopCallback() async {
|
||||
DateTime now = DateTime.now();
|
||||
if (currentBackPressTime == null ||
|
||||
now.difference(currentBackPressTime!) > Duration(seconds: 1)) {
|
||||
currentBackPressTime = now;
|
||||
Toast.showToast("Press one more time to exit");
|
||||
return Future.value(false);
|
||||
}else{
|
||||
Get.back();
|
||||
return Future.value(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> widgetOptionsNearle = _widgetOptionsNearle();
|
||||
|
||||
return GetBuilder<HomeController>(initState: (_) {
|
||||
homeController.selectedIndex = selectedIndex;
|
||||
}, builder: (controller) {
|
||||
return WillPopScope(
|
||||
onWillPop: _willPopCallback,
|
||||
child: Scaffold(
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
items: <BottomNavigationBarItem>[
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home),
|
||||
label: 'Home',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.shopping_cart),
|
||||
label: 'Orders',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.shopping_bag),
|
||||
label: 'Products',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.people),
|
||||
label: 'Customers',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person),
|
||||
label: 'Accounts',
|
||||
),
|
||||
],
|
||||
currentIndex: homeController.selectedIndex,
|
||||
selectedItemColor: ColorConstants.primaryColor,
|
||||
unselectedItemColor: Colors.grey,
|
||||
onTap: homeController.onItemTapped,
|
||||
),
|
||||
body: widgetOptionsNearle[controller.selectedIndex],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<Widget> _widgetOptionsNearle() =>
|
||||
<Widget>[
|
||||
DashboardView(),
|
||||
OrderView(),
|
||||
ProductView(),
|
||||
CustomerView(),
|
||||
// ReassignRidersView(deliveryDetails: DeliveriesDetails()),
|
||||
MoreView()
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user