import 'package:flutter/material.dart';
import 'package:tp2/exo2.dart';
import 'exo1.dart';


class Exos {
  final String title;
  final String description;
  final dynamic exo;

  const Exos(this.title, this.description, this.exo);
}


void main() {
  runApp(
    MaterialApp(
      title: 'placeholder',
      home: ExoScreen(
        exos: [
          Exos(
            'Exercice 1',
            'A description of what needs to be done for Todo ',
            Exo1()
          ),
          Exos(
            'Exercice 2',
            'A description of what needs to be done for Todo ',
            Exo2()
          ),
          // Next exo
        ],
      ),
    ),
  );
}


class ExoScreen extends StatelessWidget {

  final List<Exos> exos;

  const ExoScreen({super.key, required this.exos});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Exercices')),
      body: ListView.builder(
        itemCount: exos.length,
        itemBuilder: (context, index) {return ListTile(
          title: Text(exos[index]. title),
          // When a user taps the ListTile, navigate to the DetailScreen.
          // Notice that you're not only creating a DetailScreen, you're
          // also passing the current todo through to it.
          onTap: () {
            Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => exos[index].exo),
            );
          },
        );},
      ),
    );
  }
}