import 'dart:math';

import 'package:flutter/material.dart';
import 'package:puissance4/cpu.dart';

import 'match_page.dart';

class CpuLevelPage extends StatelessWidget {
  @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: EdgeInsets.all(15),
              ),
              child: Text(
                '☺️ FACILE',
                style:
                    Theme.of(context).textTheme.headline4?.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: EdgeInsets.all(15),
              ),
              child: Text(
                '🤔 DIFFICILE',
                style:
                    Theme.of(context).textTheme.headline4?.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: EdgeInsets.all(15),
              ),
              child: Text(
                '🤯 TRES DIFFICILE',
                style:
                    Theme.of(context).textTheme.headline4?.copyWith(color: Colors.white),
              ),
              onPressed: () {
                Navigator.pushNamed(
                  context,
                  '/match',
                  arguments: {
                    'mode': Mode.PVC,
                    'cpu': HardestCpu(Random().nextBool() ? Color.RED : Color.YELLOW),
                  },
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}