import 'dart:ui';

import 'package:hmg_patient_app/core/model/ImagesInfo.dart';
import 'package:hmg_patient_app/core/viewModels/er/am_request_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/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 'AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart';
import 'OrderLogPage.dart';

class AmbulanceReq extends StatefulWidget {
  @override
  _AmbulanceReqState createState() => _AmbulanceReqState();
}

class _AmbulanceReqState extends State<AmbulanceReq> with SingleTickerProviderStateMixin {
  late TabController _tabController;
  List<ImagesInfo> imagesInfo =[];

  @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);
    imagesInfo.add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/Ambulance/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/Ambulance/ar/0.png'));

    return BaseView<AmRequestViewModel>(
      onModelReady: (model) => model.getAmRequestOrders(projectViewModel.isArabic ? 1 : 2),
      builder: (_, model, widget) => AppScaffold(
        isShowAppBar: true,
        showNewAppBarTitle: true,
        showNewAppBar: true,
        appBarTitle: TranslationBase.of(context).transportationService,
        description: TranslationBase.of(context).infoAmbulance,
        imagesInfo: imagesInfo,
        baseViewModel: model,
        body: Column(
          children: [
            TabBar(
              isScrollable: false,
              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: 15,
                fontWeight: FontWeight.w600,
                letterSpacing: -0.48,
              ),
              unselectedLabelStyle: TextStyle(
                fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins',
                fontSize: 15,
                fontWeight: FontWeight.w600,
                letterSpacing: -0.48,
              ),
              tabs: [
                Text(TranslationBase.of(context).transportationService),
                Text(TranslationBase.of(context).ordersLog),
              ],
            ),
            Expanded(
              child: TabBarView(
                physics: NeverScrollableScrollPhysics(),
                controller: _tabController,
                children: <Widget>[
                  AmbulanceRequestIndexPage(
                    amRequestViewModel: model,
                    tabController: _tabController,
                  ),
                  OrderLogPage(
                    amRequestViewModel: model,
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
