replacing with FlashBar with SnackBar

upgrade-2021-project
Stefan Haslinger 2022-03-09 11:03:54 +01:00
parent 913b740b5b
commit 65a096519c
21 changed files with 447 additions and 311 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/activity.dart';
@ -8,36 +7,50 @@ import '/utils/icon_utils.dart';
Future<void> analyseActivities({
required BuildContext context,
required Athlete athlete,
required Flushbar<Object> flushbar,
}) async {
List<Activity> activities;
activities = await athlete.activities;
int index = 0;
int percent;
flushbar = Flushbar<Object>(
message: 'Calculating...',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Calculating...'),
],
),
),
);
for (final Activity activity in activities) {
index += 1;
await activity.setAverages();
await flushbar.dismiss();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
percent = 100 * index ~/ activities.length;
flushbar = Flushbar<Object>(
titleText: LinearProgressIndicator(value: percent / 100),
message: '$percent% done (recalculating »${activity.name}« )',
duration: const Duration(seconds: 2),
animationDuration: const Duration(milliseconds: 1),
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
content: Row(children: [
CircularProgressIndicator(value: percent / 100),
Text('recalculating »${activity.name}«')
]),
),
);
}
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Averages are now up to date.',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Averages are now up to date.')
],
),
),
);
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/activity.dart';
@ -9,14 +8,19 @@ import '/utils/icon_utils.dart';
Future<void> autoTagging({
required BuildContext context,
required Athlete athlete,
required Flushbar<Object> flushbar,
}) async {
if (await athlete.checkForSchemas()) {
flushbar = Flushbar<Object>(
message: 'Started cleaning up...',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Started cleaning up...'),
],
),
),
);
List<Activity> activities;
activities = await athlete.activities;
@ -24,37 +28,61 @@ Future<void> autoTagging({
int percent;
await TagGroup.deleteAllAutoTags(athlete: athlete);
flushbar = Flushbar<Object>(
message: 'All existing autotaggings have been deleted.',
duration: const Duration(seconds: 2),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('All existing autotaggings have been deleted.'),
],
),
),
);
for (final Activity activity in activities) {
index += 1;
await activity.autoTagger(athlete: athlete);
await flushbar.dismiss();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
percent = 100 * index ~/ activities.length;
flushbar = Flushbar<Object>(
titleText: LinearProgressIndicator(value: percent / 100),
message: '$percent% done (autotagging »${activity.name}« )',
duration: const Duration(seconds: 2),
animationDuration: const Duration(milliseconds: 1),
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
content: Row(
children: [
CircularProgressIndicator(value: percent / 100),
Text('$percent% done (autotagging »${activity.name}« )'),
],
),
),
);
}
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Autotaggings are now up to date.',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Autotaggings are now up to date.'),
],
),
),
);
} else {
flushbar = Flushbar<Object>(
message:
'Please set up Power Zone Schema and Heart Rate Zone Schema first!',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Please set up Power Zone Schema and '
'Heart Rate Zone Schema first!'),
],
),
),
);
}
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/athlete.dart';
@ -7,7 +6,6 @@ import '/utils/my_button.dart';
Future<void> deleteAthlete({
required BuildContext context,
required Athlete? athlete,
required Flushbar<Object> flushbar,
}) {
return showDialog<void>(
context: context,

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/activity.dart';
@ -9,21 +8,30 @@ Future<void> downloadActivity({
required BuildContext context,
required Activity activity,
required Athlete athlete,
required Flushbar<Object> flushbar,
}) async {
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Download .fit-File for »${activity.name}«',
duration: const Duration(seconds: 10),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(children: [
MyIcon.stravaDownloadWhite,
Text('Download .fit-File for »${activity.name}«'),
]),
),
);
await activity.download(athlete: athlete);
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Download finished',
duration: const Duration(seconds: 2),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Download finished'),
],
),
),
);
}

View File

