mirrored_repositories/flutter_schedule_app/lib/modules
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'controllers/announcements_carrousel_controller.dart';
import 'controllers/initial_announcements_controller.dart';

import 'widgets/widgets.dart';
import '../../app/utils/responsive_util.dart';

class InitialInformationPage extends GetWidget {
  const InitialInformationPage({super.key});

  @override
  Widget build(BuildContext context) {
    final ResponsiveUtil resp = ResponsiveUtil.of(context);
    final AnnouncementsCarrouselController carrouselController = Get.find();
    final InitialAnnouncementsController announcesController = Get.find();

    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Center(
        child: ConstrainedBox(
          constraints: const BoxConstraints(maxWidth: 600),
          child: Stack(
            children: [
              SizedBox(
                height: resp.height,
                width: resp.width,
                child: Obx(
                  () => AnnouncementsList(
                    announcements: announcesController.announces,
                    isLoaded: !announcesController.isLoading.value,
                    onNewPageCallback: (newPage) =>
                        carrouselController.setNewIndex(newPage),
                  ),
                ),
              ),
              // Dots
              Positioned.fill(
                top: resp.hp(95),
                child: Obx(
                  () => Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children:
                        List.generate(announcesController.quantity + 1, (x) {
                      final bool isCurrentPage =
                          x == carrouselController.currentIndex.value;
                      final bool isFinalElement =
                          x == announcesController.quantity;

                      return DotIndicator(
                        isFinalElement: isFinalElement,
                        isCurrentPage: isCurrentPage,
                      );
                    }),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
