forked from firka/student-legacy
fix weird code
This commit is contained in:
parent
11d99a4cf9
commit
c6633be301
@ -251,17 +251,11 @@ Widget filterItemBuilder(
|
|||||||
: const EdgeInsets.symmetric(vertical: 4.0),
|
: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.background,
|
color: Theme.of(context).colorScheme.background,
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.vertical(
|
||||||
topLeft: index == 0
|
top: index == 0
|
||||||
? const Radius.circular(16.0)
|
? const Radius.circular(16.0)
|
||||||
: const Radius.circular(8.0),
|
: const Radius.circular(8.0),
|
||||||
topRight: index == 0
|
bottom: index + 1 == len
|
||||||
? const Radius.circular(16.0)
|
|
||||||
: const Radius.circular(8.0),
|
|
||||||
bottomLeft: index + 1 == len
|
|
||||||
? const Radius.circular(16.0)
|
|
||||||
: const Radius.circular(8.0),
|
|
||||||
bottomRight: index + 1 == len
|
|
||||||
? const Radius.circular(16.0)
|
? const Radius.circular(16.0)
|
||||||
: const Radius.circular(8.0),
|
: const Radius.circular(8.0),
|
||||||
),
|
),
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
import 'package:filcnaplo/ui/date_widget.dart';
|
import 'package:filcnaplo/ui/date_widget.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/widgets/cretification/certification_card.dart' as mobile;
|
import 'package:filcnaplo_mobile_ui/common/widgets/cretification/certification_card.dart'
|
||||||
|
as mobile;
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
List<DateWidget> getWidgets(List<Grade> providerGrades) {
|
List<DateWidget> getWidgets(List<Grade> providerGrades) {
|
||||||
List<DateWidget> items = [];
|
List<DateWidget> items = [];
|
||||||
for (var gradeType in GradeType.values) {
|
for (var gradeType in GradeType.values) {
|
||||||
if ([GradeType.midYear, GradeType.unknown, GradeType.levelExam].contains(gradeType)) continue;
|
if ([GradeType.midYear, GradeType.unknown, GradeType.levelExam]
|
||||||
|
.contains(gradeType)) continue;
|
||||||
|
|
||||||
List<Grade> grades = providerGrades.where((grade) => grade.type == gradeType).toList();
|
List<Grade> grades =
|
||||||
|
providerGrades.where((grade) => grade.type == gradeType).toList();
|
||||||
if (grades.isNotEmpty) {
|
if (grades.isNotEmpty) {
|
||||||
grades.sort((a, b) => -a.date.compareTo(b.date));
|
grades.sort((a, b) => -a.date.compareTo(b.date));
|
||||||
|
|
||||||
items.add(DateWidget(
|
items.add(DateWidget(
|
||||||
date: grades.first.date,
|
date: grades.first.date,
|
||||||
|
key: 'certification${const Uuid().v4()}',
|
||||||
widget: mobile.CertificationCard(
|
widget: mobile.CertificationCard(
|
||||||
grades,
|
grades,
|
||||||
gradeType: gradeType,
|
gradeType: gradeType,
|
||||||
|
@ -8,7 +8,8 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
|||||||
import 'certification_card.i18n.dart';
|
import 'certification_card.i18n.dart';
|
||||||
|
|
||||||
class CertificationCard extends StatelessWidget {
|
class CertificationCard extends StatelessWidget {
|
||||||
const CertificationCard(this.grades, {super.key, required this.gradeType, this.padding});
|
const CertificationCard(this.grades,
|
||||||
|
{super.key, required this.gradeType, this.padding});
|
||||||
|
|
||||||
final List<Grade> grades;
|
final List<Grade> grades;
|
||||||
final GradeType gradeType;
|
final GradeType gradeType;
|
||||||
@ -19,7 +20,9 @@ class CertificationCard extends StatelessWidget {
|
|||||||
String title = getGradeTypeTitle(gradeType);
|
String title = getGradeTypeTitle(gradeType);
|
||||||
double average = AverageHelper.averageEvals(grades, finalAvg: true);
|
double average = AverageHelper.averageEvals(grades, finalAvg: true);
|
||||||
String averageText = average.toStringAsFixed(1);
|
String averageText = average.toStringAsFixed(1);
|
||||||
if (I18n.of(context).locale.languageCode != "en") averageText = averageText.replaceAll(".", ",");
|
if (I18n.of(context).locale.languageCode != "en") {
|
||||||
|
averageText = averageText.replaceAll(".", ",");
|
||||||
|
}
|
||||||
Color color = gradeColor(context: context, value: average);
|
Color color = gradeColor(context: context, value: average);
|
||||||
Color textColor;
|
Color textColor;
|
||||||
|
|
||||||
@ -30,7 +33,8 @@ class CertificationCard extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: padding ?? const EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
|
padding:
|
||||||
|
padding ?? const EdgeInsets.symmetric(vertical: 2.0, horizontal: 6.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
@ -42,8 +46,10 @@ class CertificationCard extends StatelessWidget {
|
|||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
contentPadding:
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
|
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12.0)),
|
||||||
leading: Text(
|
leading: Text(
|
||||||
averageText,
|
averageText,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@ -73,7 +79,8 @@ class CertificationCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
trailing: Icon(FeatherIcons.arrowRight, color: textColor),
|
trailing: Icon(FeatherIcons.arrowRight, color: textColor),
|
||||||
onTap: () => CertificationView.show(grades, context: context, gradeType: gradeType),
|
onTap: () => CertificationView.show(grades,
|
||||||
|
context: context, gradeType: gradeType),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user