Commit 54e8571e authored by Administrator's avatar Administrator

back to storing laps and events individually, showing progress in flashbar

parent 0471292f
This diff is collapsed.
......@@ -11,7 +11,6 @@ class Event {
DbEvent db;
Activity activity;
int index;
String uuid;
Event.fromDb(this.db);
......
......@@ -10,11 +10,11 @@ class Lap {
Activity activity;
int index;
List<Event> _records;
String uuid;
Lap({DataMessage dataMessage, this.activity, this.uuid}) {
Lap({DataMessage dataMessage, this.activity, int eventsId}) {
db = DbLap()
..activitiesId = activity.db.id
..eventsId = eventsId
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..startTime = dateTimeFromStrava(dataMessage.get('start_time'))
..startPositionLat = dataMessage.get('start_position_lat')
......
......@@ -101,28 +101,13 @@ class _DashboardState extends State<Dashboard> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RaisedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
athlete.readCredentials();
return ListActivitiesScreen(
athlete: athlete);
}),
);
},
onPressed: () => navigateToListActivitiesScreen(
athlete: athlete),
child: Text("Analyze"),
),
RaisedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
athlete.readCredentials();
return EditAthleteScreen(athlete: athlete);
}),
);
},
onPressed: () =>
navigateToEditAthleteScreen(athlete: athlete),
child: MyIcon.edit,
),
],
......@@ -137,4 +122,24 @@ class _DashboardState extends State<Dashboard> {
}),
);
}
navigateToListActivitiesScreen({Athlete athlete}) async {
await athlete.readCredentials();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ListActivitiesScreen(athlete: athlete),
),
);
}
navigateToEditAthleteScreen({Athlete athlete}) async {
await athlete.readCredentials();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditAthleteScreen(athlete: athlete),
),
);
}
}
......@@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'package:encrateia/screens/show_activity_screen.dart';
import 'package:encrateia/utils/num_utils.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:flushbar/flushbar.dart';
enum Action { show, parse, download, delete, state }
......@@ -24,21 +25,20 @@ class _ActivitiesListWidgetState extends State<ActivitiesListWidget> {
initState() {
getActivities();
Future<Null>.delayed(
Duration(seconds: 2),
() {
if (widget.athlete.email == null)
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("Strava email not provided yet!"),
backgroundColor: Colors.red,
));
if (widget.athlete.password == null)
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("Strava password not provided yet!"),
backgroundColor: Colors.red,
));
},
);
if (widget.athlete.email == null) {
Flushbar(
message: "Strava email not provided yet!",
duration: Duration(seconds: 3),
backgroundColor: Colors.red,
)..show(context);
}
if (widget.athlete.password == null) {
Flushbar(
message: "Strava password not provided yet!",
duration: Duration(seconds: 3),
backgroundColor: Colors.red,
)..show(context);
}
super.initState();
}
......@@ -117,7 +117,24 @@ class _ActivitiesListWidgetState extends State<ActivitiesListWidget> {
}
Future parse({Activity activity}) async {
await activity.parse(athlete: widget.athlete);
var flushbar = Flushbar(
message: "0% of storing »${activity.db.name}«",
duration: Duration(milliseconds: 1000),
animationDuration: Duration(milliseconds: 1),
titleText: LinearProgressIndicator(value: 0),
)..show(context);
var percentageStream = activity.parse(athlete: widget.athlete);
await for (var value in percentageStream) {
flushbar.dismiss();
flushbar = Flushbar(
titleText: LinearProgressIndicator(value: value/100),
message: "$value% of storing »${activity.db.name}«",
duration: Duration(milliseconds: 1000),
animationDuration: Duration(milliseconds: 1),
)
..show(context);
}
activities = await Activity.all();
setState(() {});
}
......
......@@ -225,6 +225,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.11"
flushbar:
dependency: "direct main"
description:
name: flushbar
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.1"
flutter:
dependency: "direct main"
description: flutter
......
......@@ -23,6 +23,7 @@ dependencies:
charts_flutter: ^0.8.1
uuid: 2.0.4
flushbar: ^1.9.1
dev_dependencies:
flutter_test:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment