Skip to content

Commit

Permalink
DayView: Removed item event duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeDGreef committed Nov 10, 2020
1 parent da810df commit 784cb89
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/dayview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,14 @@ class _DayViewState extends State<DayView> {
print("Updating");
if (!this.mounted) return;
setState(() {
bool rotset = false;
this._events.clear();

for (Event lec in classes) {
// If the rotationsystem is already specified don't add it again
if (this._events.indexWhere((element) => (element == lec)) != -1) continue;

// Set the day's color
if (lec.name.toLowerCase().contains("<font color")) {
if (rotset) continue;
this._todaysColor = lec.name.toLowerCase().contains("blue") ? 0 : 1;
rotset = true;
}

int i = 0;
Expand Down
26 changes: 26 additions & 0 deletions lib/event.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:quiver/core.dart';

class Event {
String name = "";
Expand Down Expand Up @@ -70,4 +71,29 @@ class Event {
this.customColor = toCopy.customColor;
this.eventType = toCopy.eventType;
}

@override
int get hashCode {
// TODO: I don't know if this is a great idea.
return this.name.hashCode ^
this.startDate.hashCode ^
this.endDate.hashCode ^
this.location.hashCode ^
this.host.hashCode ^
this.remarks.hashCode;
}

@override
bool operator ==(Object other) {
if (!(other is Event)) return false;

Event event = other;
if (this.name == event.name &&
this.startDate == event.startDate &&
this.endDate == event.endDate &&
this.location == event.location &&
this.host == event.host &&
this.remarks == event.remarks) return true;
return false;
}
}
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,12 @@ packages:
source: hosted
version: "3.0.13"
quiver:
dependency: transitive
dependency: "direct main"
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4+1"
version: "2.1.5"
rxdart:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
version: 1.0.1

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down Expand Up @@ -60,6 +60,7 @@ dependencies:
open_file: ^3.0.3
workmanager: ^0.2.3
flutter_mailer: ^1.0.1
quiver: ^2.1.5


dev_dependencies:
Expand Down

0 comments on commit 784cb89

Please sign in to comment.