Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HomeViewScreen extends StatefulWidget {
- @override
- _HomeViewScreenState createState() => _HomeViewScreenState();
- }
- class _HomeViewScreenState extends State<HomeViewScreen>
- with TickerProviderStateMixin {
- AnimationController animationController;
- Widget tabBody = Container(
- color: TemaApp.background,
- );
- List<TabIconData> tabIconsList = TabIconData.tabIconsList;
- final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
- @override
- void dispose() {
- animationController.dispose();
- super.dispose();
- }
- //Disabilito il bottone di back su android
- bool myInterceptor(bool stopDefaultButtonEvent) {
- print("Bottone back disabilitato!"); // Do some stuff.
- return true;
- }
- @override
- void initState() {
- BackButtonInterceptor.add(myInterceptor);
- tabIconsList.forEach((TabIconData tab) {
- tab.isSelected = false;
- });
- tabIconsList[0].isSelected = true;
- animationController = AnimationController(
- duration: const Duration(milliseconds: 600), vsync: this);
- tabBody = MyDiaryScreen(animationController: animationController);
- super.initState();
- //Dopo aver inizializzato le view verifico che i valori siano attivi
- _checkParametri();
- }
- //Questa funzione mostra un messaggio nella snackbar
- void showInSnackBar(String value) {
- FocusScope.of(context).requestFocus(new FocusNode());
- _scaffoldKey.currentState?.removeCurrentSnackBar();
- _scaffoldKey.currentState.showSnackBar(new SnackBar(
- content: new Text(
- value,
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white,
- fontSize: 16.0,
- fontFamily: "WorkSansSemiBold"),
- ),
- backgroundColor: Colors.blue,
- duration: Duration(seconds: 3),
- ));
- }
- //Questa funzione viene eseguita
- // all'avvio dell'app per verificare che i valori siano attivi
- Future<void> _checkParametri() async {
- bool check = await Gps.isPermesso();
- if (!check) {
- showInSnackBar("Errore: GPS non attivo");
- }
- }
- Future<bool> getData() async {
- await Future<dynamic>.delayed(const Duration(milliseconds: 200));
- return true;
- }
- //Configurazione della bottombar
- Widget bottomBar() {
- return Column(
- children: <Widget>[
- const Expanded(
- child: SizedBox(),
- ),
- BottomBarView(
- tabIconsList: tabIconsList,
- addClick: () {
- super.dispose();
- },
- changeIndex: (int index) {
- //Indice per il marcatempo
- if (index == 0) {
- animationController.reverse().then<dynamic>((data) {
- if (!mounted) {
- return;
- }
- setState(() {
- tabBody =
- MyDiaryScreen(animationController: animationController);
- });
- });
- }
- //Indice che indica la ricerca dei rapportini
- else if (index == 1) {
- animationController.reverse().then<dynamic>((data) {
- print("Sono all'interno del tab 2");
- if (!mounted) {
- return;
- }
- setState(() {
- var rapportiniView=new RapportiniScreen(
- animationController: animationController);
- tabBody = rapportiniView;
- });
- });
- }
- //Indice per la ricerca dei cantieri
- else if (index == 2) {
- animationController.reverse().then<dynamic>((data) {
- if (!mounted) {
- return;
- }
- setState(() {
- tabBody =
- UserScreen(animationController: animationController);
- /* tabBody = RicercaCantieriScreen(
- animationController: animationController);*/
- });
- });
- }
- //l'indice selezionato รจ il terzo visualizzo la schermata utenti
- else if (index == 3) {
- animationController.reverse().then<dynamic>((data) {
- if (!mounted) {
- return;
- }
- setState(() {
- tabBody =
- UserScreen(animationController: animationController);
- });
- });
- }
- },
- ),
- ],
- );
- }
- @override
- Widget build(BuildContext context) {
- return Container(
- color: TemaApp.background,
- child: Scaffold(
- backgroundColor: Colors.transparent,
- body: FutureBuilder<bool>(
- future: getData(),
- builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
- if (!snapshot.hasData) {
- return const SizedBox();
- } else {
- return new Stack(
- children: <Widget>[
- tabBody,
- bottomBar(),
- ],
- );
- }
- },
- ),
- ),
- );
- }
- }
Add Comment
Please, Sign In to add comment