Skip to content

Commit

Permalink
Merge pull request #3 from user5522/change-db
Browse files Browse the repository at this point in the history
some fixes and improvements
  • Loading branch information
user5522 authored Dec 23, 2023
2 parents aae1233 + 0ed9412 commit 3c3c491
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 63 deletions.
57 changes: 0 additions & 57 deletions .github/workflows/build-change-db.yml

This file was deleted.

6 changes: 4 additions & 2 deletions lib/components/settings/timetable_features.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ class TimetableFeaturesOptions extends ConsumerWidget {
),
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
4 changes: 2 additions & 2 deletions lib/components/subject_management/subject_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ class SubjectScreen extends HookConsumerWidget {
color.value = Color(subjects
.firstWhere(
(subj) =>
label.value.toLowerCase() ==
subj.label.toLowerCase(),
label.value.toLowerCase().trim() ==
subj.label.toLowerCase().trim(),
orElse: () => basicSubject,
)
.color);
Expand Down
11 changes: 9 additions & 2 deletions lib/db/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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()();
Expand All @@ -19,8 +20,12 @@ class Subject extends Table {

class SubjNotifier extends StateNotifier<List<SubjectData>> {
AppDatabase db;
List<List<SubjectData>> overlappingSubjects;

SubjNotifier(this.db) : super([]) {
SubjNotifier(
this.db,
this.overlappingSubjects,
) : super([]) {
getSubjects();
}

Expand Down Expand Up @@ -55,6 +60,7 @@ class SubjNotifier extends StateNotifier<List<SubjectData>> {

Future deleteSubject(SubjectData entry) async {
db.subject.deleteWhere((t) => t.id.equals(entry.id));
overlappingSubjects.removeWhere((e) => e.contains(entry));

state = await getSubjects();
}
Expand All @@ -67,5 +73,6 @@ class SubjNotifier extends StateNotifier<List<SubjectData>> {
}

final subjProvider = StateNotifierProvider<SubjNotifier, List<SubjectData>>(
(ref) => SubjNotifier(ref.watch(AppDatabase.provider)),
(ref) => SubjNotifier(
ref.watch(AppDatabase.provider), ref.watch(overlappingSubjectsProvider)),
);

0 comments on commit 3c3c491

Please sign in to comment.