Skip to content

Commit

Permalink
Rework HomeworkDialogBloc . (#1127)
Browse files Browse the repository at this point in the history
Replaced `HomeworkDialogBloc` with a `Bloc` from
[package:bloc](https://pub.dev/packages/bloc).
Added unit and golden tests.

I tried to keep the behavior mostly the same. There are still some of
the same bugs as before (e.g. #1117), they should be fixed in separate
PRs.

Differences to old behavior:
* If any field is changed the quit prompt will appear (e.g. submission
enabled, submission time and is private were ignored before)
* Pressing save will show errors (red text) like before, but not a
`SnackBar`

Not so great:
* `PrefilledTextField` will we rebuild each time the text changes
(title, description) - didn't see any problems because of this though
* Code quality is mediocre (e.g. using `HomeworkDto` for the current
state in the bloc which lead to _horrible_ hacks for the todo
`DateTime`)
* Quality of tests if mediocre, good amount of duplication. Also instead
of testing each thing seperately I threw some different scenarios
(private, not private, with submissions) together which just tested
different things at the same time.
* Markdown analytics not tested automatically, just manually once
* No automatic tests for awaiting or not awaiting API calls depending on
if attachments are added because of the Firestore offline behavior where
Future won't complete (it works though, tested it manually several
times)

Good:
* Good amount of test coverage
* Several golden tests (happy path and errors)
* UI is decoupled from business logic
* Should be a bit better to add functionality and maintain than before
* 🗿


https://github.com/SharezoneApp/sharezone-app/assets/29028262/86ef445f-2424-4607-b3fc-d403d70eafa2


https://github.com/SharezoneApp/sharezone-app/assets/29028262/64332530-0181-4bbf-8a35-d31e62405bc8

Fixes #1115
  • Loading branch information
Jonas-Sander authored Oct 25, 2023
1 parent 780288c commit de1c75f
Show file tree
Hide file tree
Showing 73 changed files with 2,567 additions and 608 deletions.
953 changes: 679 additions & 274 deletions app/lib/blocs/homework/homework_dialog_bloc.dart

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/lib/filesharing/dialog/course_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:sharezone/blocs/application_bloc.dart';
import 'package:sharezone/groups/group_join/group_join_page.dart';
import 'package:sharezone/groups/group_permission.dart';
import 'package:sharezone/groups/src/pages/course/create/course_template_page.dart';
import 'package:sharezone/pages/homework/homework_dialog.dart';
import 'package:sharezone/util/api.dart';
import 'package:sharezone_widgets/sharezone_widgets.dart';

Expand Down Expand Up @@ -109,7 +110,7 @@ class CourseTileBase extends StatelessWidget {
leading: const Icon(Icons.book),
title: const Text("Kurs"),
subtitle: Text(
errorText ?? courseName ?? 'Keinen Kurs ausgewählt',
errorText ?? courseName ?? HwDialogErrorStrings.emptyCourse,
style: errorText != null ? const TextStyle(color: Colors.red) : null,
),
trailing: const Icon(Icons.keyboard_arrow_down),
Expand Down
28 changes: 28 additions & 0 deletions app/lib/filesharing/dialog/file_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,34 @@ class FileTile extends StatelessWidget {
: cloudFile!.fileFormat;
final name = localFile != null ? localFile!.getName() : cloudFile!.name;

return FileTileBase(
name: name,
fileType: fileType,
onTap: onTap,
trailing: trailing,
onLongPress: onLongPress,
);
}
}

class FileTileBase extends StatelessWidget {
const FileTileBase({
super.key,
required this.name,
required this.fileType,
this.trailing,
this.onTap,
this.onLongPress,
});

final String name;
final FileFormat fileType;
final Widget? trailing;
final VoidCallback? onTap;
final VoidCallback? onLongPress;

@override
Widget build(BuildContext context) {
return ListTile(
leading: FileIcon(fileFormat: fileType),
title: Text(name),
Expand Down
Loading

0 comments on commit de1c75f

Please sign in to comment.