Skip to content

Commit

Permalink
Issue#689 (#969)
Browse files Browse the repository at this point in the history
* Fix issue#689

* Update

* update

* Update pubspec.yaml

* Update weekplan_screen_test.dart
  • Loading branch information
Thuyhaile authored Nov 8, 2023
1 parent 70bb646 commit 76bf9ee
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
35 changes: 16 additions & 19 deletions lib/screens/show_activity_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:api_client/models/pictogram_model.dart';
import 'package:api_client/models/settings_model.dart';
import 'package:api_client/models/weekday_model.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:weekplanner/blocs/activity_bloc.dart';
import 'package:weekplanner/blocs/auth_bloc.dart';
import 'package:weekplanner/blocs/pictogram_image_bloc.dart';
Expand Down Expand Up @@ -624,38 +625,34 @@ class ShowActivityScreen extends StatelessWidget {
BuildContext overallContext,
AsyncSnapshot<bool> timerInitSnapshot,
AsyncSnapshot<WeekplanMode> modeSnapshot,
AsyncSnapshot<SettingsModel> settingsSnapshot) {
AsyncSnapshot<SettingsModel> settingsSnapshot,
) {
return Visibility(
visible: modeSnapshot.data == WeekplanMode.guardian ||
(settingsSnapshot.hasData && !settingsSnapshot.data.lockTimerControl),
child: Flexible(
child: GirafButton(
key: const Key('TimerStopButtonKey'),
onPressed: () {
showDialog<Center>(
context: overallContext,
barrierDismissible: false,
builder: (BuildContext context) {
//Confirmation dialog for stopping the timer.
return GirafConfirmDialog(
key: const Key('TimerStopConfirmDialogKey'),
title: 'Stop Timer',
description: 'Vil du stoppe timeren?',
confirmButtonText: 'Stop',
confirmButtonIcon:
const ImageIcon(AssetImage('assets/icons/stop.png')),
confirmOnPressed: () {
_timerBloc.stopTimer();
Routes().pop(context);
},
);
});
// Directly perform actions without showing the confirmation dialog
_timerBloc.stopTimer();
_showToast('Timeren er blevet stoppet.');
},
icon: const ImageIcon(AssetImage('assets/icons/stop.png')),
),
),
);
}
// Give message after stopping timer
void _showToast(String message) {
Fluttertoast.showToast(
msg: message,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.black,
textColor: Colors.white,
);
}

Widget _deleteButton(
BuildContext overallContext,
Expand Down
5 changes: 1 addition & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ dependencies:
git:
url: https://github.com/aau-giraf/api_client.git
ref: develop


audioplayers: ^1.1.1
auto_size_text: ^3.0.0
csv: ^5.0.1
cupertino_icons: ^1.0.5
data_connection_checker: ^0.3.4

flutter:
sdk: flutter
fluttertoast: ^8.2.2
http: ^0.13.5
image: ^3.2.2
image_picker: ^0.8.6
Expand All @@ -43,7 +41,6 @@ dev_dependencies:
sdk: flutter
mockito: ^5.3.2


flutter:
assets:
- assets/
Expand Down
4 changes: 2 additions & 2 deletions test/screens/show_activity_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ void main() {
await _openTimePickerAndConfirm(tester, 3, 2, 1);
await tester.tap(find.byKey(const Key('TimerStopButtonKey')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('TimerStopConfirmDialogKey')), findsOneWidget);
expect(find.byKey(const Key('TimerStopConfirmDialogKey')), findsNothing);
});

testWidgets('Test that timer delete button probs a confirm dialog',
Expand Down Expand Up @@ -894,7 +894,7 @@ void main() {
await _openTimePickerAndConfirm(tester, 1, 1, 1);
await tester.tap(find.byKey(const Key('TimerStopButtonKey')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('TimerStopConfirmDialogKey')), findsOneWidget);
expect(find.byKey(const Key('TimerStopConfirmDialogKey')), findsNothing);
});

testWidgets('Only have a play button for timer when lockTimerControl is true',
Expand Down
6 changes: 3 additions & 3 deletions test/screens/weekplan_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ void main() {
mockActivities[2].id.toString())));
await tester.pumpAndSettle();

expect(find.byKey(const Key('TimerInitKey')), findsOneWidget);
expect(find.byKey(const Key('TimerInitKey')), findsNothing);
// ignore: always_specify_types
Future.delayed(const Duration(seconds: 2), () async {
checkCompleted.complete();
Expand Down Expand Up @@ -1232,11 +1232,11 @@ void main() {
+ mockActivities[2].id.toString())));
await tester.pumpAndSettle();

expect(find.byKey(const Key('TimerInitKey')), findsOneWidget);
expect(find.byKey(const Key('TimerInitKey')), findsNothing);
await tester.tap(find.byKey(Key(mockWeek.days[0].day.index.toString()
+ mockActivities[2].id.toString())));

expect(find.byKey(const Key('TimerInitKey')), findsOneWidget);
expect(find.byKey(const Key('TimerInitKey')), findsNothing);
// ignore: always_specify_types
Future.delayed(const Duration(seconds: 2), () async {
checkCompleted.complete();
Expand Down

0 comments on commit 76bf9ee

Please sign in to comment.