Commit dc21eaf9 authored by Stefan Haslinger's avatar Stefan Haslinger

move redownload .fit-file into ShowActivityScreen

parent 3a6588fc
......@@ -247,6 +247,18 @@ class _ShowActivityScreenState extends State<ShowActivityScreen> {
),
onPressed: () => autoTagger(),
),
if (<String>['new', 'downloaded', 'persisted'].contains(widget.activity.db.state))
RaisedButton.icon(
color: MyColor.add,
icon: MyIcon.download,
textColor: MyColor.textColor(backgroundColor: MyColor.add),
label: const Flexible(
child: Text('Redownload .fit'),
),
onPressed: () => download(),
),
if (<String>['new', 'downloaded', 'persisted'].contains(widget.activity.db.state))
RaisedButton.icon(
color: MyColor.delete,
......@@ -335,4 +347,23 @@ class _ShowActivityScreenState extends State<ShowActivityScreen> {
await widget.activity.delete();
Navigator.of(context).pop();
}
Future<void> download({Activity activity}) async {
flushbar = Flushbar<Object>(
message: 'Download .fit-File for »${widget.activity.db.name}«',
duration: const Duration(seconds: 10),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
await widget.activity.download(athlete: widget.athlete);
flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Download finished',
duration: const Duration(seconds: 1),
icon: MyIcon.finishedWhite,
)..show(context);
setState(() {});
}
}
......@@ -18,7 +18,6 @@ enum LapDoubleAttr {
enum ActivityAction {
parse,
download,
}
enum ActivityAttr {
......
......@@ -99,25 +99,6 @@ class _ActivitiesFeedWidgetState extends State<ActivitiesFeedWidget> {
}
}
Future<void> download({Activity activity}) async {
flushbar = Flushbar<Object>(
message: 'Download .fit-File for »${activity.db.name}«',
duration: const Duration(seconds: 10),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
await activity.download(athlete: widget.athlete);
flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Download finished',
duration: const Duration(seconds: 1),
icon: MyIcon.finishedWhite,
)..show(context);
setState(() {});
}
Future<void> parse({Activity activity}) async {
Flushbar<Object> flushbar = Flushbar<Object>(
message: '0% of storing »${activity.db.name}«',
......@@ -150,12 +131,9 @@ class _ActivitiesFeedWidgetState extends State<ActivitiesFeedWidget> {
List<String> actions;
switch (activity.db.state) {
case 'new':
actions = <String>['download'];
break;
case 'downloaded':
case 'persisted':
actions = <String>['parse', 'download'];
actions = <String>['parse'];
break;
}
......@@ -165,9 +143,6 @@ class _ActivitiesFeedWidgetState extends State<ActivitiesFeedWidget> {
case ActivityAction.parse:
parse(activity: activity);
break;
case ActivityAction.download:
download(activity: activity);
break;
}
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<ActivityAction>>[
......@@ -181,17 +156,6 @@ class _ActivitiesFeedWidgetState extends State<ActivitiesFeedWidget> {
],
),
),
if (actions.contains('download'))
PopupMenuItem<ActivityAction>(
value: ActivityAction.download,
child: Row(
children: <Widget>[
MyIcon.download,
const Text(' Download .fit-file'),
],
),
),
],
);
}
......
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