import 'package:doctor_app_flutter/screens/dashboard_screen.dart';
import 'package:doctor_app_flutter/screens/doctor/message_screen.dart';
import 'package:doctor_app_flutter/screens/doctor/my_schedule_screen.dart';
import 'package:doctor_app_flutter/screens/doctor/services_screen.dart';
import 'package:doctor_app_flutter/widgets/shared/app_drawer_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/bottom_nav_bar.dart';
import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/user-guid/app_showcase_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';

class LandingPage extends StatefulWidget {
  @override
  _LandingPageState createState() => _LandingPageState();
}

class _LandingPageState extends State<LandingPage> {
  int currentTab = 0;
  PageController pageController;

  _changeCurrentTab(int tab) {
    setState(() {
      currentTab = tab;
      pageController.jumpToPage(tab);
    });
  }

  @override
  void initState() {
    super.initState();
    pageController = new PageController(keepPage: true);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        backgroundColor: Hexcolor('#515B5D'),
        textTheme: TextTheme(
            headline6:
                TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
        title: Text(getText(currentTab).toUpperCase()),
        leading: Builder(
          builder: (BuildContext context) {
            return IconButton(
              icon: Icon(Icons.menu),
              color: Colors.white,
              onPressed: () => Scaffold.of(context).openDrawer(),
            );
          },
        ),
        centerTitle: true,
      ),
      drawer: SafeArea(child: AppDrawer()),
      extendBody: true,
      body: PageView(
        physics: NeverScrollableScrollPhysics(),
        controller: pageController,
        children: [
          ShowCaseWidget(
            builder: Builder(builder: (context) => DashboardScreen()),
          ),
          MessagesScreen(),
          MyScheduleScreen(),
          ServicesScreen()
        ],
      ),
      bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab),
    );
  }

  getText(currentTab) {
    switch (currentTab) {
      case 0:
        return TranslationBase.of(context).home;
      case 1:
        return TranslationBase.of(context).replay;
      case 2:
        return TranslationBase.of(context).mySchedule;
      case 3:
        return TranslationBase.of(context).services;
    }
  }
}
