import 'dart:ui';

import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history_page.dart';
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_page.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../../../Constants.dart';

class HomePrescriptionsPage extends StatefulWidget {
  @override
  _HomePrescriptionsPageState createState() => _HomePrescriptionsPageState();
}

class _HomePrescriptionsPageState extends State<HomePrescriptionsPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  List<ImagesInfo> imagesInfo = List();

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
    imagesInfo.add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-prescriptions/en/0.png',imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-prescriptions/ar/0.png'));
    imagesInfo.add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-prescriptions/en/1.png',imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-prescriptions/ar/1.png'));
  }

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

  @override
  Widget build(BuildContext context) {
    return BaseView<PrescriptionsViewModel>(
      onModelReady: (model) => model.getPrescriptions(),
      builder: (_, model, widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: TranslationBase.of(context).prescriptions,
        description: TranslationBase.of(context).infoPrescriptions,
        infoList: TranslationBase.of(context).infoPrescriptionsPoints,
        imagesInfo: imagesInfo,
        showNewAppBar: true,
        backgroundColor: Color(0xffF8F8F8),
        showNewAppBarTitle: true,
        body: Scaffold(
          extendBodyBehindAppBar: true,
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(65.0),
            child: Column(
              children: <Widget>[

                TabBar(
                  tabs: [
                    Tab(child: Text(TranslationBase.of(context).prescriptions, style: TextStyle(color: Colors.black))),
                    Tab(
                      child: Text(TranslationBase.of(context).history, style: TextStyle(color: Colors.black)),
                    ),

                  ],
                  controller: _tabController,
                ),
                Divider(
                  color: Colors.grey[600],
                  thickness: 0.5,
                ),
              ],
            ),
          ),
          body: Column(
            children: <Widget>[
              Expanded(
                child: TabBarView(
                  physics: BouncingScrollPhysics(),
                  controller: _tabController,
                  children: <Widget>[
                    PrescriptionsPage(
                      prescriptionsViewModel: model,
                    ),
                    PrescriptionsHistoryPage(
                      prescriptionsViewModel: model,
                    )
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
