Skip to content

Commit

Permalink
reorganize project structure a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
user5522 committed Dec 23, 2023
1 parent 3c3c491 commit 429c834
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/components/settings/timetable_data.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/components/widgets/alert_dialog.dart';
import 'package:timetable/db/models.dart';
import 'package:timetable/provider/subjects.dart';

/// All the settings that allow for manipulating the timetable's data.
class TimetableDataOptions extends ConsumerWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/subject_management/subject_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import 'package:timetable/constants/basic_subject.dart';
import 'package:timetable/constants/days.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/database.dart';
import 'package:timetable/db/models.dart';
import 'package:timetable/models/overlapping_subjects.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/provider/subjects.dart';

/// The Subject creation/modification screen.
/// Uses [TimeDayRotationWeekConfig], [NotesTile] and [ColorsConfig]
Expand Down
2 changes: 1 addition & 1 deletion lib/db/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:drift/drift.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/constants/days.dart';
import 'package:timetable/db/models.dart';
import 'package:timetable/db/models/subject.dart';
import 'package:timetable/db/connection/native.dart';
import 'package:timetable/db/converters/time_of_day_converter.dart';
import 'package:flutter/material.dart' as material;
Expand Down
16 changes: 16 additions & 0 deletions lib/db/models/subject.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:drift/drift.dart';
import 'package:timetable/constants/days.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/converters/time_of_day_converter.dart';

class Subject extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get label => text()();
TextColumn get location => text().nullable()();
TextColumn get note => text().nullable()();
IntColumn get color => integer()();
IntColumn get rotationWeek => intEnum<RotationWeeks>()();
IntColumn get day => intEnum<Days>()();
TextColumn get startTime => text().map(const TimeOfDayConverter())();
TextColumn get endTime => text().map(const TimeOfDayConverter())();
}
16 changes: 1 addition & 15 deletions lib/db/models.dart → lib/provider/subjects.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
import 'package:drift/drift.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/constants/days.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/converters/time_of_day_converter.dart';

import 'package:timetable/db/database.dart';
import 'package:timetable/models/overlapping_subjects.dart';

class Subject extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get label => text()();
TextColumn get location => text().nullable()();
TextColumn get note => text().nullable()();
IntColumn get color => integer()();
IntColumn get rotationWeek => intEnum<RotationWeeks>()();
IntColumn get day => intEnum<Days>()();
TextColumn get startTime => text().map(const TimeOfDayConverter())();
TextColumn get endTime => text().map(const TimeOfDayConverter())();
}

class SubjNotifier extends StateNotifier<List<SubjectData>> {
AppDatabase db;
List<List<SubjectData>> overlappingSubjects;
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/timetable_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:timetable/components/widgets/grid_day_views_toggle.dart';
import 'package:timetable/components/widgets/navigation_bar_toggle.dart';
import 'package:timetable/components/widgets/rotation_week_toggle.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/models.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/provider/subjects.dart';

/// The main screen, displays the default timetable view.
/// basically groups [TimetableGridView] & [TimetableDayView].
Expand Down

0 comments on commit 429c834

Please sign in to comment.