ELEC60013-ES-CW1/lib/view/steps/steps_page.dart

51 lines
1.5 KiB
Dart
Raw Normal View History

2022-02-09 17:52:00 +00:00
import 'package:flutter/material.dart';
import 'package:leg_barkr_app/model/steps_series.dart';
2022-02-14 20:19:04 +00:00
import 'package:leg_barkr_app/service/steps_service.dart';
2022-02-09 17:52:00 +00:00
import 'package:leg_barkr_app/view/steps/steps_chart.dart';
2022-02-09 18:29:27 +00:00
import 'package:leg_barkr_app/view/steps/steps_today.dart';
2022-02-09 17:52:00 +00:00
class StepsPage extends StatefulWidget {
const StepsPage({ Key? key }) : super(key: key);
@override
_StepsPageState createState() => _StepsPageState();
}
class _StepsPageState extends State<StepsPage> {
2022-02-10 11:06:37 +00:00
// Dummy metrics
2022-02-09 17:52:00 +00:00
final List<StepsSeries> data = [
StepsSeries(DateTime.utc(2022, 2, 9), 9867),
StepsSeries(DateTime.utc(2022, 2, 8), 8123),
StepsSeries(DateTime.utc(2022, 2, 7), 10234),
StepsSeries(DateTime.utc(2022, 2, 6), 6521),
StepsSeries(DateTime.utc(2022, 2, 5), 1021),
StepsSeries(DateTime.utc(2022, 2, 4), 10567),
StepsSeries(DateTime.utc(2022, 2, 3), 7500)
];
2022-02-14 20:19:04 +00:00
Future<int> onStepsRetrieved() async{
return await StepsService().getStepsToday("132-567-001");
}
2022-02-09 17:52:00 +00:00
@override
Widget build(BuildContext context) {
2022-02-14 20:19:04 +00:00
onStepsRetrieved();
2022-02-09 18:29:27 +00:00
return Padding(
padding: EdgeInsets.fromLTRB(0.0, 50.0, 10.0, 0.0),
2022-02-14 20:19:04 +00:00
child: FutureBuilder(
future: onStepsRetrieved(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
StepsToday(snapshot.data),
new Expanded(child: StepsChart(data))
],
);
},
2022-02-09 18:29:27 +00:00
)
2022-02-09 17:52:00 +00:00
);
}
}