@ -1,6 +1,5 @@
import 'dart:io';
import 'package:another_flushbar/flushbar.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
@ -13,7 +12,6 @@ import '/utils/icon_utils.dart';
Future<void> downloadDemoData({
required BuildContext context,
required Athlete athlete,
required Flushbar<Object>? flushbar,
}) async {
if (await athlete.checkForSchemas()) {
List<Activity> activities;
@ -28,12 +26,17 @@ Future<void> downloadDemoData({
'upper_palatinate_winter_challenge_half_marathon.fit',
];
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
message: 'Downloading Demo data ...',
icon: MyIcon.stravaDownloadWhite,
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
MyIcon.stravaDownloadWhite,
const Text('Downloading Demo data ...'),
],
),
),
);
for (final String filename in fileNames) {
final Activity activity = Activity.fromLocalDirectory(athlete: athlete);
@ -55,27 +58,33 @@ Future<void> downloadDemoData({
context: context,
activity: activity,
athlete: athlete,
flushbar: flushbar,
);
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
message: 'Tagging »${activity.name}«',
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Tagging »${activity.name}«')),
);
await activity.autoTagger(athlete: athlete);
}
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
message: 'Activities imported!',
icon: MyIcon.finishedWhite,
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Activities imported!'),
],
),
),
);
} else {
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
message: 'Please set up Power Zone Schema and Heart'
' Rate Zone Schema first!',
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Please set up Power Zone Schema and Heart'
' Rate Zone Schema first!'),
),
);
}
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/actions/parse_activity.dart';
@ -9,21 +8,33 @@ import '/utils/icon_utils.dart';
Future<void> importActivitiesLocally({
required BuildContext context,
required Athlete athlete,
required Flushbar<Object> flushbar,
}) async {
List<Activity> activities;
flushbar = Flushbar<Object>(
message: 'Importing activities from local directory',
duration: const Duration(seconds: 1),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 1),
content: Row(
children: [
MyIcon.stravaDownloadWhite,
const Text('Importing activities from local directory'),
],
),
),
);
await Activity.importFromLocalDirectory(athlete: athlete);
flushbar = Flushbar<Object>(
message: 'Activities moved into application',
duration: const Duration(seconds: 1),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 1),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Activities moved into application'),
],
),
),
);
activities = await athlete.activities;
final List<Activity> downloadedActivities = activities
@ -38,14 +49,19 @@ Future<void> importActivitiesLocally({
context: context,
activity: activity,
athlete: athlete,
flushbar: flushbar,
);
await activity.autoTagger(athlete: athlete);
}
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Activities imported!',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Activities imported!'),
],
),
),
);
}

View File

