import 'package:flutter/material.dart';

import 'widgets/news_grid.dart';
import 'widgets/news_list.dart';

class NewsScreen extends StatefulWidget {
  const NewsScreen({super.key});

  @override
  State<NewsScreen> createState() => _NewsScreenState();
}

class _NewsScreenState extends State<NewsScreen> {
  bool _isGrid = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Tagesschau News'),
        actions: [
          PopupMenuButton(itemBuilder: (context) {
            return const [
              PopupMenuItem(
                value: false,
                child: Text('List'),
              ),
              PopupMenuItem(
                value: true,
                child: Text('Grid'),
              ),
            ];
          }, onSelected: (bool value) {
            setState(() {
              _isGrid = value;
            });
          }),
        ],
      ),
      body: (_isGrid) ? NewsGrid() : NewsList(),
    );
  }
}
