import 'package:flutter/material.dart';
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
import 'package:wolf_3d_flutter/wolf_3d.dart';
import 'package:wolf_dart/screens/episode_screen.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
        itemCount: Wolf3d.I.availableGames.length,
        itemBuilder: (context, i) {
          final WolfensteinData data = Wolf3d.I.availableGames[i];
          final GameVersion version = data.version;

          return Card(
            child: ListTile(
              title: Text(version.name),
              onTap: () {
                Wolf3d.I.setActiveGame(data);
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) => const EpisodeScreen(),
                  ),
                );
              },
            ),
          );
        },
      ),
    );
  }
}
