import 'package:flutter/material.dart';
import 'package:hmg_qline/view_models/queuing_view_model.dart';
import 'package:hmg_qline/view_models/screen_config_view_model.dart';
import 'package:marquee/marquee.dart';
import 'package:provider/provider.dart';
import 'package:hmg_qline/constants/app_constants.dart';
import 'package:hmg_qline/utilities/enums.dart';
import 'package:hmg_qline/views/common_widgets/app_texts_widget.dart';
import 'package:hmg_qline/views/view_helpers/size_config.dart';

class AppFooter extends StatelessWidget {
  const AppFooter({super.key});

  @override
  Widget build(BuildContext context) {
    return Consumer(builder: (BuildContext context, ScreenConfigViewModel screenConfigVM, Widget? child) {
      return Container(
          color: Colors.grey.withOpacity(0.1),
          height: SizeConfig.getHeightMultiplier() * 0.7,
          width: double.infinity,
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  const SizedBox(width: 20),
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      AppText(
                        AppStrings.poweredBy,
                        fontSize: SizeConfig.getWidthMultiplier() * 2.5,
                      ),
                      Text("v${screenConfigVM.currentScreenIP}_${AppConstants.currentBuildVersion}",
                          style: TextStyle(
                            fontWeight: FontWeight.w500,
                            fontSize: SizeConfig.getWidthMultiplier() * 1.7,
                          )),
                      Row(
                        children: [
                          InkWell(
                            onTap: () {
                              screenConfigVM.updateCurrentScreenRotation(ScreenOrientationEnum.portraitUp);
                            },
                            child: Icon(
                              Icons.arrow_upward,
                              size: SizeConfig.getWidthMultiplier() * 2,
                            ),
                          ),
                          InkWell(
                            onTap: () {
                              screenConfigVM.updateCurrentScreenRotation(ScreenOrientationEnum.landscapeRight);
                            },
                            child: Icon(Icons.arrow_forward, size: SizeConfig.getWidthMultiplier() * 2),
                          ),
                          InkWell(
                            onTap: () {
                              screenConfigVM.updateCurrentScreenRotation(ScreenOrientationEnum.portraitDown);
                            },
                            child: Icon(
                              Icons.arrow_downward,
                              size: SizeConfig.getWidthMultiplier() * 2,
                            ),
                          ),
                          InkWell(
                            onTap: () {
                              screenConfigVM.updateCurrentScreenRotation(ScreenOrientationEnum.landscapeLeft);
                            },
                            child: Icon(
                              Icons.arrow_back,
                              size: SizeConfig.getWidthMultiplier() * 2,
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                  const SizedBox(width: 10),
                  InkWell(
                    onTap: () {
                      // context.read<ScreenConfigViewModel>().createAutoTickets(numOfTicketsToCreate: 20);
                    },
                    child: Image.asset(
                      AppAssets.cloudLogo,
                      height: SizeConfig.getHeightMultiplier() * 0.6,
                    ),
                  ),
                ],
              ),
              if (screenConfigVM.globalConfigurationsModel.isRssFeedReq && screenConfigVM.rssFeedModel.rssFeed != null && screenConfigVM.rssFeedModel.rssFeed!.isNotEmpty) ...[
                Expanded(
                  child: Container(
                    padding: const EdgeInsets.symmetric(horizontal: 10),
                    child: Marquee(
                      text: screenConfigVM.rssFeedModel.rssFeed ?? "",
                      style: TextStyle(
                        fontWeight: FontWeight.w500,
                        fontSize: SizeConfig.getWidthMultiplier() * 4,
                        fontFamily: AppStrings.fontNamePoppins,
                      ),
                      scrollAxis: Axis.horizontal,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      blankSpace: 20.0,
                      velocity: 100.0,
                      pauseAfterRound: const Duration(seconds: 1),
                      startPadding: 10.0,
                      accelerationDuration: const Duration(seconds: 1),
                      accelerationCurve: Curves.linear,
                      decelerationDuration: const Duration(milliseconds: 500),
                      decelerationCurve: Curves.easeOut,
                    ),
                  ),
                )
              ]
            ],
          ));
    });
  }
}
