Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prototype UI for a single-page dialog for adding events/exams. #1286

Merged
merged 17 commits into from
Feb 5, 2024

Conversation

Jonas-Sander
Copy link
Collaborator

@Jonas-Sander Jonas-Sander commented Feb 2, 2024

This PR adds a a prototype UI for adding events/exams. Pressing buttons etc doesn't do anything yet.

I copied most of the code it from homework_dialog.dart. In the next PR I want to move shared widgets out to sharezone_widgets. I commented some stuff out so I don't forget some functionality in the future.

Since the new dialog doesn't work yet and we can't see in the code if we're in a preview, I disabled showing this dialog for now.

grafik grafik

grafik

Summary by CodeRabbit

  • New Features
    • Enhanced the timetable functionality with the ability to add events through a dialog or a dedicated page, depending on specific conditions.

Copy link
Contributor

coderabbitai bot commented Feb 2, 2024

Walkthrough

The recent update introduces a new module for adding events to the timetable, enhancing the app's functionality with conditional navigation. Depending on specific conditions, users can now be directed to either a dialog or a separate page for event addition, streamlining the user experience according to the context.

Changes

File Path Change Summary
.../timetable_page.dart Imported timetable_add_event_dialog.dart for new event addition functionality.
.../timetable_page_fab.dart Added conditional navigation logic in showTimetableAddEventPage to navigate to a dialog or a page based on a condition, returning the navigation result.

🐰✨
In the realm of code, where time's a maze,
A rabbit hopped, setting events ablaze.
"Choose your path," it whispered with glee,
"A dialog or page, what will it be?"
🌟📅

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions bot added the feature: timetable / calendar Includes anything regarding lessons (timetable) and events (calendar). label Feb 2, 2024
Copy link

github-actions bot commented Feb 2, 2024

Visit the preview URL for this PR (updated for commit fcc2207):

https://sharezone-test--pr1286-new-events-dialog-5zs05fl6.web.app

