import 'package:hmg_patient_app/core/model/ImagesInfo.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/models/Authentication/authenticated_user.dart';
import 'package:hmg_patient_app/pages/base/base_view.dart';
import 'package:hmg_patient_app/pages/packages_offers/OfferAndPackagesPage.dart';
import 'package:hmg_patient_app/pages/packages_offers/packages_orders_history.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

bool OFFERS_VIEW_ONLY = false;
class PackagesOfferTabPage extends StatefulWidget{

  AuthenticatedUser user;
  PackagesOfferTabPage(this.user);

  @override
  State<StatefulWidget> createState() => PackagesOfferTabPageState();
}

class PackagesOfferTabPageState extends State<PackagesOfferTabPage> with SingleTickerProviderStateMixin{
  TabController? _tabController;
  ProjectViewModel? _projectViewModel;

  @override
  void initState() {
    _tabController = TabController(length: 2, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    _projectViewModel = Provider.of(context);
    return AppScaffold(
      description: TranslationBase.of(context).offerAndPackagesDetails,
      imagesInfo: [ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png')],
      appBarTitle: TranslationBase.of(context).offerAndPackages,
      isShowAppBar: true,
      isPharmacy: false,
      backgroundColor: Color(0xfff7f7f7),
      showPharmacyCart: false,
      isOfferPackages: true,
      showOfferPackagesCart: false,
      isShowDecPage: false,
      showNewAppBar: true,
      showNewAppBarTitle: true,
      body: Column(
        children: <Widget>[
          SizedBox(
            height: OFFERS_VIEW_ONLY ? null : 0,
            child: TabBar(
              controller: _tabController,
              indicatorWeight: 3.0,
              indicatorSize: TabBarIndicatorSize.tab,
              labelColor: Color(0xff2B353E),
              unselectedLabelColor: Color(0xff575757),
              labelPadding: EdgeInsets.only(top: 15, bottom: 13, left: 20, right: 20),
              labelStyle: TextStyle(
                fontFamily: _projectViewModel!.isArabic ? 'Cairo' : 'Poppins',
                fontSize: 16,
                fontWeight: FontWeight.w600,
                letterSpacing: -0.48,
              ),
              unselectedLabelStyle: TextStyle(
                fontFamily: _projectViewModel!.isArabic ? 'Cairo' : 'Poppins',
                fontSize: 16,
                fontWeight: FontWeight.w600,
                letterSpacing: -0.48,
              ),
              tabs: [Text(TranslationBase.of(context).offerAndPackages), Text(TranslationBase.of(context).orderLog)],
            ),
          ),
          Expanded(
            child: TabBarView(
              physics: OFFERS_VIEW_ONLY ? BouncingScrollPhysics() : NeverScrollableScrollPhysics(),
              controller: _tabController,
              children: <Widget>[
                PackagesHomePage(widget.user),
                PackagesOrdersHistory()
              ],
            ),
          )
        ],
      ),
    );
  }

}
