/// Flutter code sample for BottomNavigationBar

// This example shows a [BottomNavigationBar] as it is used within a [Scaffold]
// widget. The [BottomNavigationBar] has four [BottomNavigationBarItem]
// widgets, which means it defaults to [BottomNavigationBarType.shifting], and
// the [currentIndex] is set to index 0. The selected item is amber in color.
// With each [BottomNavigationBarItem] widget, backgroundColor property is
// also defined, which changes the background color of [BottomNavigationBar],
// when that item is selected. The `_onItemTapped` function changes the
// selected item's index and displays a corresponding message in the center of
// the [Scaffold].

import 'package:flutter/material.dart';
import 'package:jubo/event.dart';
import 'package:jubo/ui/settings.dart';
import 'package:jubo/ui/signUpScreen.dart';
import 'splash.dart';
import 'event.dart';
import 'package:jubo/ui/wallet.dart';
import 'home.dart';
import 'model/person.dart';
import 'util/params.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main() => runApp(const MyApp());

/// This is the main application widget.
class MyApp extends StatelessWidget {
  const MyApp({key}) : super(key: key);

  static const String _title = 'JuBo';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        localizationsDelegates: [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          GlobalCupertinoLocalizations.delegate,
        ],
        supportedLocales: [
          const Locale('en', ''), // English, no country code
          const Locale('pt', 'BR'), // Hebrew, no country code
        ],
        title: _title,
        debugShowCheckedModeBanner: false,
        home: Splash());
    //title: _title, debugShowCheckedModeBanner: false, home: Splash());
  }
}

/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
  MyStatefulWidget({this.selectedIndex});
  int selectedIndex;
  @override
  _MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}

/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {


  static TextStyle optionStyle =
      TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
  static List<Widget> _widgetOptions = <Widget>[
    Home(),
    Event(),
    Wallet(),
    Settings(),
  ];


  void _onItemTapped(int index) {
    setState(() {
      widget.selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: PreferredSize(
          preferredSize: Size.fromHeight(60.0),
          child: AppBar(
              automaticallyImplyLeading: false,
              centerTitle: true,
              title: Image.asset('assets/images/Jubo_Logo_White.png', width: 200,),
              backgroundColor: Color.fromRGBO(68, 49, 122, 1.0))),
      body: Container(
          color: COLOR_TERTIARY,
          child: Center(
            child: _widgetOptions.elementAt(widget.selectedIndex),
          )),
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home, color: COLOR_FONT_1),
            label: 'Home',
            backgroundColor: Color.fromRGBO(68, 49, 122, 1.0),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.nightlife, color: COLOR_FONT_1),
            label: 'Eventos',
            backgroundColor: Color.fromRGBO(68, 49, 122, 1.0),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.account_balance_wallet, color: COLOR_FONT_1),
            label: 'Carteira',
            backgroundColor: Color.fromRGBO(68, 49, 122, 1.0),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.settings, color: COLOR_FONT_1),
            label: 'Configurações',
            backgroundColor: Color.fromRGBO(68, 49, 122, 1.0),
          ),
        ],
        currentIndex: widget.selectedIndex,
        selectedItemColor: Colors.white,
        onTap: _onItemTapped,
      ),
    );
  }
}
