content: // ignore_for_file: invalid_use_of_protected_member
  
  import 'package:anymex/widgets/header.dart';
  import 'package:flutter/material.dart';
  import 'package:flutter/services.dart';
  
  import 'package:get/get.dart';
  
  import 'package:anymex/controllers/service_handler/service_handler.dart';
  import 'package:anymex/widgets/common/scroll_aware_app_bar.dart';
  
  class AnimeHomePage extends StatefulWidget {
    const AnimeHomePage({
      super.key,
    });
  
    @override
    State<AnimeHomePage> createState() => _AnimeHomePageState();
  }
  
  class _AnimeHomePageState extends State<AnimeHomePage> {
    late ScrollController _scrollController;
    final ValueNotifier<bool> _isAppBarVisibleExternally =
        ValueNotifier<bool>(true);
  
    @override
    void initState() {
      super.initState();
      _scrollController = ScrollController();
    }
  
    ScrollController get scrollController => _scrollController;
  
    @override
    void dispose() {
      _scrollController.dispose();
      _isAppBarVisibleExternally.dispose();
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      final serviceHandler = Get.find<ServiceHandler>();
      final isDesktop = MediaQuery.of(context).size.width > 600;
      final statusBarHeight = MediaQuery.of(context).padding.top;
      const appBarHeight = kToolbarHeight + 20;
      final double bottomNavBarHeight = MediaQuery.of(context).padding.bottom;
  
      return Scaffold(
        extendBodyBehindAppBar: true,
        body: Stack(
          children: [
            SingleChildScrollView(
              controller: _scrollController,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  SizedBox(height: statusBarHeight + appBarHeight),
                  const SizedBox(height: 10),
                  Obx(() {
                    return Column(
                      children: serviceHandler.animeWidgets(context),
                    );
                  }),
                  if (!isDesktop)
                    SizedBox(height: bottomNavBarHeight)
                  else
                    const SizedBox(height: 50),
                ],
              ),
            ),
            CustomAnimatedAppBar(
              isVisible: _isAppBarVisibleExternally,
              scrollController: _scrollController,
              headerContent: const Header(type: PageType.anime),
              visibleStatusBarStyle: SystemUiOverlayStyle(
                statusBarIconBrightness:
                    Theme.of(context).brightness == Brightness.light
                        ? Brightness.dark
                        : Brightness.light,
                statusBarBrightness: Theme.of(context).brightness,
                statusBarColor: Colors.transparent,
              ),
              hiddenStatusBarStyle: SystemUiOverlayStyle(
                statusBarIconBrightness:
                    Theme.of(context).brightness == Brightness.light
                        ? Brightness.light
                        : Brightness.dark,
                statusBarBrightness:
                    Theme.of(context).brightness == Brightness.light
                        ? Brightness.dark
                        : Brightness.light,
                statusBarColor: Colors.transparent,
              ),
            ),
          ],
        ),
      );
    }
  }
  