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

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

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

class _ReportsOverviewScreenState extends State<ReportsOverviewScreen> {
  final ScrollController _scrollController = ScrollController();

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(translate(LocalizationKeys.reports_title)),
      ),
      drawer:
          const Navigation(currentLocation: ReportsOverviewScreen.routeName),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Expanded(
            child: GridView.count(
              crossAxisCount: 2,
              children: [
                GestureDetector(
                  onTap: () => Navigator.pushNamed(context, Routes.dailyChart),
                  child: Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: Card(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Padding(
                            padding: const EdgeInsets.all(10.0),
                            child: Icon(Icons.today, size: 50, color: Theme.of(context).textTheme.subtitle2?.color),
                          ),
                          Text(
                            translate(LocalizationKeys.reports_sections_dailyReport).toUpperCase(),
                            style: Theme.of(context).textTheme.subtitle2,
                            textAlign: TextAlign.center
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () => showDialog(
                    context: context,
                    builder: (context) => const ExportDialog(),
                  ),
                  child: Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: Card(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Padding(
                            padding: const EdgeInsets.all(10.0),
                            child: Icon(Icons.today, size: 50, color: Theme.of(context).textTheme.subtitle2?.color),
                          ),
                          Text(
                            translate(LocalizationKeys.reports_sections_pdfReport).toUpperCase(),
                            style: Theme.of(context).textTheme.subtitle2,
                            textAlign: TextAlign.center
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
