Skip to content

Commit

Permalink
Merge pull request #2 from user5522/change-db
Browse files Browse the repository at this point in the history
Change db
  • Loading branch information
user5522 authored Dec 23, 2023
2 parents 497c6e6 + e8cb186 commit aae1233
Show file tree
Hide file tree
Showing 27 changed files with 850 additions and 370 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-change-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Android Build and Artifact

on:
push:
branches:
- change-db
jobs:
build:
name: Android Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "zulu"
cache: 'gradle'
- uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- name: Set up Flutter
run: flutter pub get
- name: Build with Flutter
env:
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
run: flutter build apk --release --split-per-abi
- name: Sign APK
id: sign_apk
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: build/app/outputs/flutter-apk/
signingKeyBase64: ${{ secrets.SIGNING_KEYSTORE }}
keyStorePassword: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
alias: ${{ secrets.SIGNING_KEY_ALIAS }}
keyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}
- name: Archive arm64-v8a
uses: actions/upload-artifact@v2
with:
name: android-arm64-v8a
path: |
build/app/outputs/flutter-apk/*-arm64-v8a-release-signed.apk
- name: Archive armeabi-v7a
uses: actions/upload-artifact@v2
with:
name: android-armeabi-v7a
path: |
build/app/outputs/flutter-apk/*-armeabi-v7a-release-signed.apk
- name: Archive x86_64
uses: actions/upload-artifact@v2
with:
name: android-x86_64
path: |
build/app/outputs/flutter-apk/*-x86_64-release-signed.apk
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
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/db/models.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
35 changes: 20 additions & 15 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/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/models/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,32 +50,30 @@ 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 =
useState(isSubjectNull ? RotationWeeks.none : subject!.rotationWeek);
final color = useState(isSubjectNull ? Colors.black : subject!.color);
final color =
useState(isSubjectNull ? Colors.black : Color(subject!.color));

final label = useState(subject?.label ?? "");
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,
color: color.value.value,
startTime: startTime.value,
endTime: endTime.value,
day: day.value,
rotationWeek: rotationWeek.value,
note: note.value,
);

final subjects = ref.watch(subjectProvider);

final subjectsInSameDay = subjects
.where(
(e) => e.day == day.value,
Expand Down Expand Up @@ -116,7 +121,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 @@ -140,7 +145,7 @@ class SubjectScreen extends HookConsumerWidget {
if (formKey.currentState!.validate()) {
if (isSubjectNull) {
if (!isOccupied) {
state.addSubject(newSubject);
subjectNotifier.addSubject(newSubject.toCompanion(false));
Navigator.pop(context, label.value);
} else {
ScaffoldMessenger.of(context).showSnackBar(
Expand All @@ -151,7 +156,7 @@ class SubjectScreen extends HookConsumerWidget {
}
} else {
if (!isOccupiedExceptSelf) {
state.updateSubject(subject!, newSubject);
subjectNotifier.updateSubject(newSubject);
Navigator.pop(context, label.value);
} else {
ScaffoldMessenger.of(context).showSnackBar(
Expand Down Expand Up @@ -194,14 +199,14 @@ class SubjectScreen extends HookConsumerWidget {
onChanged: (value) {
label.value = value;
if (autoCompleteColor) {
color.value = subjects
color.value = Color(subjects
.firstWhere(
(subj) =>
label.value.toLowerCase() ==
subj.label.toLowerCase(),
orElse: () => basicSubject,
)
.color;
.color);
}
},
),
Expand Down
9 changes: 6 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,22 @@ 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/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 @@ -52,7 +53,9 @@ class TimetableDayView extends HookConsumerWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: getFilteredByRotationWeeksSubjects(
rotationWeek, subject)
rotationWeek,
subject,
)
.where((s) => s.day.index == index)
.map(
(subject) => DayViewSubjectBuilder(
Expand Down
11 changes: 6 additions & 5 deletions lib/components/timetable_views/grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:timetable/components/widgets/time_column.dart';
import 'package:timetable/constants/custom_times.dart';
import 'package:timetable/constants/grid_properties.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/database.dart';
import 'package:timetable/models/overlapping_subjects.dart';
import 'package:timetable/models/subjects.dart';
import 'package:timetable/components/widgets/grid_view_subject_builder.dart';
import 'package:timetable/components/widgets/subject_container_builder.dart';
import 'package:timetable/components/widgets/tile.dart';
Expand All @@ -17,15 +17,16 @@ import 'package:timetable/models/settings.dart';
/// Timetable view that shows All the days' subjects in a grid form.
class TimetableGridView extends HookConsumerWidget {
final ValueNotifier<RotationWeeks> rotationWeek;
final List<SubjectData> subject;

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

@override
Widget build(BuildContext context, WidgetRef ref) {
final subject = ref.watch(subjectProvider);
final compactMode = ref.watch(settingsProvider).compactMode;
final customStartTime = ref.watch(settingsProvider).customStartTime;
final customEndTime = ref.watch(settingsProvider).customEndTime;
Expand Down Expand Up @@ -83,7 +84,7 @@ class TimetableGridView extends HookConsumerWidget {
}

List<List<Tile?>> generate(
List<Subject> subjects,
List<SubjectData> subjects,
int totalDays,
int totalHours,
WidgetRef ref,
Expand Down Expand Up @@ -135,15 +136,15 @@ class TimetableGridView extends HookConsumerWidget {
);

for (final subjects in overlappingSubjects) {
Subject getSubjectWithEarlierStartTime() {
SubjectData getSubjectWithEarlierStartTime() {
if (subjects[0].startTime.hour < subjects[1].startTime.hour) {
return subjects[0];
} else {
return subjects[1];
}
}

Subject getSubjectWithLaterEndTime() {
SubjectData getSubjectWithLaterEndTime() {
if (subjects[0].endTime.hour > subjects[1].endTime.hour) {
return subjects[0];
} else {
Expand Down
13 changes: 7 additions & 6 deletions lib/components/widgets/day_view_subject_builder.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/database.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/models/subjects.dart';
import 'package:timetable/components/subject_management/subject_screen.dart';

/// Subject builder for the day view.
class DayViewSubjectBuilder extends ConsumerWidget {
final Subject subject;
final SubjectData subject;

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

Expand All @@ -16,15 +16,16 @@ class DayViewSubjectBuilder extends ConsumerWidget {
final rotationWeeks = ref.watch(settingsProvider).rotationWeeks;
final hideTransparentSubject =
ref.watch(settingsProvider).hideTransparentSubject;
Color labelColor =
subject.color.computeLuminance() > .7 ? Colors.black : Colors.white;
Color subLabelsColor = subject.color.computeLuminance() > .7
Color labelColor = Color(subject.color).computeLuminance() > .7
? Colors.black
: Colors.white;
Color subLabelsColor = Color(subject.color).computeLuminance() > .7
? Colors.black.withOpacity(.6)
: Colors.white.withOpacity(.75);

String label = subject.label;
String? location = subject.location;
Color color = subject.color;
Color color = Color(subject.color);
String? note = subject.note;

final hideTransparentSubjects =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import 'package:non_uniform_border/non_uniform_border.dart';
import 'package:timetable/constants/custom_times.dart';
import 'package:timetable/constants/grid_properties.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/database.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/models/subjects.dart';
import 'package:timetable/components/subject_management/subject_screen.dart';

/// Overlapping Subjects Builder for the grid view.
class OverlappingSubjBuilder extends ConsumerWidget {
final List<Subject> subjects;
final List<SubjectData> subjects;
final int earlierStartTimeHour;
final int laterEndTimeHour;

Expand Down Expand Up @@ -63,18 +63,19 @@ class OverlappingSubjBuilder extends ConsumerWidget {
),
child: Row(
children: List.generate(subjects.length, (i) {
Color labelColor = subjects[i].color.computeLuminance() > .7
Color labelColor = Color(subjects[i].color).computeLuminance() > .7
? Colors.black
: Colors.white;
Color subLabelsColor = subjects[i].color.computeLuminance() > .7
? Colors.black.withOpacity(.6)
: Colors.white.withOpacity(.75);
Color subLabelsColor =
Color(subjects[i].color).computeLuminance() > .7
? Colors.black.withOpacity(.6)
: Colors.white.withOpacity(.75);

int endTimeHour = subjects[i].endTime.hour;
int startTimeHour = subjects[i].startTime.hour;
String label = subjects[i].label;
String? location = subjects[i].location;
Color color = subjects[i].color;
Color color = Color(subjects[i].color);

int subjHeight = endTimeHour - startTimeHour;

Expand Down
6 changes: 3 additions & 3 deletions lib/components/widgets/grid_view_subject_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:non_uniform_border/non_uniform_border.dart';
import 'package:timetable/constants/custom_times.dart';
import 'package:timetable/constants/rotation_weeks.dart';
import 'package:timetable/db/database.dart';
import 'package:timetable/models/settings.dart';
import 'package:timetable/models/subjects.dart';
import 'package:timetable/components/subject_management/subject_screen.dart';
import 'package:timetable/constants/grid_properties.dart';

/// Subject builder for the grid view.
class SubjectBuilder extends ConsumerWidget {
final Subject subject;
final SubjectData subject;

const SubjectBuilder({
super.key,
Expand All @@ -28,7 +28,7 @@ class SubjectBuilder extends ConsumerWidget {

String label = subject.label;
String? location = subject.location;
Color color = subject.color;
Color color = Color(subject.color);

final hideTransparentSubjects =
hideTransparentSubject && color.opacity == Colors.transparent.opacity;
Expand Down
Loading

0 comments on commit aae1233

Please sign in to comment.