From 0cad0dc8d552e936dd3240bdc0b0a0f4b26affec Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Sat, 21 Mar 2020 15:50:46 -0700 Subject: [PATCH] Fix checkup submission build errors --- lib/src/ui/screens/checkup/checkup.dart | 20 ++++++++++++++----- lib/src/ui/screens/checkup/steps/intro.dart | 1 - .../ui/screens/checkup/steps/subjective.dart | 1 - .../ui/screens/checkup/steps/temperature.dart | 1 - 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/src/ui/screens/checkup/checkup.dart b/lib/src/ui/screens/checkup/checkup.dart index a294e1a..c61694d 100644 --- a/lib/src/ui/screens/checkup/checkup.dart +++ b/lib/src/ui/screens/checkup/checkup.dart @@ -20,6 +20,7 @@ class _CheckupScreenState extends State { // Storing the page controller at this level so that we can access it // across the entire checkup experience PageController _pageController; + bool _showLoadingAssessmentHUD = false; @override void initState() { @@ -88,10 +89,8 @@ class _CheckupScreenState extends State { case CheckupStateInProgress: return CheckupLoadedBody(); case CheckupStateCompleting: - return Container(); case CheckupStateCompleted: - _handleCheckupCompletion(preferencesState, checkupState); - return null; + return Container(); default: return _getErrorBody(); } @@ -103,12 +102,23 @@ class _CheckupScreenState extends State { builder: (context, state) { final PreferencesState preferencesState = state; - return BlocBuilder( + return BlocConsumer( + listener: (context, state) { + if (state is CheckupStateCompleting) { + if (!_showLoadingAssessmentHUD) { + setState(() { + _showLoadingAssessmentHUD = true; + }); + } + } else if (state is CheckupStateCompleted) { + _handleCheckupCompletion(preferencesState, state); + } + }, builder: (context, state) { final CheckupState checkupState = state; return WidgetHUD( - showHUD: checkupState is CheckupStateCompleting, + showHUD: _showLoadingAssessmentHUD, hud: HUD(label: 'Loading your assessment'), builder: (context) { return ChangeNotifierProvider.value( diff --git a/lib/src/ui/screens/checkup/steps/intro.dart b/lib/src/ui/screens/checkup/steps/intro.dart index 4e46467..602474a 100644 --- a/lib/src/ui/screens/checkup/steps/intro.dart +++ b/lib/src/ui/screens/checkup/steps/intro.dart @@ -4,7 +4,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:coronavirus_diary/src/blocs/checkup/checkup.dart'; -import 'package:coronavirus_diary/src/ui/router.dart'; import 'index.dart'; class IntroStep extends StatefulWidget implements CheckupStep { diff --git a/lib/src/ui/screens/checkup/steps/subjective.dart b/lib/src/ui/screens/checkup/steps/subjective.dart index 3e2a043..2e0e008 100644 --- a/lib/src/ui/screens/checkup/steps/subjective.dart +++ b/lib/src/ui/screens/checkup/steps/subjective.dart @@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:coronavirus_diary/src/blocs/checkup/checkup.dart'; import 'package:coronavirus_diary/src/blocs/questions/questions.dart'; -import 'package:coronavirus_diary/src/ui/router.dart'; import 'package:coronavirus_diary/src/ui/widgets/questions/question_view.dart'; import 'package:coronavirus_diary/src/ui/utils/checkups.dart'; import 'index.dart'; diff --git a/lib/src/ui/screens/checkup/steps/temperature.dart b/lib/src/ui/screens/checkup/steps/temperature.dart index e7354c3..0bb0616 100644 --- a/lib/src/ui/screens/checkup/steps/temperature.dart +++ b/lib/src/ui/screens/checkup/steps/temperature.dart @@ -4,7 +4,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:coronavirus_diary/src/blocs/checkup/checkup.dart'; -import 'package:coronavirus_diary/src/ui/router.dart'; import 'package:coronavirus_diary/src/ui/widgets/tutorial_step.dart'; import 'package:coronavirus_diary/src/ui/utils/checkups.dart'; import 'index.dart';