Skip to content
Snippets Groups Projects
overview.dart 5.61 KiB
Newer Older
import 'package:flutter/material.dart';
import 'package:mobileeventlog/datamodel.dart';
import 'package:mobileeventlog/sensorconnector.dart';
import 'package:url_launcher/url_launcher.dart';

class Overview extends StatelessWidget {
  const Overview({Key? key}) : super(key: key);

  Widget _buildLegalInformationPopupDialog(BuildContext context){
    return AlertDialog(
      content: SingleChildScrollView(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            const Text('Alfred Wegener Institute, Helmholtz Centre for Polar and Marine '
                'Research',  style: TextStyle(
                fontWeight: FontWeight.bold)
            ),
            const Text(
                '\nAm Handelshafen 12\n27570 Bremerhaven Germany\n'
                    '+49 (0)471 4831-0, info@awi.de'
            ),
            InkWell(
                child: const Text('www.awi.de',
                  style: TextStyle(
                    color: Colors.blueAccent,
                    decoration: TextDecoration.underline,
                  ),
                ),
                onTap: () => launchUrl(Uri.parse('https://www.awi.de'))
            ),
            const Text('\nThe Alfred Wegener Institute is a foundation under public law '
                '(Stiftung des öffentlichen Rechts). The AWI is a member of the '
                'Helmholtz Association of German Research Centres.\n'),
            InkWell(
                child: const Text('Legal Notices',
                  style: TextStyle(
                    color: Colors.blueAccent,
                    decoration: TextDecoration.underline,
                  ),
                ),
                onTap: () => launchUrl(Uri.parse('https://registry.o2a-data.de/?site=legal'))
            ),

            InkWell(
                child: const Text('\nPrivacy',
                  style: TextStyle(
                    color: Colors.blueAccent,
                    decoration: TextDecoration.underline,
                  ),
                ),
                onTap: () => launchUrl(Uri.parse('https://registry.o2a-data.de/?site=privacy'))
            ),
          ],
        ),
      ),
      actions: <Widget>[
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
          child: const Text('Close'),
        ),
      ],
    );
  }


  Widget _buildPopupInfoDialog(BuildContext context) {
    SensorConnector sensorConnector = SensorConnector();

    return AlertDialog(
      content: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          const Icon( Icons.copyright_outlined),
          const Text('Alfred Wegener Institute'),
          const Text('Data Logistics Support'),
          const SizedBox(height: 15),
          const Text('Maximilian Betz'),
          const SizedBox(height: 0),
          const Text('o2a-support@awi.de'),
          const SizedBox(height: 15),
          const Text('API Endpoint:'),
          Text(sensorConnector.baseUrl),
          const SizedBox(height: 15),
          Text('Version: ' + getVersion()),
          Text('Build-Number: ' + getBuildNumber()),
        ],
      ),
      actions: <Widget>[
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
            showDialog(
              barrierDismissible: false,
              context: context,
              builder: (BuildContext context) => _buildLegalInformationPopupDialog(context),
            );
          child: const Text('Legal Notices'),
        ),
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
          child: const Text('Close'),
        ),
      ],
    );
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Mobile Event Log'),
        actions: [
          IconButton(
              icon: const Icon(
                  Icons.info,
                  size: 34.0),
              onPressed: (){
                showDialog(
                  barrierDismissible: false,
                  context: context,
                  builder: (BuildContext context) => _buildPopupInfoDialog(context),
                );
              }
          ),
        ],
      ),
      body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              const SizedBox(height: 10),
              Expanded(
                child: ElevatedButton(
                  child: const Text('Add Event', style: TextStyle(fontSize: 36)),
                  onPressed: () {
                    Navigator.pushNamed(context, '/second');
                  },
                ),
              const SizedBox(height: 10),
              Expanded(
                child: ElevatedButton(
                  child: const Text('View & Sync', style: TextStyle(fontSize: 36)),
                  onPressed: () {
                    Navigator.pushNamed(context, '/third');
                  },
                ),
              const SizedBox(height: 10),
              Expanded(
                child: ElevatedButton(
                  child: const Text('Configuration', style: TextStyle(fontSize: 36)),
                  onPressed: () {
                    Navigator.pushNamed(context, '/forth');
                  },
                ),
              const SizedBox(height: 10),