import 'dart:ui';

import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart';
import 'package:doctor_app_flutter/screens/patients/patient_search_screen.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class SearchMedicinePatientScreen extends StatefulWidget {
  @override
  _SearchMedicinePatientScreen createState() => _SearchMedicinePatientScreen();
}

class _SearchMedicinePatientScreen extends State<SearchMedicinePatientScreen>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  var activeIndex = 0;
  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  @override
  Widget build(BuildContext context) {
    return AppScaffold(
        isShowAppBar: true,
        appBarTitle: TranslationBase.of(context).searchmedicinepatient,
        body: Scaffold(
          extendBodyBehindAppBar: true,
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(65.0),
            child: Center(
              child: Container(
                height: 60.0,
                margin: EdgeInsets.only(top: 10.0),
                width: MediaQuery.of(context).size.width * 0.92, // 0.9,
                decoration: BoxDecoration(
                    border: Border(
                      bottom: BorderSide(
                          color: Theme.of(context).dividerColor,
                          width: 0.9), //width: 0.7
                    ),
                    color: Colors.white),
                child: TabBar(
                  isScrollable: true,
                  onTap: (index) {
                    setState(() {
                      activeIndex = index;
                    });
                  },
                  controller: _tabController,
                  indicatorWeight: 5.0,
                  indicatorSize: TabBarIndicatorSize.tab,
                  indicatorColor: Colors.red[800],
                  labelColor: Theme.of(context).primaryColor,
                  labelPadding:
                      EdgeInsets.only(top: 4.0, left: 30.0, right: 30.0),
                  unselectedLabelColor: Colors.grey[800],
                  tabs: [
                    Container(
                      width: MediaQuery.of(context).size.width * 0.35,
                      child: Center(
                        child: AppText(
                          TranslationBase.of(context).searchPatient,
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                          fontSize: 14,
                        ),
                      ),
                    ),
                    Container(
                      width: MediaQuery.of(context).size.width * 0.35,
                      child: Center(
                        child: AppText(
                            TranslationBase.of(context).searchMedicine,
                            fontWeight: FontWeight.bold,
                            fontSize: 14,
                            color: Colors.black),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
          body: Column(
            children: <Widget>[
              Expanded(
                child: TabBarView(
                  physics: BouncingScrollPhysics(),
                  controller: _tabController,
                  children: <Widget>[
                    PatientSearchScreen(),
                    MedicineSearchScreen()
                  ],
                ),
              )
            ],
          ),
        ));
  }
}