@ -1,6 +1,4 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/activity.dart';
import '/models/athlete.dart';
import '/models/log.dart';
@ -9,14 +7,19 @@ Future<void> parseActivity({
required BuildContext context,
required Activity activity,
required Athlete athlete,
required Flushbar<Object>? flushbar,
}) async {
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
message: '0% of storing »${activity.name}«',
titleText: const LinearProgressIndicator(value: 0),
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
const CircularProgressIndicator(value: 0),
Text('storing »${activity.name}«'),
],
),
),
);
Stream<int> percentageStream;
@ -24,20 +27,26 @@ Future<void> parseActivity({
percentageStream = activity.parse(athlete: athlete);
await for (final int value in percentageStream) {
if (value == -2) {
await flushbar?.dismiss();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
} else if (value == -1) {
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
message: 'Analysing »${activity.name}«',
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Analysing »${activity.name}«'),
),
);
} else {
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
titleText: LinearProgressIndicator(value: value / 100),
message: '$value% of storing »${activity.name}«',
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Row(
children: [
CircularProgressIndicator(value: value / 100),
Text('storing »${activity.name}«'),
],
),
),
);
}
}
} catch (exception, stacktrace) {
@ -50,11 +59,12 @@ Future<void> parseActivity({
await log.save();
activity.nonParsable = true;
await activity.save();
await flushbar?.dismiss();
flushbar = Flushbar<Object>(
message: 'Error, see log on home screen for details',
animationDuration: const Duration(milliseconds: 0),
duration: const Duration(seconds: 2),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
duration: Duration(seconds: 2),
content: Text('Error, see log on home screen for details')),
);
}
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/activity.dart';
@ -8,18 +7,26 @@ import '/utils/icon_utils.dart';
Future<void> queryStrava({
required BuildContext context,
required Athlete athlete,
required Flushbar<Object> flushbar,
}) async {
flushbar = Flushbar<Object>(
message: 'Downloading new activities',
duration: const Duration(seconds: 10),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(
children: [MyIcon.stravaDownloadWhite, const Text('Downloading new activities'),
],
),
),
);
await Activity.queryStrava(athlete: athlete);
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Download finished',
duration: const Duration(seconds: 1),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 1),
content: Row(
children: [MyIcon.finishedWhite, const Text('Download finished'),
],
),
),
);
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/actions/download_demo_data.dart';
@ -9,7 +8,6 @@ import '/models/weight.dart';
Future<void> setupDemoAthlete({
required BuildContext context,
required Flushbar<Object>? flushbar,
}) async {
final Athlete athlete = Athlete();
await athlete.setupStandaloneAthlete();
@ -31,7 +29,6 @@ Future<void> setupDemoAthlete({
await downloadDemoData(
context: context,
athlete: athlete,
flushbar: flushbar,
);
await flushbar?.dismiss();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/actions/download_activity.dart';
@ -11,7 +10,6 @@ import '/utils/icon_utils.dart';
Future<void> updateJob({
required BuildContext context,
required Athlete athlete,
required Flushbar<Object> flushbar,
}) async {
List<Activity> activities;
@ -19,7 +17,6 @@ Future<void> updateJob({
await queryStrava(
context: context,
athlete: athlete,
flushbar: flushbar,
);
activities = await athlete.activities;
@ -30,7 +27,6 @@ Future<void> updateJob({
context: context,
activity: activity,
athlete: athlete,
flushbar: flushbar,
);
}
@ -45,22 +41,33 @@ Future<void> updateJob({
context: context,
activity: activity,
athlete: athlete,
flushbar: flushbar,
);
await activity.autoTagger(athlete: athlete);
}
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'You are now up to date!',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('You are now up to date!'),
],
),
),
);
} else {
flushbar = Flushbar<Object>(
message:
'Please set up Power Zone Schema and Heart Rate Zone Schema first!',
duration: const Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Please set up Power Zone Schema and '
'Heart Rate Zone Schema first!'),
],
),
),
);
}
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/actions/setup_demo_athlete.dart';
@ -22,7 +21,6 @@ class OnboardingCreateUserScreen extends StatefulWidget {
class _OnboardingCreateUserScreenState
extends State<OnboardingCreateUserScreen> {
Athlete athlete = Athlete();
Flushbar<Object>? flushbar;
@override
Widget build(BuildContext context) {
@ -57,10 +55,7 @@ class _OnboardingCreateUserScreenState
color: MyColor.primary),
child: const Text('Create Demo User'),
onPressed: () async {
await setupDemoAthlete(
context: context,
flushbar: flushbar,
);
await setupDemoAthlete(context: context);
await Navigator.pushReplacement(
context,
MaterialPageRoute<BuildContext>(

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -52,7 +51,6 @@ class ShowActivityScreen extends StatefulWidget {
}
class _ShowActivityScreenState extends State<ShowActivityScreen> {
Flushbar<Object> flushbar = Flushbar<Object>();
Weight? weight;
List<Widget> get tiles {
@ -479,20 +477,32 @@ class _ShowActivityScreenState extends State<ShowActivityScreen> {
}
Future<void> autoTagger() async {
flushbar = Flushbar<Object>(
message: 'Starting Autotagger',
duration: const Duration(seconds: 10),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(
children: [
MyIcon.stravaDownloadWhite,
const Text('Starting Autotagger'),
],
),
),
);
await widget.activity.autoTagger(athlete: widget.athlete);
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Autotagging finished',
duration: const Duration(seconds: 2),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Autotagging finished'),
],
),
),
);
setState(() {});
}
@ -514,57 +524,81 @@ class _ShowActivityScreenState extends State<ShowActivityScreen> {
}
Future<void> download() async {
flushbar = Flushbar<Object>(
message: 'Download .fit-File for »${widget.activity.name}«',
duration: const Duration(seconds: 10),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(
children: [
MyIcon.stravaDownloadWhite,
Text('Download .fit-File for »${widget.activity.name}«'),
],
),
),
);
await widget.activity.download(athlete: widget.athlete);
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Download finished',
duration: const Duration(seconds: 1),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 1),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Download finished'),
],
),
),
);
await parse();
flushbar = Flushbar<Object>(
message: 'Analysis finished for »${widget.activity.name}«',
duration: const Duration(seconds: 2),
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
content: Text('Analysis finished for »${widget.activity.name}«'),
),
);
}
Future<void> parse() async {
Flushbar<Object> flushbar = Flushbar<Object>(
message: '0% of storing »${widget.activity.name}«',
duration: const Duration(seconds: 10),
animationDuration: const Duration(milliseconds: 0),
titleText: const LinearProgressIndicator(value: 0),
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(
children: [
const CircularProgressIndicator(value: 0),
Text('storing »${widget.activity.name}«'),
],
),
),
);
final Stream<int> percentageStream =
widget.activity.parse(athlete: widget.athlete);
await for (final int value in percentageStream) {
if (value == -2) {
await flushbar.dismiss();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
} else if (value == -1) {
await flushbar.dismiss();
flushbar = Flushbar<Object>(
message: 'Analysing »${widget.activity.name}«',
duration: const Duration(seconds: 1),
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 1),
content: Text('Analysing »${widget.activity.name}«'),
),
);
} else {
await flushbar.dismiss();
flushbar = Flushbar<Object>(
titleText: LinearProgressIndicator(value: value / 100),
message: '$value% of storing »${widget.activity.name}«',
duration: const Duration(seconds: 3),
animationDuration: const Duration(milliseconds: 0),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 3),
content: Row(
children: [
CircularProgressIndicator(value: value / 100),
Text('storing »${widget.activity.name}«'),
],
),
),
);
}
}
setState(() {});

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/actions/analyse_activities.dart';
@ -51,7 +50,6 @@ class ShowAthleteScreen extends StatefulWidget {
}
class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
Flushbar<Object> flushbar = Flushbar<Object>();
Visibility? floatingActionButton;
late bool floatingActionButtonVisible;
@ -172,7 +170,6 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
await importActivitiesLocally(
context: context,
athlete: widget.athlete,
flushbar: flushbar,
);
},
),
@ -227,7 +224,6 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
onPressed: () => deleteAthlete(
context: context,
athlete: widget.athlete,
flushbar: flushbar,
),
),
ElevatedButton.icon(
@ -239,7 +235,6 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
onPressed: () => analyseActivities(
context: context,
athlete: widget.athlete,
flushbar: flushbar,
),
),
ElevatedButton.icon(
@ -251,7 +246,6 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
onPressed: () => autoTagging(
context: context,
athlete: widget.athlete,
flushbar: flushbar,
),
),
ElevatedButton.icon(
@ -261,7 +255,6 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
onPressed: () => downloadDemoData(
context: context,
athlete: widget.athlete,
flushbar: flushbar,
),
),
];
@ -292,7 +285,6 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
updateJob(
context: context,
athlete: widget.athlete,
flushbar: flushbar,
);
setState(() => floatingActionButtonVisible = true);
},

