From 957add6b81b223cde425d962322ec472fbc6f7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20E=2E=20Bermonti-P=C3=A9rez?= Date: Wed, 29 May 2024 14:43:12 -0400 Subject: [PATCH 1/2] improve: Use rest instructions provided by config improve: Require rest instructions in config improve: Use restInstructions from config refactor(example): Pass rest instructions --- example/lib/main.dart | 25 +++++++++++++++++++ .../components/config/user_config.dart | 7 ++++++ .../components/rest/rest_view.dart | 13 +++------- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 157507d..9a098b3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -82,6 +82,7 @@ class _HomePageState extends State { participantID: participantID, sessionID: sessionID, sessionType: SessionType.practice, + restInstructions: const RestInstructions(), ); // Setup task task = DigitSpanTask(config: practiceConfig); @@ -96,6 +97,7 @@ class _HomePageState extends State { participantID: participantID, sessionID: sessionID, sessionType: SessionType.experimental, + restInstructions: const RestInstructions(), ); task = DigitSpanTask(config: experimentalConfig); await Get.to(StartPage()); @@ -111,6 +113,7 @@ class _HomePageState extends State { stimList: ['901234'], participantID: participantID, sessionID: sessionID, + restInstructions: const RestInstructions(), sessionType: SessionType.experimental, ); final task = DigitSpanTask(config: config); @@ -150,3 +153,25 @@ class StartPage extends StatelessWidget { ); } } + +class RestInstructions extends StatelessWidget { + const RestInstructions({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Text( + 'Toma un descanso', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 15), + Text( + 'Respira profundo antes de continuar', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 25), + ], + ); + } +} diff --git a/lib/src/digit_span_task/components/config/user_config.dart b/lib/src/digit_span_task/components/config/user_config.dart index 8d40886..07d9613 100644 --- a/lib/src/digit_span_task/components/config/user_config.dart +++ b/lib/src/digit_span_task/components/config/user_config.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:get/get_state_manager/get_state_manager.dart'; import 'package:digit_span_tasks/src/digit_span_task/randomize.dart'; @@ -30,11 +31,17 @@ class UserConfig extends GetxController { /// either either practice or experimental. final SessionType sessionType; + /// Instructions to be presented during the rest periods. + /// + /// Any [Widget] can be used. + final Widget restInstructions; + UserConfig({ required stimList, required this.sessionID, required this.participantID, required this.sessionType, + required this.restInstructions, }) { this.stimList = randomizeDigitsInSets(stimList); } diff --git a/lib/src/digit_span_task/components/rest/rest_view.dart b/lib/src/digit_span_task/components/rest/rest_view.dart index 1402dc1..d878afd 100644 --- a/lib/src/digit_span_task/components/rest/rest_view.dart +++ b/lib/src/digit_span_task/components/rest/rest_view.dart @@ -1,3 +1,4 @@ +import 'package:digit_span_tasks/src/digit_span_task/components/config/ds_config.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:digit_span_tasks/src/digit_span_task/components/rest/rest_controller.dart'; @@ -7,6 +8,7 @@ class RestView extends StatelessWidget { RestView({super.key}); final RestController _restController = Get.put(RestController()); + final DSConfig _config = Get.find(); @override Widget build(BuildContext context) { @@ -17,16 +19,7 @@ class RestView extends StatelessWidget { child: Screen( children: Column( children: [ - Text( - 'Toma un descanso', - style: Theme.of(context).textTheme.titleLarge, - ), - const SizedBox(height: 15), - Text( - 'Respira profundo antes de continuar', - style: Theme.of(context).textTheme.titleLarge, - ), - const SizedBox(height: 25), + _config.userConfig.restInstructions, ElevatedButton( onPressed: () => _restController.toNextScreen(), child: Text( From 99922feae131dd90479ededa977e202121a1b15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20E=2E=20Bermonti-P=C3=A9rez?= Date: Wed, 29 May 2024 14:56:05 -0400 Subject: [PATCH 2/2] test: Fix tests --- test/src/digit_span_task/components/data/data_manager_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/src/digit_span_task/components/data/data_manager_test.dart b/test/src/digit_span_task/components/data/data_manager_test.dart index 09e509d..7f3843b 100644 --- a/test/src/digit_span_task/components/data/data_manager_test.dart +++ b/test/src/digit_span_task/components/data/data_manager_test.dart @@ -1,6 +1,7 @@ import 'package:digit_span_tasks/digit_span_tasks.dart'; import 'package:digit_span_tasks/src/digit_span_task/components/config/ds_config.dart'; import 'package:digit_span_tasks/src/digit_span_task/components/data/data_manager.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:get/get.dart'; import 'package:cognitive_data/cognitive_data.dart'; @@ -21,6 +22,7 @@ void main() { participantID: participantID, sessionID: '001', sessionType: SessionType.practice, + restInstructions: Text(''), ), ), );