import 'dart:ui';

import 'package:hmg_patient_app/core/model/ImagesInfo.dart';
import 'package:hmg_patient_app/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/pages/base/base_view.dart';
import 'package:hmg_patient_app/theme/colors.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';

import 'NewCMC/new_cmc_page.dart';
import 'orders_log_details_page.dart';

class CMCPage extends StatefulWidget {
  @override
  _CMCPageState createState() => _CMCPageState();
}

class _CMCPageState extends State<CMCPage> with SingleTickerProviderStateMixin {
  late TabController _tabController;

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

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

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return BaseView<CMCViewModel>(
      onModelReady: (model) async {
        await model.getCmcAllPresOrders();
      },
      builder: (_, model, widget) => AppScaffold(
        isShowAppBar: true,
        description: TranslationBase.of(context).infoCMC,
        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).comprehensiveMedicalCheckup,
        showNewAppBar: true,
        showNewAppBarTitle: true,
        backgroundColor: CustomColors.appBackgroudGrey2Color,
        body: Column(
          children: <Widget>[
            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).cmcHeading), Text(TranslationBase.of(context).orderLog)],
            ),
            Expanded(
              child: TabBarView(
                physics: BouncingScrollPhysics(),
                controller: _tabController,
                children: <Widget>[NewCMCPage(model: model), OrdersLogDetailsPage(model: model)],
              ),
            )
          ],
        ),
      ),
    );
  }
}