View File

@ -1,6 +1,5 @@
import 'dart:math';
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/activity.dart';
@ -26,7 +25,6 @@ class ActivitiesFeedWidget extends StatefulWidget {
class _ActivitiesFeedWidgetState extends State<ActivitiesFeedWidget> {
List<Activity> activities = <Activity>[];
List<TagGroup> tagGroups = <TagGroup>[];
Flushbar<Object>? flushbar;
bool disposed = false;
@override
@ -201,17 +199,21 @@ class _ActivitiesFeedWidgetState extends State<ActivitiesFeedWidget> {
void showMyFlushbar() {
if (widget.athlete.stravaId != null) {
if (widget.athlete.email == null) {
flushbar = Flushbar<Object>(
message: 'Strava email not provided yet!',
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow[900]!,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
duration: Duration(seconds: 3),
backgroundColor: Colors.yellow,
content: Text('Strava email not provided yet!'),
),
);
} else if (widget.athlete.password == null) {
flushbar = Flushbar<Object>(
message: 'Strava password not provided yet!',
duration: const Duration(seconds: 3),
backgroundColor: Colors.red,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
duration: Duration(seconds: 3),
backgroundColor: Colors.red,
content: Text('Strava password not provided yet!'),
),
);
}
}
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/activity.dart';
@ -20,7 +19,6 @@ class ActivitiesListWidget extends StatefulWidget {
class _ActivitiesListWidgetState extends State<ActivitiesListWidget> {
List<Activity> activities = <Activity>[];
Flushbar<Object>? flushbar;
@override
void initState() {
@ -102,41 +100,62 @@ class _ActivitiesListWidgetState extends State<ActivitiesListWidget> {
}
Future<void> download({required Activity activity}) async {
flushbar = Flushbar<Object>(
message: 'Download .fit-File for »${activity.name}«',
duration: const Duration(seconds: 10),
icon: MyIcon.stravaDownloadWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(
children: [
MyIcon.stravaDownloadWhite,
Text('Download .fit-File for »${activity.name}«'),
],
),
),
);
await activity.download(athlete: widget.athlete);
flushbar = Flushbar<Object>(
message: 'Download finished',
duration: const Duration(seconds: 3),
icon: MyIcon.finishedWhite,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 3),
content: Row(
children: [
MyIcon.finishedWhite,
const Text('Download finished'),
],
),
),
);
setState(() {});
}
Future<void> parse({required Activity activity}) async {
Flushbar<Object> flushbar = Flushbar<Object>(
message: '0% of storing »${activity.name}«',
duration: const Duration(seconds: 10),
animationDuration: const Duration(milliseconds: 1),
titleText: const LinearProgressIndicator(value: 0),
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(
children: [
const CircularProgressIndicator(value: 0),
Text('storing »${activity.name}«'),
],
),
),
);
final Stream<int> percentageStream =
activity.parse(athlete: widget.athlete);
await for (final int value in percentageStream) {
await flushbar.dismiss();
flushbar = Flushbar<Object>(
titleText: LinearProgressIndicator(value: value / 100),
message: '$value% of storing »${activity.name}«',
duration: const Duration(seconds: 3),
animationDuration: const Duration(milliseconds: 1),
)..show(context);
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 3),
content: Row(
children: [
CircularProgressIndicator(value: value / 100),
Text('storing »${activity.name}«'),
],
),
),
);
}
getActivities();
}
@ -149,17 +168,21 @@ class _ActivitiesListWidgetState extends State<ActivitiesListWidget> {
void showMyFlushbar() {
if (widget.athlete.stravaId != null) {
if (widget.athlete.email == null) {
flushbar = Flushbar<Object>(
message: 'Strava email not provided yet!',
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow[900]!,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
duration: Duration(seconds: 3),
backgroundColor: Colors.yellow,
content: Text('Strava email not provided yet!'),
),
);
} else if (widget.athlete.password == null) {
flushbar = Flushbar<Object>(
message: 'Strava password not provided yet!',
duration: const Duration(seconds: 3),
backgroundColor: Colors.red,
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
duration: Duration(seconds: 3),
backgroundColor: Colors.red,
content: Text('Strava password not provided yet!'),
),
);
}
}
}

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/athlete.dart';
@ -22,7 +21,6 @@ class EditStandaloneAthleteWidget extends StatefulWidget {
class _EditStandaloneAthleteWidgetState
extends State<EditStandaloneAthleteWidget> {
Flushbar<Object> flushbar = Flushbar<Object>();
@override
Widget build(BuildContext context) {

View File

@ -1,4 +1,3 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import '/models/athlete.dart';
@ -22,8 +21,6 @@ class EditStravaAthleteWidget extends StatefulWidget {
}
class _EditStravaAthleteWidgetState extends State<EditStravaAthleteWidget> {
Flushbar<Object> flushbar = Flushbar<Object>();
@override
Widget build(BuildContext context) {
return ListView(
@ -86,16 +83,22 @@ class _EditStravaAthleteWidgetState extends State<EditStravaAthleteWidget> {
Future<void> saveStravaUser(BuildContext context) async {
await widget.athlete!.save();
await widget.athlete!.storeCredentials();
flushbar = Flushbar<Object>(
icon: MyIcon.information,
message: 'checking credentials...',
duration: const Duration(seconds: 10),
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 10),
content: Row(
children: [
MyIcon.information,
const Text('checking credentials...'),
],
),
),
);
if (await StravaFitDownload.credentialsAreValid(athlete: widget.athlete!)) {
final List<PowerZoneSchema> powerZoneSchemas =
await widget.athlete!.powerZoneSchemas;
await flushbar.dismiss();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
if (powerZoneSchemas.isEmpty) {
Navigator.pushReplacement(
context,
@ -108,11 +111,17 @@ class _EditStravaAthleteWidgetState extends State<EditStravaAthleteWidget> {
Navigator.of(context).pop();
}
} else {
flushbar = Flushbar<Object>(
icon: MyIcon.error,
message: 'The credentials provided are invalid!',
duration: const Duration(seconds: 5),
)..show(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 5),
content: Row(
children: [
MyIcon.error,
const Text('The credentials provided are invalid!'),
],
),
),
);
}
}
}

View File

@ -1,6 +1,5 @@
import 'dart:math';
import 'package:another_flushbar/flushbar.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
@ -30,7 +29,6 @@ class _IntervalsFeedWidgetState extends State<IntervalsFeedWidget> {
<int, List<encrateia.Interval>>{};
Map<int?, Activity> activityMap = <int, Activity>{};
List<TagGroup> tagGroups = <TagGroup>[];
Flushbar<Object>? flushbar;
bool disposed = false;
@override

View File

@ -15,13 +15,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.0"
another_flushbar:
dependency: "direct main"
description:
name: another_flushbar
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.28"
archive:
dependency: transitive
description:

View File

@ -8,7 +8,6 @@ environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
another_flushbar: ^1.10.28
charts_flutter: ^0.12.0
collection: ^1.14.13
csv: ^5.0.1