import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';

import 'navbar_screens/account.dart';
import 'navbar_screens/history.dart';
import 'navbar_screens/home.dart';
import 'navbar_screens/notifications.dart';
import 'navbar_screens/vehicle_details.dart';

class NavBarScreen extends StatefulWidget {
  @override
  _NavBarScreenState createState() => _NavBarScreenState();
}

class _NavBarScreenState extends State<NavBarScreen> {
  int selected_index = 2;

  final HistoryScreen _history = new HistoryScreen();
  final VehicleDetailsScreen _vehicleDetails = new VehicleDetailsScreen();
  final HomeScreen _home = HomeScreen();
  final NotificationsScreen _notifications = new NotificationsScreen();
  final AccountScreen _account = new AccountScreen();

  Widget _showPage = new HomeScreen();

  Widget _pageChooser(int page) {
    switch (page) {
      case 0:
        return _history;
      case 1:
        return _vehicleDetails;
      case 2:
        return _home;
      case 3:
        return _notifications;
      case 4:
        return _account;
      default:
        return new Container(
          child: new Center(
            child: new Text("No page found"),
          ),
        );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: CurvedNavigationBar(
        index: selected_index,
        color: Color(0xff01122b),
        buttonBackgroundColor: Color(0xff01122b),
        backgroundColor: Colors.white,
        animationDuration: Duration(milliseconds: 400),
        animationCurve: Curves.easeInBack,
        height: 55.0,
        items: <Widget>[
          Icon(Icons.history, size: 30, color: Colors.white),
          Icon(Icons.car_rental_rounded, size: 30, color: Colors.white),
          Icon(Icons.home, size: 30, color: Colors.white),
          Icon(Icons.notification_add, size: 30, color: Colors.white),
          Icon(Icons.person, size: 30, color: Colors.white),
        ],
        onTap: (int tapped_index) {
          setState(() {
            _showPage = _pageChooser(tapped_index);
          });
        },
      ),
      body: Container(
        child: Center(
          child: _showPage,
        ),
      ),
    );
  }
}
