import 'package:diameter/localization_keys.dart';
import 'package:diameter/navigation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_translate/flutter_translate.dart';

class CategoryOverviewScreen extends StatefulWidget {
  static const String routeName = '/category';
  const CategoryOverviewScreen({Key? key}) : super(key: key);

  @override
  _CategoryOverviewScreenState createState() => _CategoryOverviewScreenState();
}

class _CategoryOverviewScreenState extends State<CategoryOverviewScreen> {
  final ScrollController _scrollController = ScrollController();

  @override
  void dispose() {
    _scrollController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(translate(LocalizationKeys.categories)),
      ),
      drawer:
          const Navigation(currentLocation: CategoryOverviewScreen.routeName),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Expanded(
            child: GridView.count(
              crossAxisCount: 2,
              padding: const EdgeInsets.all(10.0),
              children: [
                GestureDetector(
                  onTap: () => Navigator.pushNamed(context, Routes.mealSources),
                  child: Card(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Padding(
                          padding: const EdgeInsets.all(10.0),
                          child: Icon(Icons.local_grocery_store, size: 50, color: Theme.of(context).textTheme.subtitle2?.color),
                        ),
                        Text(
                          translate(LocalizationKeys.mealSource_title).toUpperCase(),
                          style: Theme.of(context).textTheme.subtitle2,
                          textAlign: TextAlign.center
                        ),
                      ],
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () => Navigator.pushNamed(context, Routes.mealCategories),
                  child: Padding(
                    padding: const EdgeInsets.only(left: 10.0),
                    child: Card(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Padding(
                            padding: const EdgeInsets.all(10.0),
                            child: Icon(Icons.category, size: 50, color: Theme.of(context).textTheme.subtitle2?.color),
                          ),
                          Text(
                            translate(LocalizationKeys.mealCategory_title).toUpperCase(),
                            style: Theme.of(context).textTheme.subtitle2,
                            textAlign: TextAlign.center
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () => Navigator.pushNamed(context, Routes.mealPortionTypes),
                  child: Card(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Padding(
                          padding: const EdgeInsets.all(10.0),
                          child: Icon(Icons.pie_chart, size: 50, color: Theme.of(context).textTheme.subtitle2?.color),
                        ),
                        Text(
                          translate(LocalizationKeys.portionType_title).toUpperCase(),
                          style: Theme.of(context).textTheme.subtitle2,
                          textAlign: TextAlign.center
                        ),
                      ],
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () => Navigator.pushNamed(context, Routes.accuracies),
                  child: Padding(
                    padding: const EdgeInsets.only(left: 10.0),
                    child: Card(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Padding(
                            padding: const EdgeInsets.all(10.0),
                            child: Icon(Icons.architecture, size: 50, color: Theme.of(context).textTheme.subtitle2?.color),
                          ),
                          Text(
                            translate(LocalizationKeys.accuracy_title).toUpperCase(),
                            style: Theme.of(context).textTheme.subtitle2,
                            textAlign: TextAlign.center
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () => Navigator.pushNamed(context, Routes.eventTypes),
                  child: Card(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Padding(
                          padding: const EdgeInsets.all(10.0),
                          child: Icon(Icons.event, size: 50, color: Theme.of(context).textTheme.subtitle2?.color),
                        ),
                        Text(
                          translate(LocalizationKeys.eventType_title).toUpperCase(),
                          style: Theme.of(context).textTheme.subtitle2,
                          textAlign: TextAlign.center
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
