import 'dart:math';

import 'package:flutter/material.dart';

import 'package:puissance4/cpu.dart';
import 'package:puissance4/match_page.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
      ),
      backgroundColor: Colors.blue,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisSize: MainAxisSize.max,
          children: <Widget>[
            TextButton(
              style: TextButton.styleFrom(
                backgroundColor: Colors.yellow,
                padding: const EdgeInsets.all(15),
              ),
              child: Text(
                '☺️ FACILE',
                style:
                    Theme.of(context).textTheme.headlineMedium?.copyWith(color: Colors.black),
              ),
              onPressed: () {
                Navigator.pushNamed(
                  context,
                  '/match',
                  arguments: {
                    'mode': Mode.pvc,
                    'cpu': DumbCpu(Random().nextBool() ? Color.red : Color.yellow),
                  },
                );
              },
            ),
            TextButton(
              style: TextButton.styleFrom(
                backgroundColor: Colors.red,
                padding: const EdgeInsets.all(15),
              ),
              child: Text(
                '🤔 DIFFICILE',
                style:
                    Theme.of(context).textTheme.headlineMedium?.copyWith(color: Colors.white),
              ),
              onPressed: () {
                Navigator.pushNamed(
                  context,
                  '/match',
                  arguments: {
                    'mode': Mode.pvc,
                    'cpu': HarderCpu(Random().nextBool() ? Color.red : Color.yellow),
                  },
                );
              },
            ),
            TextButton(
              style: TextButton.styleFrom(
                backgroundColor: Colors.deepPurpleAccent,
                padding: const EdgeInsets.all(15),
              ),
              child: Text(
                '🤯 TRES DIFFICILE',
                style:
                    Theme.of(context).textTheme.headlineMedium?.copyWith(color: Colors.white),
              ),
              onPressed: () {
                Navigator.pushNamed(
                  context,
                  '/match',
                  arguments: {
                    'mode': Mode.pvc,
                    'cpu': HardestCpu(Random().nextBool() ? Color.red : Color.yellow),
                  },
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}