import 'package:flutter/material.dart';

import 'detail_hero_panel.dart';
import '../model/detail_view_state.dart';
import '../../../shared/widgets/app_loading_ring.dart';


class DetailViewRenderer extends StatelessWidget {
  final DetailViewState state;

  const DetailViewRenderer({super.key, required this.state});

  @override
  Widget build(BuildContext context) {
    final hero = state.hero;
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        DetailHeroPanel(
          title: hero.title,
          logoUrl: hero.logoUrl,
          posterUrl: hero.posterUrl,
          imageHeaders: hero.imageHeaders,
          rating: hero.rating,
          metaParts: hero.metaParts,
          genres: hero.genres,
          overview: hero.overview,
          tagline: hero.tagline,
          actions: hero.actions,
        ),
        for (final section in state.sections) section.child,
        if (state.showLoadingBelowHero)
          const Padding(
            padding: EdgeInsets.symmetric(vertical: 32),
            child: Center(child: AppLoadingRing()),
          ),
        const SizedBox(height: 32),
      ],
    );
  }
}
