Revert "Rename everything filcnaplo-related to refilc"
This reverts commit d1a9625d93.
This commit is contained in:
108
filcnaplo_mobile_ui/lib/common/widgets/cretification/certification_card.dart
Executable file
108
filcnaplo_mobile_ui/lib/common/widgets/cretification/certification_card.dart
Executable file
@@ -0,0 +1,108 @@
|
||||
import 'package:filcnaplo/helpers/average_helper.dart';
|
||||
import 'package:i18n_extension/i18n_widget.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/cretification/certification_view.dart';
|
||||
import 'package:filcnaplo/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'certification_card.i18n.dart';
|
||||
|
||||
class CertificationCard extends StatelessWidget {
|
||||
const CertificationCard(this.grades, {Key? key, required this.gradeType, this.padding}) : super(key: key);
|
||||
|
||||
final List<Grade> grades;
|
||||
final GradeType gradeType;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String title = getGradeTypeTitle(gradeType);
|
||||
double average = AverageHelper.averageEvals(grades, finalAvg: true);
|
||||
String averageText = average.toStringAsFixed(1);
|
||||
if (I18n.of(context).locale.languageCode != "en") averageText = averageText.replaceAll(".", ",");
|
||||
Color color = gradeColor(context: context, value: average);
|
||||
Color textColor;
|
||||
|
||||
if (color.computeLuminance() >= .5) {
|
||||
textColor = Colors.black;
|
||||
} else {
|
||||
textColor = Colors.white;
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: padding ?? const EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
gradient: LinearGradient(
|
||||
colors: [color, color.withOpacity(.75)],
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
|
||||
leading: Text(
|
||||
averageText,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24.0,
|
||||
),
|
||||
),
|
||||
title: Text.rich(
|
||||
TextSpan(
|
||||
text: title,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: " • ${grades.length}",
|
||||
style: TextStyle(
|
||||
color: textColor.withOpacity(.75),
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
),
|
||||
trailing: Icon(FeatherIcons.arrowRight, color: textColor),
|
||||
onTap: () => CertificationView.show(grades, context: context, gradeType: gradeType),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String getGradeTypeTitle(GradeType gradeType) {
|
||||
String title;
|
||||
|
||||
switch (gradeType) {
|
||||
case GradeType.halfYear:
|
||||
title = "mid".i18n;
|
||||
break;
|
||||
case GradeType.firstQ:
|
||||
title = "1q".i18n;
|
||||
break;
|
||||
case GradeType.secondQ:
|
||||
title = "2q".i18n;
|
||||
break;
|
||||
case GradeType.thirdQ:
|
||||
title = "3q".i18n;
|
||||
break;
|
||||
case GradeType.fourthQ:
|
||||
title = "4q".i18n;
|
||||
break;
|
||||
default:
|
||||
title = "final".i18n;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"final": "Final grades",
|
||||
"mid": "Midterm grades",
|
||||
"1q": "1. Quarter grades",
|
||||
"2q": "2. Quarter grades",
|
||||
"3q": "3. Quarter grades",
|
||||
"4q": "4. Quarter grades",
|
||||
},
|
||||
"hu_hu": {
|
||||
"final": "Év végi jegyek",
|
||||
"mid": "Félévi jegyek",
|
||||
"1q": "1. Negyedéves jegyek",
|
||||
"2q": "2. Negyedéves jegyek",
|
||||
"3q": "3. Negyedéves jegyek",
|
||||
"4q": "4. Negyedéves jegyek",
|
||||
},
|
||||
"de_de": {
|
||||
"final": "Zeugnis Noten",
|
||||
"mid": "Halbjährlich Noten",
|
||||
"1q": "1. Quartal Noten",
|
||||
"2q": "2. Quartal Noten",
|
||||
"3q": "3. Quartal Noten",
|
||||
"4q": "4. Quartal Noten",
|
||||
}
|
||||
};
|
||||
|
||||
String get i18n => localize(this, _t);
|
||||
String fill(List<Object> params) => localizeFill(this, params);
|
||||
String plural(int value) => localizePlural(value, this, _t);
|
||||
String version(Object modifier) => localizeVersion(modifier, this, _t);
|
||||
}
|
||||
91
filcnaplo_mobile_ui/lib/common/widgets/cretification/certification_tile.dart
Executable file
91
filcnaplo_mobile_ui/lib/common/widgets/cretification/certification_tile.dart
Executable file
@@ -0,0 +1,91 @@
|
||||
import 'package:filcnaplo/helpers/subject.dart';
|
||||
import 'package:filcnaplo/models/settings.dart';
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/grades/subject_grades_container.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'certification_tile.i18n.dart';
|
||||
|
||||
class CertificationTile extends StatelessWidget {
|
||||
const CertificationTile(this.grade, {Key? key, this.onTap, this.padding}) : super(key: key);
|
||||
|
||||
final Function()? onTap;
|
||||
final Grade grade;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isSubjectView = SubjectGradesContainer.of(context) != null;
|
||||
String certificationName;
|
||||
|
||||
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
|
||||
|
||||
switch (grade.type) {
|
||||
case GradeType.endYear:
|
||||
certificationName = "final".i18n;
|
||||
break;
|
||||
case GradeType.halfYear:
|
||||
certificationName = "mid".i18n;
|
||||
break;
|
||||
case GradeType.firstQ:
|
||||
certificationName = "1q".i18n;
|
||||
break;
|
||||
case GradeType.secondQ:
|
||||
certificationName = "2q".i18n;
|
||||
break;
|
||||
case GradeType.thirdQ:
|
||||
certificationName = "3q".i18n;
|
||||
break;
|
||||
case GradeType.fourthQ:
|
||||
certificationName = "4q".i18n;
|
||||
break;
|
||||
case GradeType.levelExam:
|
||||
certificationName = "equivalency".i18n;
|
||||
break;
|
||||
case GradeType.unknown:
|
||||
default:
|
||||
certificationName = "unknown".i18n;
|
||||
}
|
||||
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: Padding(
|
||||
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: ListTile(
|
||||
visualDensity: VisualDensity.compact,
|
||||
contentPadding:
|
||||
isSubjectView ? const EdgeInsets.only(left: 12.0, right: 12.0, top: 2.0, bottom: 8.0) : const EdgeInsets.only(left: 8.0, right: 12.0),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||
onTap: onTap,
|
||||
leading: isSubjectView
|
||||
? GradeValueWidget(
|
||||
grade.value,
|
||||
complemented: grade.description == 'Dicséret',
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(left: 2.0),
|
||||
child: Icon(SubjectIcon.resolveVariant(subject: grade.subject, context: context),
|
||||
size: 28.0, color: AppColors.of(context).text.withOpacity(.75)),
|
||||
),
|
||||
minLeadingWidth: isSubjectView ? 32.0 : 42.0,
|
||||
trailing: isSubjectView
|
||||
? const Icon(FeatherIcons.award)
|
||||
: GradeValueWidget(
|
||||
grade.value,
|
||||
complemented: grade.description == 'Dicséret',
|
||||
),
|
||||
title: Text(isSubjectView ? certificationName : grade.subject.renamedTo ?? grade.subject.name.capital(),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0, fontStyle: grade.subject.isRenamed && settingsProvider.renamedSubjectsItalics ? FontStyle.italic : null)),
|
||||
subtitle: Text(grade.value.valueName, style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16.0)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"final": "Final",
|
||||
"mid": "Mid year",
|
||||
"1q": "1. Quarter",
|
||||
"2q": "2. Quarter",
|
||||
"3q": "3. Quarter",
|
||||
"4q": "4. Quarter",
|
||||
"equivalency": "Equivalency test",
|
||||
"unknown": "Unknown",
|
||||
"classavg": "Class Average",
|
||||
},
|
||||
"hu_hu": {
|
||||
"final": "Év vége",
|
||||
"mid": "Félév",
|
||||
"1q": "1. Negyedév",
|
||||
"2q": "2. Negyedév",
|
||||
"3q": "3. Negyedév",
|
||||
"4q": "4. Negyedév",
|
||||
"equivalency": "Osztályozó",
|
||||
"unknown": "Ismeretlen",
|
||||
"classavg": "Osztályátlag",
|
||||
},
|
||||
"de_de": {
|
||||
"final": "Zeugnis",
|
||||
"mid": "Halbjährlich",
|
||||
"1q": "1. Quartal",
|
||||
"2q": "2. Quartal",
|
||||
"3q": "3. Quartal",
|
||||
"4q": "4. Quartal",
|
||||
"equivalency": "Zulassungsprüfung",
|
||||
"unknown": "Unbekannt",
|
||||
"classavg": "Klassendurchschnitt",
|
||||
}
|
||||
};
|
||||
|
||||
String get i18n => localize(this, _t);
|
||||
String fill(List<Object> params) => localizeFill(this, params);
|
||||
String plural(int value) => localizePlural(value, this, _t);
|
||||
String version(Object modifier) => localizeVersion(modifier, this, _t);
|
||||
}
|
||||
43
filcnaplo_mobile_ui/lib/common/widgets/cretification/certification_view.dart
Executable file
43
filcnaplo_mobile_ui/lib/common/widgets/cretification/certification_view.dart
Executable file
@@ -0,0 +1,43 @@
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/cretification/certification_card.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/cretification/certification_tile.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/hero_scrollview.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
|
||||
class CertificationView extends StatelessWidget {
|
||||
const CertificationView(this.grades, {Key? key, required this.gradeType}) : super(key: key);
|
||||
|
||||
final List<Grade> grades;
|
||||
final GradeType gradeType;
|
||||
|
||||
static show(List<Grade> grades, {required BuildContext context, required GradeType gradeType}) =>
|
||||
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(builder: (context) => CertificationView(grades, gradeType: gradeType)));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
grades.sort((a, b) => a.subject.name.compareTo(b.subject.name));
|
||||
List<Widget> tiles = grades.map((e) => CertificationTile(e)).toList();
|
||||
return Scaffold(
|
||||
body: HeroScrollView(
|
||||
title: getGradeTypeTitle(gradeType),
|
||||
icon: FeatherIcons.award,
|
||||
iconSize: 50,
|
||||
child: ListView(
|
||||
children: [
|
||||
SafeArea(
|
||||
child: Panel(
|
||||
child: Column(
|
||||
children: tiles,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 24.0),
|
||||
physics: const BouncingScrollPhysics(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user