data_widget.dart 2.45 KB
Newer Older
1
import 'package:flutter/cupertino.dart';
2 3
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
4
import 'package:geolocator/geolocator.dart';
5

6 7
import 'package:logair_application/logic/handlers/data_handler.dart';
import 'package:logair_application/logic/handlers/position_handler.dart';
8
import 'package:logair_application/ui/carousel_card.dart';
9
import 'package:logair_application/ui/components/data_tile.dart';
10
import 'package:logair_application/ui/components/graph/graph.dart';
11 12 13 14 15

class DataWidget extends StatelessWidget {
  DataWidget();

  @override
Nicolas Richard Walter Boeckh's avatar
Nicolas Richard Walter Boeckh committed
16
  Widget build(BuildContext context) {
17
    Widget widget = Center(
18 19 20 21
      child: SingleChildScrollView(
        child: Column(
          children: [
            // Local data (Chart + Data points)
22
            Graph(),
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
            DataTile(DataHandler().getDataStream()),
            // Bar (Locations + Add new -> Pop to new route)
            Container(
              color: Colors.grey,
              child: Row(
                children: [
                  Expanded(
                    child: Text(
                        'Other Locations',
                        textAlign: TextAlign.center,
                    ),
                  ),
                  IconButton(
                    onPressed: () => {},
                    icon: Icon(Icons.add),
                  )
                ],
              ),
            ),
            SingleChildScrollView(
              child: Column(
                children: [
                  
                ],
              ),
            ),
            // Locations
50 51 52 53 54
            Container(
              padding: EdgeInsets.symmetric(horizontal: 3),
              height: 300,
              child: Column(
                children: [
55
                  Spacer(flex: 1), 
56 57 58 59
                  StreamBuilder<Position>(
                    stream: PositionHandler().getCurrentOrLastPosition(),
                    builder: (context, snapshot) {
                      Position data = snapshot.data;
60 61 62
                      if (data != null)
                        return Text('Latitude ${data.latitude} | Longitude ${data.longitude}');
                      else return Text('Latitude N/A | Longitude N/A');
63 64
                    },
                  ),
65
                  Spacer(flex: 1), 
66 67
                ],
              ),
68
            )
69 70
          ],
        )
71
      )
72
    );
73
    return CarouselCard(child: widget);
74
  }
75
}