@@ -20,6 +20,7 @@ import 'package:notredame/core/constants/preferences_flags.dart';
2020import 'package:notredame/core/constants/urls.dart' ;
2121import 'package:notredame/core/models/course_activity.dart' ;
2222import 'package:notredame/core/constants/discovery_ids.dart' ;
23+ import 'package:notredame/core/constants/progress_bar_text_options.dart' ;
2324
2425// UTILS
2526import 'package:notredame/core/utils/utils.dart' ;
@@ -34,7 +35,10 @@ class DashboardView extends StatefulWidget {
3435 _DashboardViewState createState () => _DashboardViewState ();
3536}
3637
37- class _DashboardViewState extends State <DashboardView > {
38+ class _DashboardViewState extends State <DashboardView >
39+ with TickerProviderStateMixin {
40+ Text progressBarText;
41+
3842 @override
3943 void initState () {
4044 super .initState ();
@@ -95,6 +99,8 @@ class _DashboardViewState extends State<DashboardView> {
9599
96100 default :
97101 }
102+
103+ setText (model);
98104 }
99105
100106 return cards;
@@ -185,22 +191,37 @@ class _DashboardViewState extends State<DashboardView> {
185191 padding: const EdgeInsets .fromLTRB (17 , 10 , 15 , 20 ),
186192 child: ClipRRect (
187193 borderRadius: const BorderRadius .all (Radius .circular (10 )),
188- child: LinearProgressIndicator (
189- value: model.progress,
190- minHeight: 30 ,
191- valueColor: const AlwaysStoppedAnimation <Color >(
192- AppTheme .gradeGoodMax),
193- backgroundColor: AppTheme .etsDarkGrey,
194+ child: GestureDetector (
195+ onTap: () => setState (
196+ () => setState (() {
197+ model.changeProgressBarText ();
198+ setText (model);
199+ }),
200+ ),
201+ child: LinearProgressIndicator (
202+ value: model.progress,
203+ minHeight: 30 ,
204+ valueColor: const AlwaysStoppedAnimation <Color >(
205+ AppTheme .gradeGoodMax),
206+ backgroundColor: AppTheme .etsDarkGrey,
207+ ),
194208 ),
195209 ),
196210 ),
197- Container (
198- padding: const EdgeInsets .only (top: 16 ),
199- child: Center (
200- child: Text (
201- AppIntl .of (context).progress_bar_message (
202- model.sessionDays[0 ], model.sessionDays[1 ]),
203- style: const TextStyle (color: Colors .white),
211+ GestureDetector (
212+ onTap: () => setState (() {
213+ model.changeProgressBarText ();
214+ setText (model);
215+ }),
216+ child: Container (
217+ padding: const EdgeInsets .only (top: 16 ),
218+ child: Center (
219+ child: progressBarText ??
220+ Text (
221+ AppIntl .of (context).progress_bar_message (
222+ model.sessionDays[0 ], model.sessionDays[1 ]),
223+ style: const TextStyle (color: Colors .white),
224+ ),
204225 ),
205226 ),
206227 ),
@@ -215,6 +236,33 @@ class _DashboardViewState extends State<DashboardView> {
215236 ]),
216237 );
217238
239+ void setText (DashboardViewModel model) {
240+ if (model.sessionDays[0 ] == 0 || model.sessionDays[1 ] == 0 ) {
241+ return ;
242+ }
243+
244+ if (model.currentProgressBarText ==
245+ ProgressBarText .daysElapsedWithTotalDays) {
246+ progressBarText = Text (
247+ AppIntl .of (context)
248+ .progress_bar_message (model.sessionDays[0 ], model.sessionDays[1 ]),
249+ style: const TextStyle (color: Colors .white),
250+ );
251+ } else if (model.currentProgressBarText == ProgressBarText .percentage) {
252+ progressBarText = Text (
253+ AppIntl .of (context).progress_bar_message_percentage (
254+ ((model.sessionDays[0 ] / model.sessionDays[1 ]) * 100 ).round ()),
255+ style: const TextStyle (color: Colors .white),
256+ );
257+ } else {
258+ progressBarText = Text (
259+ AppIntl .of (context).progress_bar_message_remaining_days (
260+ model.sessionDays[1 ] - model.sessionDays[0 ]),
261+ style: const TextStyle (color: Colors .white),
262+ );
263+ }
264+ }
265+
218266 Widget _buildTodayScheduleCard (
219267 DashboardViewModel model, PreferencesFlag flag) {
220268 return DismissibleCard (
0 commit comments