import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hmg_qline/config/dependency_injection.dart';
import 'package:hmg_qline/models/global_config_model.dart';
import 'package:hmg_qline/utilities/enums.dart';
import 'package:hmg_qline/utilities/native_method_handler.dart';
import 'package:hmg_qline/view_models/queuing_view_model.dart';
import 'package:hmg_qline/view_models/screen_config_view_model.dart';
import 'package:hmg_qline/views/common_widgets/app_general_widgets.dart';
import 'package:provider/provider.dart';
import 'package:hmg_qline/constants/app_constants.dart';

import 'package:hmg_qline/views/common_widgets/app_texts_widget.dart';
import 'package:hmg_qline/views/view_helpers/size_config.dart';

class AppHeader extends StatelessWidget implements PreferredSizeWidget {
  const AppHeader({super.key});

  @override
  Widget build(BuildContext context) {
    return Selector<ScreenConfigViewModel, GlobalConfigurationsModel>(
      selector: (context, screenConfigViewModel) => screenConfigViewModel.globalConfigurationsModel,
      builder: (BuildContext context, GlobalConfigurationsModel globalConfigurationsModel, Widget? child) {
        return Directionality(
          textDirection: globalConfigurationsModel.textDirection,
          child: Padding(
            padding: EdgeInsets.symmetric(horizontal: SizeConfig.getWidthMultiplier() * 4),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    InkWell(

                      onTap: () {
                        // getIt.get<QueuingViewModel>().triggerOOM();
                      },
                      child: engArabicTextWithSeparatorWidget(
                        englishText: globalConfigurationsModel.currentServeTextEng ?? "",
                        arabicText: globalConfigurationsModel.currentServeTextArb ?? "",
                      ),
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        SvgPicture.asset(
                          globalConfigurationsModel.qTypeEnum == QTypeEnum.appointment ? AppAssets.hmgLogoFull : AppAssets.hmgLogoPharmacy,
                          height: SizeConfig.getHeightMultiplier() * 0.48,
                        ),
                      ],
                    ),
                    // networkStatusBar(),
                  ],
                ),
              ],
            ),
          ),
        );
      },
    );
  }

  @override
  Size get preferredSize => Size(double.maxFinite, SizeConfig.getHeightMultiplier() * 1.1);
}
