Siopas Inventory PETI for ISTW Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

163 lines
4.4 KiB

// import 'package:flutter/material.dart';
// import 'package:provider/provider.dart';
// import '../../providers/auth_provider.dart';
// import 'home_page.dart';
// import 'setting_page.dart';
// class MainPage extends StatefulWidget {
// @override
// State<MainPage> createState() => _MainPageState();
// }
// class _MainPageState extends State<MainPage> {
// int currentIndex = 0;
// bool isReinitInProgress = false;
// @override
// Widget build(BuildContext context) {
// AuthProvider authProvider = Provider.of<AuthProvider>(context);
// Widget customBottomNav() {
// return ClipRRect(
// // borderRadius: BorderRadius.only(
// // topLeft: Radius.circular(20.0),
// // topRight: Radius.circular(20.0),
// // ),
// child: BottomNavigationBar(
// type: BottomNavigationBarType.fixed,
// currentIndex: currentIndex,
// selectedItemColor: Colors.indigoAccent, // Warna saat dipilih
// onTap: (index) {
// if (mounted) {
// setState(() {
// currentIndex = index;
// });
// }
// },
// items: [
// BottomNavigationBarItem(
// icon: Icon(Icons.home),
// label: 'Beranda',
// ),
// BottomNavigationBarItem(
// icon: Icon(Icons.settings),
// label: 'Pengaturan',
// ),
// ],
// ),
// );
// }
// Widget body() {
// switch (currentIndex) {
// case 0:
// return HomePage();
// case 1:
// // Return your MapsPage here
// return SettingPage(); // Ganti dengan MapsPage
// default:
// return Container(); // Add more cases if needed
// }
// }
// return Scaffold(
// backgroundColor: currentIndex == 0
// ? Color.fromRGBO(255, 255, 255, 0.973)
// : Colors.grey,
// bottomNavigationBar: customBottomNav(),
// body: Stack(
// children: [
// body(),
// ],
// ),
// // extendBody: true, // Membuat latar belakang menembus hingga ke bawah
// );
// }
// }
// main_page.dart
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:provider/provider.dart';
import '../../providers/auth_provider.dart';
import 'home_page.dart';
import 'setting_page.dart';
class MainPage extends StatefulWidget {
@override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
int currentIndex = 0;
bool isReinitInProgress = false;
@override
Widget build(BuildContext context) {
AuthProvider authProvider = Provider.of<AuthProvider>(context);
Widget customBottomNav() {
return AbsorbPointer(
absorbing: isReinitInProgress,
child: ClipRRect(
child: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: currentIndex,
selectedItemColor: Colors.indigoAccent,
onTap: (index) {
if (!isReinitInProgress) {
setState(() {
currentIndex = index;
});
}
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Beranda',
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: 'Pengaturan',
),
],
),
),
);
}
Widget body() {
switch (currentIndex) {
case 0:
return HomePage(onReinitStarted: () {
// Callback untuk memberi tahu bahwa Reinit dimulai
setState(() {
isReinitInProgress = true;
});
}, onReinitFinished: () {
// Callback untuk memberi tahu bahwa Reinit selesai
setState(() {
isReinitInProgress = false;
});
});
case 1:
return SettingPage();
default:
return Container();
}
}
return Scaffold(
backgroundColor: currentIndex == 0
? Color.fromRGBO(255, 255, 255, 0.973)
: Colors.grey,
bottomNavigationBar: customBottomNav(),
body: Stack(
children: [
body(),
],
),
);
}
}