develop-biggerFeedbackWidget #51
@@ -16,4 +16,15 @@ extension IsSameDay on DateTime {
 | 
			
		||||
  TimeOfDay toTimeOfDay() {
 | 
			
		||||
    return TimeOfDay(hour: hour, minute: minute);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool isSameDateTime(DateTime other) {
 | 
			
		||||
    bool isSameDay = this.isSameDay(other);
 | 
			
		||||
    bool isSameTimeOfDay = (toTimeOfDay() == other.toTimeOfDay());
 | 
			
		||||
 | 
			
		||||
    return isSameDay && isSameTimeOfDay;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool isSameOrAfter(DateTime other) {
 | 
			
		||||
    return isSameDateTime(other) || isAfter(other);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -4,7 +4,9 @@ part 'timetableSettings.g.dart';
 | 
			
		||||
 | 
			
		||||
@JsonSerializable()
 | 
			
		||||
class TimetableSettings {
 | 
			
		||||
  TimetableSettings();
 | 
			
		||||
  bool connectDoubleLessons;
 | 
			
		||||
 | 
			
		||||
  TimetableSettings({required this.connectDoubleLessons});
 | 
			
		||||
 | 
			
		||||
  factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json);
 | 
			
		||||
  Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this);
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,11 @@ part of 'timetableSettings.dart';
 | 
			
		||||
// **************************************************************************
 | 
			
		||||
 | 
			
		||||
TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) =>
 | 
			
		||||
    TimetableSettings();
 | 
			
		||||
    TimetableSettings(
 | 
			
		||||
      connectDoubleLessons: json['connectDoubleLessons'] as bool,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) =>
 | 
			
		||||
    <String, dynamic>{};
 | 
			
		||||
    <String, dynamic>{
 | 
			
		||||
      'connectDoubleLessons': instance.connectDoubleLessons,
 | 
			
		||||
    };
 | 
			
		||||
 
 | 
			
		||||
@@ -244,9 +244,66 @@ class _TimetableState extends State<Timetable> {
 | 
			
		||||
    ];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  List<GetTimetableResponseObject> _removeDuplicates(TimetableProps data, Duration maxTimeBetweenDouble) {
 | 
			
		||||
 | 
			
		||||
    List<GetTimetableResponseObject> timetableList = data.getTimetableResponse.result.toList();
 | 
			
		||||
 | 
			
		||||
    if(timetableList.isEmpty) return timetableList;
 | 
			
		||||
 | 
			
		||||
    timetableList.sort((a, b) => _parseWebuntisTimestamp(a.date, a.startTime).compareTo(_parseWebuntisTimestamp(b.date, b.startTime)));
 | 
			
		||||
 | 
			
		||||
    GetTimetableResponseObject previousElement = timetableList.first;
 | 
			
		||||
    for(var i = 1; i < timetableList.length; i++) {
 | 
			
		||||
      GetTimetableResponseObject currentElement = timetableList.elementAt(i);
 | 
			
		||||
 | 
			
		||||
      bool isSameLesson() {
 | 
			
		||||
        int? currentSubjectId = currentElement.su.firstOrNull?.id;
 | 
			
		||||
        int? previousSubjectId = previousElement.su.firstOrNull?.id;
 | 
			
		||||
 | 
			
		||||
        if(currentSubjectId == null || previousSubjectId == null || currentSubjectId != previousSubjectId) return false;
 | 
			
		||||
 | 
			
		||||
        int? currentRoomId = currentElement.ro.firstOrNull?.id;
 | 
			
		||||
        int? previousRoomId = previousElement.ro.firstOrNull?.id;
 | 
			
		||||
 | 
			
		||||
        if(currentRoomId != previousRoomId) return false;
 | 
			
		||||
 | 
			
		||||
        int? currentTeacherId = currentElement.te.firstOrNull?.id;
 | 
			
		||||
        int? previousTeacherId = previousElement.te.firstOrNull?.id;
 | 
			
		||||
 | 
			
		||||
        if(currentTeacherId != previousTeacherId) return false;
 | 
			
		||||
 | 
			
		||||
        String? currentStatusCode = currentElement.code;
 | 
			
		||||
        String? previousStatusCode = previousElement.code;
 | 
			
		||||
 | 
			
		||||
        if(currentStatusCode != previousStatusCode) return false;
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      bool isNotSeparated() => _parseWebuntisTimestamp(previousElement.date, previousElement.endTime).add(maxTimeBetweenDouble)
 | 
			
		||||
          .isSameOrAfter(_parseWebuntisTimestamp(currentElement.date, currentElement.startTime));
 | 
			
		||||
 | 
			
		||||
      if(isSameLesson() && isNotSeparated()) {
 | 
			
		||||
        previousElement.endTime = currentElement.endTime;
 | 
			
		||||
        timetableList.remove(currentElement);
 | 
			
		||||
        i--;
 | 
			
		||||
      } else {
 | 
			
		||||
        previousElement = currentElement;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return timetableList;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TimetableEvents _buildTableEvents(TimetableProps data) {
 | 
			
		||||
 | 
			
		||||
    List<Appointment> appointments = data.getTimetableResponse.result.map((element) {
 | 
			
		||||
    List<GetTimetableResponseObject> timetableList = data.getTimetableResponse.result.toList();
 | 
			
		||||
 | 
			
		||||
    if(settings.val().timetableSettings.connectDoubleLessons) {
 | 
			
		||||
      timetableList = _removeDuplicates(data, const Duration(minutes: 5));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    List<Appointment> appointments = timetableList.map((element) {
 | 
			
		||||
 | 
			
		||||
      GetRoomsResponse rooms = data.getRoomsResponse;
 | 
			
		||||
      GetSubjectsResponse subjects = data.getSubjectsResponse;
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,9 @@ class DefaultSettings {
 | 
			
		||||
          askedForPreferredGradeSystem: false,
 | 
			
		||||
          inputs: []
 | 
			
		||||
      ),
 | 
			
		||||
      timetableSettings: TimetableSettings(),
 | 
			
		||||
      timetableSettings: TimetableSettings(
 | 
			
		||||
        connectDoubleLessons: false,
 | 
			
		||||
      ),
 | 
			
		||||
      talkSettings: TalkSettings(
 | 
			
		||||
        sortFavoritesToTop: true,
 | 
			
		||||
        sortUnreadToTop: false,
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import 'package:provider/provider.dart';
 | 
			
		||||
import 'package:shared_preferences/shared_preferences.dart';
 | 
			
		||||
 | 
			
		||||
import '../../model/accountData.dart';
 | 
			
		||||
import '../../model/timetable/timetableProps.dart';
 | 
			
		||||
import '../../notification/notifyUpdater.dart';
 | 
			
		||||
import '../../storage/base/settingsProvider.dart';
 | 
			
		||||
import '../../theming/appTheme.dart';
 | 
			
		||||
@@ -98,6 +99,20 @@ class _SettingsState extends State<Settings> {
 | 
			
		||||
 | 
			
		||||
            const Divider(),
 | 
			
		||||
 | 
			
		||||
            ListTile(
 | 
			
		||||
              leading: const Icon(Icons.calendar_view_day_outlined),
 | 
			
		||||
              title: const Text('Doppelstunden zusammenhängend anzeigen'),
 | 
			
		||||
              trailing: Checkbox(
 | 
			
		||||
                value: settings.val().timetableSettings.connectDoubleLessons,
 | 
			
		||||
                onChanged: (e) {
 | 
			
		||||
                  settings.val(write: true).timetableSettings.connectDoubleLessons = e!;
 | 
			
		||||
                  Provider.of<TimetableProps>(context, listen: false).run(renew: false);
 | 
			
		||||
                },
 | 
			
		||||
              ),
 | 
			
		||||
            ),
 | 
			
		||||
 | 
			
		||||
            const Divider(),
 | 
			
		||||
 | 
			
		||||
            ListTile(
 | 
			
		||||
              leading: const Icon(Icons.star_border),
 | 
			
		||||
              title: const Text('Favoriten im Talk nach oben sortieren'),
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 | 
			
		||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 | 
			
		||||
# In Windows, build-name is used as the major, minor, and patch parts
 | 
			
		||||
# of the product and file versions while build-number is used as the build suffix.
 | 
			
		||||
version: 0.0.7+33
 | 
			
		||||
version: 0.0.8+34
 | 
			
		||||
 | 
			
		||||
environment:
 | 
			
		||||
  sdk: '>3.0.0'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user