Skip to content

Commit

Permalink
Merge pull request #128 from mario-bermonti:mario-bermonti/issue127
Browse files Browse the repository at this point in the history
Require rest instructions and improve 'continue button' text
  • Loading branch information
mario-bermonti authored May 29, 2024
2 parents f47095b + 99922fe commit ed2940a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
25 changes: 25 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class _HomePageState extends State<HomePage> {
participantID: participantID,
sessionID: sessionID,
sessionType: SessionType.practice,
restInstructions: const RestInstructions(),
);
// Setup task
task = DigitSpanTask(config: practiceConfig);
Expand All @@ -96,6 +97,7 @@ class _HomePageState extends State<HomePage> {
participantID: participantID,
sessionID: sessionID,
sessionType: SessionType.experimental,
restInstructions: const RestInstructions(),
);
task = DigitSpanTask(config: experimentalConfig);
await Get.to(StartPage());
Expand All @@ -111,6 +113,7 @@ class _HomePageState extends State<HomePage> {
stimList: ['901234'],
participantID: participantID,
sessionID: sessionID,
restInstructions: const RestInstructions(),
sessionType: SessionType.experimental,
);
final task = DigitSpanTask(config: config);
Expand Down Expand Up @@ -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),
],
);
}
}
7 changes: 7 additions & 0 deletions lib/src/digit_span_task/components/config/user_config.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
}
Expand Down
13 changes: 3 additions & 10 deletions lib/src/digit_span_task/components/rest/rest_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) {
Expand All @@ -17,16 +19,7 @@ class RestView extends StatelessWidget {
child: Screen(
children: Column(
children: <Widget>[
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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,6 +22,7 @@ void main() {
participantID: participantID,
sessionID: '001',
sessionType: SessionType.practice,
restInstructions: Text(''),
),
),
);
Expand Down

0 comments on commit ed2940a

Please sign in to comment.