Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sz-test-randomness-fr…
Browse files Browse the repository at this point in the history
…om-seed
  • Loading branch information
Jonas-Sander committed Feb 27, 2024
2 parents 55c128d + bcd27c6 commit 0516540
Show file tree
Hide file tree
Showing 78 changed files with 309 additions and 341 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/licence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ jobs:
cd tools/sz_repo_cli
dart pub get
lic_ck check-licenses --config ../../licenses_config.yaml --problematic
- name: Check licenses in website
run: |
cd website
flutter pub get
lic_ck check-licenses --config ../licenses_config.yaml --problematic
3 changes: 2 additions & 1 deletion app/lib/blackboard/blackboard_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
// SPDX-License-Identifier: EUPL-1.2

import 'package:clock/clock.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore_helper/cloud_firestore_helper.dart';

Expand Down Expand Up @@ -64,7 +65,7 @@ class BlackboardItem {
title: "",
text: null,
pictureURL: "",
createdOn: DateTime.now(),
createdOn: clock.now(),
attachments: [],
sendNotification: true,
forUsers: {},
Expand Down
28 changes: 23 additions & 5 deletions app/lib/calendrical_events/models/calendrical_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@ import 'package:sharezone/timetable/src/models/lesson.dart';
import 'package:sharezone/timetable/src/models/lesson_length/lesson_length.dart';
import 'package:time/time.dart';

import 'calendrical_event_types.dart';
enum EventType {
event('meeting'),
exam('exam');

/// Database key for the event type.
final String key;

const EventType(this.key);

static EventType fromString(String s) {
switch (s) {
case 'meeting':
return event;
case 'exam':
return exam;
}
throw ArgumentError("Couldn't parse $EventType from unkown event type: $s");
}
}

class CalendricalEvent {
/// The date and time when the event was created.
Expand All @@ -25,7 +43,7 @@ class CalendricalEvent {

final String eventID, groupID, authorID;
final GroupType groupType;
final CalendricalEventType eventType;
final EventType eventType;
final Date date;
final Time startTime, endTime;
final String title;
Expand Down Expand Up @@ -64,7 +82,7 @@ class CalendricalEvent {
endTime: Time.parse(data['endTime'] as String),
title: data['title'] as String,
groupType: GroupType.values.byName(data['groupType'] as String),
eventType: getEventTypeFromString(data['eventType'] as String),
eventType: EventType.fromString(data['eventType'] as String),
detail: data['detail'] as String?,
place: data['place'] as String?,
sendNotification: (data['sendNotification'] as bool?) ?? false,
Expand All @@ -77,7 +95,7 @@ class CalendricalEvent {
'createdOn': createdOn,
'groupID': groupID,
'groupType': groupType.name,
'eventType': getEventTypeToString(eventType),
'eventType': eventType.key,
'authorID': authorID,
'date': date.toDateString,
'startTime': startTime.time,
Expand All @@ -95,7 +113,7 @@ class CalendricalEvent {
String? groupID,
String? authorID,
GroupType? groupType,
CalendricalEventType? eventType,
EventType? eventType,
Date? date,
Time? startTime,
Time? endTime,
Expand Down
102 changes: 0 additions & 102 deletions app/lib/calendrical_events/models/calendrical_event_types.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:flutter/material.dart';
import 'package:group_domain_models/group_domain_models.dart';
import 'package:provider/provider.dart';
import 'package:sharezone/calendrical_events/models/calendrical_event.dart';
import 'package:sharezone/calendrical_events/models/calendrical_event_types.dart';
import 'package:sharezone/calendrical_events/provider/past_calendrical_events_page_controller.dart';
import 'package:sharezone/calendrical_events/provider/past_calendrical_events_page_controller_factory.dart';
import 'package:sharezone/sharezone_plus/page/sharezone_plus_page.dart';
Expand Down Expand Up @@ -176,7 +175,7 @@ class _SharezonePlusAd extends StatelessWidget {
detail: null,
endTime: Time(hour: 12, minute: 0),
eventID: 'eventId',
eventType: Exam(),
eventType: EventType.exam,
groupType: GroupType.course,
latestEditor: null,
place: null,
Expand Down
5 changes: 3 additions & 2 deletions app/lib/changelog/change_database_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//
// SPDX-License-Identifier: EUPL-1.2

import 'package:clock/clock.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:sharezone/changelog/change.dart';
import 'package:cloud_firestore_helper/cloud_firestore_helper.dart';
import 'package:sharezone/changelog/change.dart';

class ChangeDatabaseModel {
final String id;
Expand All @@ -32,7 +33,7 @@ class ChangeDatabaseModel {
return ChangeDatabaseModel._(
id: "",
version: "",
releaseDate: DateTime.now(),
releaseDate: clock.now(),
newFeatures: [],
improvements: [],
fixes: [],
Expand Down
4 changes: 3 additions & 1 deletion app/lib/comments/comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//
// SPDX-License-Identifier: EUPL-1.2

import 'package:clock/clock.dart';

import 'misc.dart';

class Comment {
Expand Down Expand Up @@ -66,7 +68,7 @@ class CommentAge extends Duration {

int get inApproximateYears => (inDays / approximateDaysPerMonth).round();

DateTime get writtenOnDateTime => DateTime.now().subtract(this);
DateTime get writtenOnDateTime => clock.now().subtract(this);
}

class CommentAuthor {
Expand Down
6 changes: 3 additions & 3 deletions app/lib/comments/comment_data_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//
// SPDX-License-Identifier: EUPL-1.2

import 'package:clock/clock.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:sharezone/comments/comment.dart';
import 'package:cloud_firestore_helper/cloud_firestore_helper.dart';
import 'package:sharezone/comments/comment.dart';

class CommentDataModel {
final String? id;
Expand Down Expand Up @@ -73,8 +74,7 @@ class CommentDataModel {
author: author.toModel(),
content: comment,
ratings: _createRatings(),
age: CommentAge.fromDuration(
DateTime.now().difference(writtenOn!.toDate())),
age: CommentAge.fromDuration(clock.now().difference(writtenOn!.toDate())),
id: id,
);
}
Expand Down
7 changes: 4 additions & 3 deletions app/lib/dashboard/bloc/dashboard_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import 'dart:async';

import 'package:bloc_base/bloc_base.dart';
import 'package:clock/clock.dart';
import 'package:date/date.dart';
import 'package:design/design.dart';
import 'package:firebase_hausaufgabenheft_logik/firebase_hausaufgabenheft_logik.dart';
Expand Down Expand Up @@ -52,7 +53,7 @@ extension RepeatEveryExtension<T> on Stream<T> {
class DashboardBloc extends BlocBase {
final String _uid;
final todayDateTimeWithoutTime =
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day);
DateTime(clock.now().year, clock.now().month, clock.now().day);

final _unreadBlackboardViewsSubject = BehaviorSubject<List<BlackboardView>>();
final _unreadBlackboardItemsEmptySubject = BehaviorSubject<bool>();
Expand Down Expand Up @@ -152,7 +153,7 @@ class DashboardBloc extends BlocBase {

List<HomeworkDto> _filterUrgentHomeworks(
List<HomeworkDto> allHomeworks, TypeOfUser typeOfUser) {
final now = DateTime.now();
final now = clock.now();
final dayAfterTomorrow = DateTime(now.year, now.month, now.day + 2);
// Was passiert, wenn der 30. Oktober ist und 2 Tage dazu gezählt werden? Springt es dann auf den 1. November um?
// Antwort: Springt um auf den 1.November, gechekt, auf wenn der Code unschön ist, besser wäre dayAfterTomorrow = now.add(Duration(days:2))
Expand Down Expand Up @@ -286,7 +287,7 @@ extension on DateTime {
bool get isDayAfterTomorrow => dayAfterTomorrow == withoutTime;

static DateTime get today =>
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day);
DateTime(clock.now().year, clock.now().month, clock.now().day);
static DateTime get tomorrow =>
DateTime(today.year, today.month, today.day + 1);
static DateTime get dayAfterTomorrow =>
Expand Down
1 change: 1 addition & 0 deletions app/lib/dashboard/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'dart:developer';

import 'package:analytics/analytics.dart';
import 'package:bloc_provider/bloc_provider.dart';
import 'package:clock/clock.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down
7 changes: 4 additions & 3 deletions app/lib/dashboard/models/homework_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
// SPDX-License-Identifier: EUPL-1.2

import 'package:clock/clock.dart';
import 'package:firebase_hausaufgabenheft_logik/firebase_hausaufgabenheft_logik.dart';
import 'package:flutter/material.dart';
import 'package:group_domain_models/group_domain_models.dart';
Expand Down Expand Up @@ -39,7 +40,7 @@ class HomeworkView {
}

final todayDateTimeWithoutTime =
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day);
DateTime(clock.now().year, clock.now().month, clock.now().day);
if (dateTime.isBefore(todayDateTimeWithoutTime)) {
return "Überfällig!";
} else if (dateTime.isAtSameMomentAs(todayDateTimeWithoutTime)) {
Expand All @@ -62,8 +63,8 @@ class HomeworkView {
final defaultColor = Colors.grey[400]!;
if (!withUrgentColor) return defaultColor;

final dayAfterTomorrow = DateTime(
DateTime.now().year, DateTime.now().month, DateTime.now().day + 2);
final dayAfterTomorrow =
DateTime(clock.now().year, clock.now().month, clock.now().day + 2);
return dateTime.isBefore(dayAfterTomorrow)
? Colors.redAccent
: defaultColor;
Expand Down
5 changes: 2 additions & 3 deletions app/lib/dashboard/sections/holiday_countdown_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ class _HolidayText extends StatelessWidget {
}
// For each Holiday create a Widget and add to the list.
for (var holiday in holidayList) {
int daysTillHolidayBeginn =
holiday!.start.difference(DateTime.now()).inDays;
int daysTillHolidayBeginn = holiday!.start.difference(clock.now()).inDays;
String holidayTitle = capitalize(holiday.name);

String emoji;
Expand All @@ -139,7 +138,7 @@ class _HolidayText extends StatelessWidget {
emoji = "🎉🎉🙌";
textWidget = Text("$holidayTitle: JETZT, WOOOOOOO! $emoji");
} else {
int daysTillHolidayEnd = holiday.end.difference(DateTime.now()).inDays;
int daysTillHolidayEnd = holiday.end.difference(clock.now()).inDays;
if (daysTillHolidayEnd == 0) {
textWidget = Text("$holidayTitle: Letzer Tag 😱");
} else {
Expand Down
3 changes: 2 additions & 1 deletion app/lib/dashboard/update_reminder/update_reminder_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// SPDX-License-Identifier: EUPL-1.2

import 'package:bloc_base/bloc_base.dart';
import 'package:clock/clock.dart';
import 'package:crash_analytics/crash_analytics.dart';
import 'package:meta/meta.dart';
import 'package:sharezone/changelog/change.dart';
Expand Down Expand Up @@ -41,7 +42,7 @@ class UpdateReminderBloc extends BlocBase {
getCurrentVersion: () => platformInformationRetriever.init().then(
(_) => Version.parse(name: platformInformationRetriever.version)),
updateGracePeriod: updateGracePeriod,
getCurrentDateTime: () => DateTime.now(),
getCurrentDateTime: () => clock.now(),
crashAnalytics: crashAnalytics,
);
}
Expand Down
Loading

0 comments on commit 0516540

Please sign in to comment.