import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/models/InPatientServices/get_inpatient_advance_requests_response_model.dart';
import 'package:hmg_patient_app/pages/InPatientServices/components/inpatient_paid_advance_payment.dart';
import 'package:hmg_patient_app/pages/InPatientServices/components/inpatient_pending_advance_payment.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/material.dart';
import 'package:provider/provider.dart';

class InPatientAdvancePayment extends StatefulWidget {
  InPatientAdvanceResponseModel? inPatientAdvanceResponseModel;
  bool? isHasData;

  InPatientAdvancePayment({this.isHasData, this.inPatientAdvanceResponseModel});

  @override
  State<InPatientAdvancePayment> createState() => _InPatientAdvancePaymentState();
}

class _InPatientAdvancePaymentState extends State<InPatientAdvancePayment> with SingleTickerProviderStateMixin {
  late TabController _tabController;
  late ProjectViewModel projectViewModel;

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

  @override
  Widget build(BuildContext context) {
    projectViewModel = Provider.of(context);
    return AppScaffold(
      isShowAppBar: true,
      isShowDecPage: false,
      showNewAppBarTitle: true,
      showNewAppBar: true,
      appBarTitle: TranslationBase.of(context).advancePayment,
      body: Column(
        children: [
          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),
            physics: const NeverScrollableScrollPhysics(),
            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).pending), Text(TranslationBase.of(context).history)],
          ),
          Expanded(
            child: TabBarView(
              physics: BouncingScrollPhysics(),
              controller: _tabController,
              children: [
                InPatientPendingAdvancePayment(isHasData: widget.isHasData!, inPatientAdvanceResponseModel: widget.inPatientAdvanceResponseModel!),
                InPatientPaidAdvancePayment(),
              ],
            ),
          )
        ],
      ),
    );
  }
}
