import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/parent_categorise_page.dart';
import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart';
import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart';
import 'package:flutter/material.dart';

import '../offers_categorise_page.dart';

class LandingPagePharmacy extends StatefulWidget {
  @override
  _LandingPagePharmacyState createState() => _LandingPagePharmacyState();
}

class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
  int currentTab = 0;
  PageController pageController;
  ProjectViewModel projectProvider;

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: currentTab == 0 || currentTab == 1
          ? AppBar(
              backgroundColor: Color(0xff5AB145),
              elevation: 0,
              title: Container(
                height: 30,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4.0),
                  color: Colors.white,
                ),
                child: InkWell(
                  child: Padding(
                    padding: EdgeInsets.all(8.0),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Icon(Icons.search, size: 16.0),
                        SizedBox(
                          width: 5.0,
                        ),
                        Text(
                          'Search your Medicine',
                          style: TextStyle(
                              fontSize: 13.0, fontWeight: FontWeight.w300),
                        )
                      ],
                    ),
                  ),
                ),
              ),
              leading: Builder(
                builder: (BuildContext context) {
                  return Container(
                    height: 2.0,
                    width: 10.0,
                    child: Image.asset(
                      'assets/images/pharmacy_logo.png',
                    ),
                  );
                },
              ),
              actions: [
                // IconButton(
                //     iconSize: 70,
                //     icon: SvgPicture.asset('assets/images/svg/robort_svg.svg',
                //         height: 100, width: 100, fit: BoxFit.cover),
                //     onPressed: () {
                //       triggerRobot();
                //     } //do something,
                //     )
              ],
              centerTitle: true,
            )
          : AppBar(
              backgroundColor: Color(0xff5AB145),
              elevation: 0,
              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.arrow_back),
                    color: Colors.white,
                    onPressed: () => Scaffold.of(context).openDrawer(),
                  );
                },
              ),
              actions: [
                // IconButton(
                //     iconSize: 70,
                //     icon: SvgPicture.asset('assets/images/svg/robort_svg.svg',
                //         height: 100, width: 100, fit: BoxFit.cover),
                //     onPressed: () {
                //       triggerRobot();
                //     } //do something,
                //     )
              ],
              centerTitle: true,
            ),
      extendBody: false,
      body: PageView(
        physics: NeverScrollableScrollPhysics(),
        controller: pageController,
        children: [
          Container(
            child: Text('text'),
          ),
          PharmacyCategorisePage(),
          OffersCategorisePage(),
          ParentCategorisePage(),
          Container(
            child: Center(child: Text('This Is Cart Page')),
          ),
        ], // Please do not remove the BookingOptions from this array
      ),
      bottomNavigationBar: BottomNavPharmacyBar(
        changeIndex: _changeCurrentTab,
        index: currentTab,
      ),
    );
  }

  getText(currentTab) {
    switch (currentTab) {
      case 2:
        return 'Wishlist';
      case 3:
        return 'My Account';
      case 4:
        return 'Shopping Cart';
    }
  }
}
