Skip to content

Commit

Permalink
Merge pull request #4 from user5522/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
user5522 authored Dec 23, 2023
2 parents 94f1d1d + 8551669 commit a68ace4
Show file tree
Hide file tree
Showing 51 changed files with 1,320 additions and 807 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- dev
jobs:
build:
name: Android Build
Expand Down
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# timetable
# Timetable
![Workflow Status](https://github.com/user5522/timetable/actions/workflows/build.yml/badge.svg)

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
A Flutter based Android timetable application for managing time.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:enableOnBackInvokedCallback="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
2 changes: 1 addition & 1 deletion lib/components/settings/customize_timetable.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/provider/settings.dart';

/// All the settings that allow for customizing the timetable.
class CustomizeTimetableOptions extends ConsumerWidget {
Expand Down
5 changes: 3 additions & 2 deletions lib/components/settings/screens/timetable_period_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/constants/custom_times.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/provider/settings.dart';

///
/// Screen to manage the period of the timetable.
/// Changes the start time and end time of the timetable.
class TimetablePeriodScreen extends ConsumerWidget {
const TimetablePeriodScreen({super.key});

Expand Down
4 changes: 2 additions & 2 deletions lib/components/settings/timetable_data.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/components/widgets/alert_dialog.dart';
import 'package:timetable/models/subjects.dart';
import 'package:timetable/provider/subjects.dart';

/// All the settings that allow for manipulating the timetable's data.
class TimetableDataOptions extends ConsumerWidget {
const TimetableDataOptions({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
final subjNotifier = ref.watch(subjectProvider.notifier);
final subjNotifier = ref.watch(subjProvider.notifier);

return Column(
children: [
Expand Down
10 changes: 6 additions & 4 deletions lib/components/settings/timetable_features.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/provider/settings.dart';
import 'package:timetable/components/settings/screens/timetable_period_screen.dart';

/// All the settings for changing some timetable features.
Expand All @@ -27,18 +27,20 @@ class TimetableFeaturesOptions extends ConsumerWidget {
),
);
},
title: const Text("Time Period Config"),
title: const Text("Time Period Configuration"),
),
SwitchListTile(
title: const Text("Rotation Weeks"),
subtitle: const Text("Experimental"),
value: rotationWeeks,
onChanged: (bool value) {
settings.updateRotationWeeks(value);
},
),
SwitchListTile(
title: const Text("AutoComplete Colors"),
title: const Text("Auto Complete Colors"),
subtitle: const Text(
"auto assigns colors from previously made subjects that have matching names",
),
value: autoCompleteColor,
onChanged: (bool value) {
settings.updateAutoCompleteColor(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:timetable/components/subject_management/subject_configs/time_con
import 'package:timetable/components/widgets/list_tile_group.dart';
import 'package:timetable/constants/days.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/provider/settings.dart';

/// Day, Time & Rotation Week config part of the Subject creation screen.
class TimeDayRotationWeekConfig extends ConsumerWidget {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:timetable/components/widgets/bottom_sheets/rotation_week_modal_bottom_sheet.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/helpers/rotation_weeks.dart';

/// Rotation Week config part of the Subject creation screen.
class RotationWeekConfig extends StatelessWidget {
Expand Down Expand Up @@ -29,12 +30,9 @@ class RotationWeekConfig extends StatelessWidget {
isDismissible: true,
context: context,
builder: (context) {
return SizedBox(
height: 200,
child: RotationWeekModalBottomSheet(
rotationWeek: rotationWeek,
rotationWeeks: rotationWeeks,
),
return RotationWeekModalBottomSheet(
rotationWeek: rotationWeek,
rotationWeeks: rotationWeeks,
);
},
);
Expand Down
28 changes: 13 additions & 15 deletions lib/components/subject_management/subject_configs/time_config.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/constants/custom_times.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/provider/settings.dart';

/// Time config part of the Subject creation screen.
class TimeConfig extends ConsumerWidget {
Expand Down Expand Up @@ -115,12 +115,11 @@ class TimeConfig extends ConsumerWidget {
),
),
),
const SizedBox(
width: 10,
),
const Icon(Icons.arrow_forward),
const SizedBox(
width: 10,
const Padding(
padding: EdgeInsets.symmetric(
horizontal: 10,
),
child: Icon(Icons.arrow_forward),
),
ActionChip(
side: BorderSide.none,
Expand Down Expand Up @@ -153,15 +152,14 @@ class TimeConfig extends ConsumerWidget {
),
),
),
if (occupied == true)
const SizedBox(
width: 10,
if (occupied)
const Padding(
padding: EdgeInsets.only(left: 10),
child: Icon(
Icons.cancel,
color: Colors.redAccent,
),
),
if (occupied == true)
const Icon(
Icons.cancel,
color: Colors.redAccent,
)
],
);
}
Expand Down
57 changes: 29 additions & 28 deletions lib/components/subject_management/subject_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import 'package:timetable/components/widgets/list_tile_group.dart';
import 'package:timetable/constants/basic_subject.dart';
import 'package:timetable/constants/days.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/models/overlapping_subjects.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/models/subjects.dart';
import 'package:timetable/db/database.dart';
import 'package:timetable/provider/overlapping_subjects.dart';
import 'package:timetable/provider/settings.dart';
import 'package:timetable/provider/subjects.dart';

/// The Subject creation/modification screen.
/// Uses [TimeDayRotationWeekConfig], [NotesTile] and [ColorsConfig]
class SubjectScreen extends HookConsumerWidget {
final int? rowIndex;
final int? columnIndex;
final Subject? subject;
final SubjectData? subject;

const SubjectScreen({
super.key,
Expand All @@ -30,7 +31,13 @@ class SubjectScreen extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final subjects = ref.watch(subjProvider);
final subjectNotifier = ref.watch(subjProvider.notifier);
final overlappingSubjects = ref.watch(overlappingSubjectsProvider);
final autoCompleteColor = ref.watch(settingsProvider).autoCompleteColor;

final bool isSubjectNull = subject == null;
final int id = isSubjectNull ? subjects.length : subject!.id;
final startTime = useState(
TimeOfDay(
hour: isSubjectNull ? (rowIndex! + 8) : subject!.startTime.hour,
Expand All @@ -43,9 +50,7 @@ class SubjectScreen extends HookConsumerWidget {
minute: 0,
),
);
final overlappingSubjects = ref.watch(overlappingSubjectsProvider);
final state = ref.read(subjectProvider.notifier);
final autoCompleteColor = ref.watch(settingsProvider).autoCompleteColor;

final day = useState(
Days.values[isSubjectNull ? columnIndex! : subject!.day.index]);
final rotationWeek =
Expand All @@ -56,7 +61,8 @@ class SubjectScreen extends HookConsumerWidget {
final location = useState(subject?.location ?? "");
final note = useState(subject?.note ?? "");

final Subject newSubject = Subject(
final SubjectData newSubject = SubjectData(
id: id,
label: label.value,
location: location.value,
color: color.value,
Expand All @@ -67,8 +73,6 @@ class SubjectScreen extends HookConsumerWidget {
note: note.value,
);

final subjects = ref.watch(subjectProvider);

final subjectsInSameDay = subjects
.where(
(e) => e.day == day.value,
Expand Down Expand Up @@ -116,7 +120,7 @@ class SubjectScreen extends HookConsumerWidget {
foregroundColor: Theme.of(context).colorScheme.errorContainer,
),
onPressed: () {
state.removeSubject(subject!, overlappingSubjects);
subjectNotifier.deleteSubject(newSubject);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Subject Deleted!'),
Expand All @@ -139,8 +143,8 @@ class SubjectScreen extends HookConsumerWidget {
onPressed: () {
if (formKey.currentState!.validate()) {
if (isSubjectNull) {
if (isOccupied == false) {
state.addSubject(newSubject);
if (!isOccupied) {
subjectNotifier.addSubject(newSubject.toCompanion(false));
Navigator.pop(context, label.value);
} else {
ScaffoldMessenger.of(context).showSnackBar(
Expand All @@ -150,8 +154,8 @@ class SubjectScreen extends HookConsumerWidget {
);
}
} else {
if (isOccupiedExceptSelf == false) {
state.updateSubject(subject!, newSubject);
if (!isOccupiedExceptSelf) {
subjectNotifier.updateSubject(newSubject);
Navigator.pop(context, label.value);
} else {
ScaffoldMessenger.of(context).showSnackBar(
Expand Down Expand Up @@ -197,8 +201,8 @@ class SubjectScreen extends HookConsumerWidget {
color.value = subjects
.firstWhere(
(subj) =>
label.value.toLowerCase() ==
subj.label.toLowerCase(),
label.value.toLowerCase().trim() ==
subj.label.toLowerCase().trim(),
orElse: () => basicSubject,
)
.color;
Expand All @@ -220,12 +224,9 @@ class SubjectScreen extends HookConsumerWidget {
),
],
),
const SizedBox(
height: 10,
),
ColorsConfig(color: color),
const SizedBox(
height: 10,
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: ColorsConfig(color: color),
),
TimeDayRotationWeekConfig(
day: day,
Expand All @@ -234,12 +235,12 @@ class SubjectScreen extends HookConsumerWidget {
endTime: endTime,
occupied: isSubjectNull ? isOccupied : isOccupiedExceptSelf,
),
const SizedBox(
height: 10,
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: NotesTile(
note: note,
),
),
NotesTile(
note: note,
)
],
),
),
Expand Down
11 changes: 8 additions & 3 deletions lib/components/timetable_views/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import 'package:timetable/components/widgets/day_view_subject_builder.dart';
import 'package:timetable/constants/days.dart';
import 'package:timetable/constants/grid_properties.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/models/subjects.dart';
import 'package:timetable/helpers/rotation_weeks.dart';
import 'package:timetable/db/database.dart';

/// Timetable view that shows each day's subjects in a single screen.
class TimetableDayView extends HookConsumerWidget {
final ValueNotifier<RotationWeeks> rotationWeek;
final List<SubjectData> subject;

const TimetableDayView({
super.key,
required this.rotationWeek,
required this.subject,
});

@override
Widget build(BuildContext context, WidgetRef ref) {
PageController controller;
final subject = ref.watch(subjectProvider);
controller = PageController(initialPage: DateTime.now().weekday - 1);

return Column(
Expand Down Expand Up @@ -51,7 +53,10 @@ class TimetableDayView extends HookConsumerWidget {
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: getFilteredSubjects(rotationWeek, subject)
children: getFilteredByRotationWeeksSubjects(
rotationWeek,
subject,
)
.where((s) => s.day.index == index)
.map(
(subject) => DayViewSubjectBuilder(
Expand Down
Loading

0 comments on commit a68ace4

Please sign in to comment.