Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 255 additions & 59 deletions folio_kreta_api/lib/demo/demo_data.dart

Large diffs are not rendered by default.

56 changes: 40 additions & 16 deletions folio_kreta_api/lib/models/grade.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Grade {
DateTime writeDate;
DateTime seenDate;
String form;
String rarity;

Grade({
required this.id,
Expand All @@ -36,24 +37,27 @@ class Grade {
required this.writeDate,
required this.seenDate,
required this.form,
required this.rarity,
this.json,
});

factory Grade.fromJson(Map json) {
var gradeValue = GradeValue(
json["SzamErtek"] ?? 0,
json["SzovegesErtek"] ?? "",
json["SzovegesErtekelesRovidNev"] ?? "",
json["SulySzazalekErteke"] ?? 0,
percentage: json["ErtekFajta"] != null
? json["ErtekFajta"]["Uid"] == "3,Szazalekos"
: false,
);

return Grade(
id: json["Uid"] ?? "",
date: json["KeszitesDatuma"] != null
? DateTime.parse(json["KeszitesDatuma"]).toLocal()
: DateTime(0),
value: GradeValue(
json["SzamErtek"] ?? 0,
json["SzovegesErtek"] ?? "",
json["SzovegesErtekelesRovidNev"] ?? "",
json["SulySzazalekErteke"] ?? 0,
percentage: json["ErtekFajta"] != null
? json["ErtekFajta"]["Uid"] == "3,Szazalekos"
: false,
),
value: gradeValue,
teacher: Teacher.fromString((json["ErtekeloTanarNeve"] ?? "").trim()),
description: json["Tema"] ?? "",
type: json["Tipus"] != null
Expand All @@ -71,22 +75,24 @@ class Grade {
seenDate: json["LattamozasDatuma"] != null
? DateTime.parse(json["LattamozasDatuma"]).toLocal()
: DateTime(0),
rarity: gradeValue.getRarity(),
form: (json["Jelleg"] ?? "Na") != "Na" ? json["Jelleg"] : "",
json: json,
);
}

factory Grade.fromExportJson(Map json) {
var gradeValue = GradeValue(
json["value"] ?? 0,
json["value_name"] ?? "",
json["value_name"] ?? "",
json["weight"] ?? 0,
percentage: false,
);
return Grade(
id: const Uuid().v4(),
date: json["date"] != null ? DateTime.parse(json["date"]) : DateTime(0),
value: GradeValue(
json["value"] ?? 0,
json["value_name"] ?? "",
json["value_name"] ?? "",
json["weight"] ?? 0,
percentage: false,
),
value: gradeValue,
teacher: Teacher.fromString((json["teacher"] ?? "").trim()),
description: json["description"] ?? "",
type: json["type"] != null
Expand All @@ -105,6 +111,7 @@ class Grade {
json["date"] != null ? DateTime.parse(json["date"]) : DateTime(0),
seenDate:
json["date"] != null ? DateTime.parse(json["date"]) : DateTime(0),
rarity: gradeValue.getRarity(),
form: "",
json: json,
);
Expand Down Expand Up @@ -177,6 +184,23 @@ class GradeValue {
_valueName = valueName,
_weight = weight,
_percentage = percentage;

String getRarity() {
switch (value) {
case 5:
return "legendary";
case 4:
return "epic";
case 3:
return "rare";
case 2:
return "uncommon";
case 1:
return "common";
default:
return "legendary";
}
}
}

enum GradeType {
Expand Down
16 changes: 8 additions & 8 deletions folio_kreta_api/lib/providers/grade_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ class GradeProvider with ChangeNotifier {
}
}

Future<void> unseenAll() async {
String? userId = _user.id;
if (userId != null) {
final userStore = _database.userStore;
await userStore.storeLastSeen(DateTime(1969),
userId: userId, category: LastSeenCategory.surprisegrade);
_lastSeen = DateTime(1969);
Future<void> unseenAll() async {
String? userId = _user.id;
if (userId != null) {
final userStore = _database.userStore;
await userStore.storeLastSeen(DateTime(1969),
userId: userId, category: LastSeenCategory.surprisegrade);
_lastSeen = DateTime(1969);
}
}
}

Future<void> restore() async {
String? userId = _user.id;
Expand Down
29 changes: 14 additions & 15 deletions folio_mobile_ui/lib/common/widgets/grade/new_grades.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,20 @@ class NewGradesSurprise extends StatelessWidget {
height: 44,
child: Center(
child: Container(
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Theme.of(context)
.colorScheme
.secondary
.withValues(alpha: .5),
blurRadius: 18.0,
)
]),
child: Icon(
Icons.backpack,
size: 36.0,
color: Theme.of(context).colorScheme.secondary,
)
),
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Theme.of(context)
.colorScheme
.secondary
.withValues(alpha: .5),
blurRadius: 18.0,
)
]),
child: Icon(
Icons.backpack,
size: 36.0,
color: Theme.of(context).colorScheme.secondary,
)),
),
),
title: censored
Expand Down
Loading