(expires Thu, 08 Feb 2024 13:51:59 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b

@Jonas-Sander Jonas-Sander marked this pull request as ready for review February 5, 2024 13:48
@Jonas-Sander Jonas-Sander changed the title New one-page events dialog. Add prototype UI for a single-page dialog for adding events/exams. Feb 5, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 8

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 13a4718 and fcc2207.
Files selected for processing (3)
  • app/lib/timetable/timetable_add_event/timetable_add_event_dialog.dart (1 hunks)
  • app/lib/timetable/timetable_page/timetable_page.dart (2 hunks)
  • app/lib/timetable/timetable_page/timetable_page_fab.dart (1 hunks)
Additional comments: 6
app/lib/timetable/timetable_page/timetable_page_fab.dart (1)
  • 63-64: Check for the necessity of await waitingForPopAnimation(); when the context is not mounted. This could potentially lead to unwanted behavior if the context becomes unmounted before the animation completes.
app/lib/timetable/timetable_page/timetable_page.dart (1)
  • 35-35: The import of timetable_add_event/timetable_add_event_dialog.dart is added. Ensure that this module is utilized within the file or consider removing the import if it's not needed.
app/lib/timetable/timetable_add_event/timetable_add_event_dialog.dart (4)
  • 215-227: Placeholder text and commented-out error handling in _TitleFieldBase. Ensure that proper error handling and user feedback mechanisms are implemented.
  • 305-309: The CourseTileBase widget is used with null parameters for courseName and errorText. Ensure these values are intentionally left null or provide meaningful defaults or dynamic values.
  • 408-408: The use of date?.parser.toYMMMEd might throw an error if date is null. Ensure that date is always non-null when accessed or handle the potential null case explicitly.
  • 527-527: The onChanged callback in _Location is a no-op ((_) {}). If this is intentional for a prototype, consider adding a comment explaining future plans. Otherwise, implement the callback or remove it if unnecessary.

Comment on lines +46 to +56
// ignore: dead_code
if (false) {
await Navigator.push(
context,
IgnoreWillPopScopeWhenIosSwipeBackRoute(
builder: (context) => TimetableAddEventDialog(
isExam: isExam,
),
settings: const RouteSettings(name: TimetableAddEventDialog.tag)));
return null;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of // ignore: dead_code and a hardcoded false condition in the if statement is not ideal for maintainability or readability. Consider replacing this with a feature flag or configuration parameter that can be easily toggled.

Comment on lines +46 to +68
// ignore: dead_code
if (false) {
await Navigator.push(
context,
IgnoreWillPopScopeWhenIosSwipeBackRoute(
builder: (context) => TimetableAddEventDialog(
isExam: isExam,
),
settings: const RouteSettings(name: TimetableAddEventDialog.tag)));
return null;
} else {
final result = await Navigator.push<TimetableResult>(
context,
IgnoreWillPopScopeWhenIosSwipeBackRoute(
builder: (context) => TimetableAddEventPage(isExam: isExam),
settings: const RouteSettings(name: TimetableAddEventPage.tag)));
if (result != null) {
await waitingForPopAnimation();
if (!context.mounted) return null;

showDataArrivalConfirmedSnackbar(context: context);
showDataArrivalConfirmedSnackbar(context: context);
}
return result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await Navigator.push inside the if block is never reached due to the hardcoded false condition. This dead code should either be removed or updated to reflect the intended functionality.


showDataArrivalConfirmedSnackbar(context: context);
showDataArrivalConfirmedSnackbar(context: context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function showDataArrivalConfirmedSnackbar is called without checking the context.mounted status afterward, which could lead to attempting to show a snackbar in an unmounted context.

+ if (context.mounted) {
  showDataArrivalConfirmedSnackbar(context: context);
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
showDataArrivalConfirmedSnackbar(context: context);
if (context.mounted) {
showDataArrivalConfirmedSnackbar(context: context);
}

Comment on lines +38 to +49
// final hasInputChanged = hasModifiedData();
const hasInputChanged = false;
final navigator = Navigator.of(context);
if (!hasInputChanged) {
navigator.pop();
return;
}

// final shouldPop = await warnUserAboutLeavingForm(context);
// if (shouldPop && context.mounted) {
// navigator.pop();
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code related to checking if input has changed and warning the user about leaving the form. Consider removing or implementing this functionality if needed.

import 'package:sharezone_widgets/sharezone_widgets.dart';
import 'package:time/time.dart';

final _titleNode = FocusNode();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global variable _titleNode is defined outside of any class. Consider moving it inside the relevant widget to encapsulate its scope and prevent potential conflicts or misuse.


@override
Widget build(BuildContext context) {
if (PlatformCheck.isDesktopOrWeb) return const SizedBox(height: 4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of PlatformCheck.isDesktopOrWeb to conditionally render a widget could be refined by abstracting platform checks into a separate utility class or function for better maintainability and testing.

Comment on lines +169 to +182
Future<void> onPressed(BuildContext context) async {
Navigator.pop(context);
// final bloc = bloc_lib.BlocProvider.of<HomeworkDialogBloc>(context);
// try {
// bloc.add(const Save());
// } on Exception catch (e) {
// log("Exception when submitting: $e", error: e);
// showSnackSec(
// text:
// "Es gab einen unbekannten Fehler (${e.toString()}) 😖 Bitte kontaktiere den Support!",
// context: context,
// seconds: 5,
// );
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code within the onPressed method of _SaveButton. If this logic is planned for future use, consider adding a TODO comment; otherwise, remove the commented-out code to clean up the file.

Comment on lines +347 to +368
if (false) ...[
Row(
children: [
const SizedBox(width: 34),
OutlinedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const _LessonPickerPage(),
),
);
},
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14))),
child: const Text('Schulstunde auswählen'),
),
],
),
const SizedBox(height: 10),
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code within if (false) block in _DateAndTimePicker. Consider removing or implementing the intended functionality.

Copy link
Member

@nilsreichardt nilsreichardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jonas-Sander Jonas-Sander added this pull request to the merge queue Feb 5, 2024
Merged via the queue into main with commit 12008af Feb 5, 2024
44 of 45 checks passed
@Jonas-Sander Jonas-Sander deleted the new-events-dialog branch February 5, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation feature: timetable / calendar Includes anything regarding lessons (timetable) and events (calendar).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants