import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_chart_box.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_end_side_bar.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_heat_map_box.dart';

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

  static const _padding = EdgeInsetsDirectional.all(32);

  @override
  Widget build(BuildContext context) {
    final height = MediaQuery.sizeOf(context).height;
    return LayoutBuilder(
      builder: (context, constraints) {
        final isMediumOrLess = constraints.maxWidth <= 900;
        if (isMediumOrLess) {
          return SingleChildScrollView(
            padding: _padding,
            child: Column(
              spacing: 32,
              children: [
                SizedBox(height: height * 0.8, child: const OccupancyEndSideBar()),
                SizedBox(height: height * 0.5, child: const OccupancyChartBox()),
                SizedBox(height: height * 0.5, child: const OccupancyHeatMapBox()),
              ],
            ),
          );
        }

        return SingleChildScrollView(
          child: Container(
            padding: _padding,
            height: height * 1,
            child: const Row(
              spacing: 32,
              children: [
                Expanded(
                  flex: 7,
                  child: Column(
                    spacing: 20,
                    children: [
                      Expanded(child: OccupancyChartBox()),
                      Expanded(child: OccupancyHeatMapBox()),
                    ],
                  ),
                ),
                Expanded(flex: 4, child: OccupancyEndSideBar()),
              ],
            ),
          ),
        );
      },
    );
  }
}
