Rename everything filcnaplo-related to refilc
This commit is contained in:
@@ -1,87 +0,0 @@
|
||||
import 'package:filcnaplo/helpers/subject.dart';
|
||||
import 'package:filcnaplo/models/settings.dart';
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/average_display.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class GradeSubjectTile extends StatelessWidget {
|
||||
const GradeSubjectTile(this.subject,
|
||||
{Key? key,
|
||||
this.average = 0.0,
|
||||
this.groupAverage = 0.0,
|
||||
this.onTap,
|
||||
this.averageBefore = 0.0})
|
||||
: super(key: key);
|
||||
|
||||
final Subject subject;
|
||||
final void Function()? onTap;
|
||||
final double average;
|
||||
final double groupAverage;
|
||||
final double averageBefore;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color textColor = AppColors.of(context).text;
|
||||
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
|
||||
|
||||
// Failing indicator
|
||||
if (average < 2.0 && average >= 1.0) {
|
||||
textColor = AppColors.of(context).red;
|
||||
}
|
||||
|
||||
final String changeIcon = average < averageBefore ? "▼" : "▲";
|
||||
final Color changeColor = average < averageBefore
|
||||
? Colors.redAccent
|
||||
: Colors.lightGreenAccent.shade700;
|
||||
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: ListTile(
|
||||
minLeadingWidth: 32.0,
|
||||
dense: true,
|
||||
contentPadding: const EdgeInsets.only(left: 8.0, right: 6.0),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||
visualDensity: VisualDensity.compact,
|
||||
onTap: onTap,
|
||||
leading: Icon(
|
||||
SubjectIcon.resolveVariant(subject: subject, context: context),
|
||||
color: textColor.withOpacity(.75)),
|
||||
title: Text(
|
||||
subject.renamedTo ?? subject.name.capital(),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0,
|
||||
color: textColor,
|
||||
fontStyle: settingsProvider.renamedSubjectsItalics && subject.isRenamed ? FontStyle.italic : null),
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (groupAverage != 0 && averageBefore == 0.0)
|
||||
AverageDisplay(average: groupAverage, border: true),
|
||||
const SizedBox(width: 6.0),
|
||||
if (averageBefore != 0.0 && averageBefore != average) ...[
|
||||
AverageDisplay(average: averageBefore),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 6.0, right: 6.0, bottom: 3.5),
|
||||
child: Text(
|
||||
changeIcon,
|
||||
style: TextStyle(
|
||||
color: changeColor,
|
||||
fontSize: 20.0,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
AverageDisplay(average: average)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
import 'package:filcnaplo/models/settings.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/bottom_card.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/detail.dart';
|
||||
import 'package:filcnaplo/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'grade_view.i18n.dart';
|
||||
|
||||
class GradeView extends StatelessWidget {
|
||||
const GradeView(this.grade, {Key? key}) : super(key: key);
|
||||
|
||||
static show(Grade grade, {required BuildContext context}) =>
|
||||
showBottomCard(context: context, child: GradeView(grade));
|
||||
|
||||
final Grade grade;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: GradeValueWidget(grade.value, fill: true),
|
||||
title: Text(
|
||||
grade.subject.renamedTo ?? grade.subject.name.capital(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontStyle: grade.subject.isRenamed &&
|
||||
settingsProvider.renamedSubjectsItalics
|
||||
? FontStyle.italic
|
||||
: null),
|
||||
),
|
||||
subtitle: Text(
|
||||
!Provider.of<SettingsProvider>(context, listen: false)
|
||||
.presentationMode
|
||||
? (grade.teacher.isRenamed
|
||||
? grade.teacher.renamedTo
|
||||
: grade.teacher.name) ??
|
||||
''
|
||||
: "Tanár",
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
trailing: Text(
|
||||
grade.date.format(context),
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
|
||||
// Grade Details
|
||||
Detail(
|
||||
title: "value".i18n,
|
||||
description: "${grade.value.valueName} " + percentText(),
|
||||
),
|
||||
if (grade.description != "")
|
||||
Detail(title: "description".i18n, description: grade.description),
|
||||
if (grade.mode.description != "")
|
||||
Detail(title: "mode".i18n, description: grade.mode.description),
|
||||
if (grade.writeDate.year != 0)
|
||||
Detail(
|
||||
title: "date".i18n,
|
||||
description: grade.writeDate.format(context)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String percentText() => grade.value.weight != 100 && grade.value.weight > 0
|
||||
? "${grade.value.weight}%"
|
||||
: "";
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"value": "Value",
|
||||
"date": "Date",
|
||||
"description": "Description",
|
||||
"mode": "Type",
|
||||
},
|
||||
"hu_hu": {
|
||||
"value": "Érték",
|
||||
"date": "Írás ideje",
|
||||
"description": "Leírás",
|
||||
"mode": "Típus",
|
||||
},
|
||||
"de_de": {
|
||||
"value": "Notenwert",
|
||||
"date": "Prüfungszeit",
|
||||
"description": "Bezeichnung",
|
||||
"mode": "Typ",
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/card_handle.dart';
|
||||
import 'package:filcnaplo/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/grade/grade_view.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/viewable.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/grades/subject_grades_container.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradeViewable extends StatelessWidget {
|
||||
const GradeViewable(this.grade, {Key? key, this.padding}) : super(key: key);
|
||||
|
||||
final Grade grade;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final subject = SubjectGradesContainer.of(context) != null;
|
||||
final tile = GradeTile(grade, padding: subject ? EdgeInsets.zero : padding);
|
||||
|
||||
return Viewable(
|
||||
tile: subject ? SubjectGradesContainer(child: tile) : tile,
|
||||
view: CardHandle(child: GradeView(grade)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
import 'package:filcnaplo/models/settings.dart';
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/grade/surprise_grade.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
import 'new_grades.i18n.dart';
|
||||
|
||||
class NewGradesSurprise extends StatelessWidget {
|
||||
const NewGradesSurprise(this.grades, {Key? key, this.censored = false}) : super(key: key);
|
||||
|
||||
final List<Grade> grades;
|
||||
final bool censored;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
width: 3.0,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(14.0),
|
||||
),
|
||||
visualDensity: VisualDensity.compact,
|
||||
contentPadding: const EdgeInsets.only(left: 8.0, right: 12.0),
|
||||
onTap: () => openingFun(context),
|
||||
minLeadingWidth: 54,
|
||||
leading: SizedBox(
|
||||
width: 44,
|
||||
height: 44,
|
||||
child: Center(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(boxShadow: [
|
||||
BoxShadow(
|
||||
color: Theme.of(context).colorScheme.secondary.withOpacity(.5),
|
||||
blurRadius: 18.0,
|
||||
)
|
||||
]),
|
||||
child: const RiveAnimation.asset("assets/animations/backpack-2.riv"),
|
||||
),
|
||||
),
|
||||
),
|
||||
title: censored
|
||||
? Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: 85,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.85),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
grades.length == 1 ?
|
||||
"new_grade".i18n :
|
||||
"new_grades".i18n,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
subtitle: censored
|
||||
? Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: 125,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.45),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
"tap_to_open".i18n,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
trailing: censored
|
||||
? Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: 25,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.45),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text.rich(
|
||||
TextSpan(children: [
|
||||
TextSpan(
|
||||
text: "${grades.length}",
|
||||
style: TextStyle(
|
||||
shadows: [
|
||||
Shadow(
|
||||
color: AppColors.of(context).text.withOpacity(.2),
|
||||
offset: const Offset(2, 2),
|
||||
)
|
||||
],
|
||||
)),
|
||||
TextSpan(
|
||||
text: "x",
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
color: AppColors.of(context).text.withOpacity(.5),
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
)
|
||||
]),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 28.0,
|
||||
color: AppColors.of(context).text.withOpacity(.75),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void openingFun(BuildContext context) {
|
||||
final settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||
if (!settings.gradeOpeningFun) return;
|
||||
|
||||
final gradeProvider = Provider.of<GradeProvider>(context, listen: false);
|
||||
|
||||
final newGrades = gradeProvider.grades.where((element) => element.date.isAfter(gradeProvider.lastSeenDate)).toList();
|
||||
newGrades.sort((a, b) => a.date.compareTo(b.date));
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
for (final grade in newGrades) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) => SurpriseGrade(grade),
|
||||
useRootNavigator: true,
|
||||
barrierDismissible: false,
|
||||
barrierColor: Colors.transparent,
|
||||
useSafeArea: false,
|
||||
);
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
}
|
||||
await gradeProvider.seenAll();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"common": "Common",
|
||||
"uncommon": "Uncommon",
|
||||
"rare": "Rare",
|
||||
"epic": "Epic",
|
||||
"legendary": "Legendary",
|
||||
"new_grade": "New grade",
|
||||
"new_grades": "New grades",
|
||||
"tap_to_open": "Tap to open now!",
|
||||
"open_subtitle": "Tap to open...",
|
||||
},
|
||||
"hu_hu": {
|
||||
"common": "Gyakori",
|
||||
"uncommon": "Nem gyakori",
|
||||
"rare": "Ritka",
|
||||
"epic": "Epikus",
|
||||
"legendary": "Legendás",
|
||||
"new_grade": "Új jegy",
|
||||
"new_grades": "Új jegyek",
|
||||
"tap_to_open": "Nyisd ki őket!",
|
||||
"open_subtitle": "Nyomd meg a kinyitáshoz...",
|
||||
},
|
||||
"de_de": {
|
||||
"common": "Gemeinsam",
|
||||
"uncommon": "Gelegentlich",
|
||||
"rare": "Selten",
|
||||
"epic": "Episch",
|
||||
"legendary": "Legendär",
|
||||
"new_grade": "Neue Note",
|
||||
"new_grades": "Neue Noten",
|
||||
"tap_to_open": "Tippen, um jetzt zu öffnen!",
|
||||
"open_subtitle": "Antippen zum Öffnen...",
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,389 +0,0 @@
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:animated_background/animated_background.dart' as bg;
|
||||
import 'package:filcnaplo/helpers/subject.dart';
|
||||
import 'package:filcnaplo/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/home/particle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'package:rive/rive.dart' as rive;
|
||||
|
||||
import 'new_grades.i18n.dart';
|
||||
|
||||
class SurpriseGrade extends StatefulWidget {
|
||||
const SurpriseGrade(this.grade, {Key? key}) : super(key: key);
|
||||
|
||||
final Grade grade;
|
||||
|
||||
@override
|
||||
State<SurpriseGrade> createState() => _SurpriseGradeState();
|
||||
}
|
||||
|
||||
class _SurpriseGradeState extends State<SurpriseGrade> with TickerProviderStateMixin {
|
||||
late AnimationController _revealAnimFade;
|
||||
late AnimationController _revealAnimScale;
|
||||
late AnimationController _revealAnimGrade;
|
||||
late AnimationController _revealAnimParticle;
|
||||
late rive.RiveAnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_revealAnimFade = AnimationController(vsync: this, duration: const Duration(milliseconds: 500));
|
||||
_revealAnimScale = AnimationController(vsync: this, duration: const Duration(milliseconds: 300));
|
||||
_revealAnimGrade = AnimationController(vsync: this, duration: const Duration(seconds: 1));
|
||||
_revealAnimParticle = AnimationController(vsync: this, duration: const Duration(seconds: 2));
|
||||
_revealAnimScale.animateTo(0.7, duration: Duration.zero);
|
||||
_controller = rive.SimpleAnimation('Timeline 1', autoplay: false);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_revealAnimFade.animateTo(1.0, curve: Curves.easeInOut);
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
_revealAnimScale.animateTo(1.0, curve: Curves.easeInOut).then((_) {
|
||||
setState(() => subtitle = true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
seed = Random().nextInt(100000000);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_revealAnimFade.dispose();
|
||||
_revealAnimScale.dispose();
|
||||
_revealAnimGrade.dispose();
|
||||
_revealAnimParticle.dispose();
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool hold = false;
|
||||
bool subtitle = false;
|
||||
late int seed;
|
||||
|
||||
void reveal() async {
|
||||
if (!subtitle) {
|
||||
_revealAnimParticle.animateBack(0.0, curve: Curves.fastLinearToSlowEaseIn, duration: const Duration(milliseconds: 300));
|
||||
await Future.delayed(const Duration(milliseconds: 50));
|
||||
_revealAnimGrade.animateBack(0.0, curve: Curves.fastLinearToSlowEaseIn);
|
||||
await Future.delayed(const Duration(milliseconds: 50));
|
||||
_revealAnimFade.animateBack(0.0, curve: Curves.easeInOut);
|
||||
_revealAnimScale.animateBack(0.0, curve: Curves.easeInOut);
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
subtitle = false;
|
||||
setState(() => hold = false);
|
||||
_controller.isActive = true;
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
if (mounted) _revealAnimGrade.animateTo(1.0, curve: Curves.fastLinearToSlowEaseIn);
|
||||
await Future.delayed(const Duration(milliseconds: 700));
|
||||
if (mounted) await _revealAnimParticle.animateTo(1.0, curve: Curves.fastLinearToSlowEaseIn);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _revealAnimFade,
|
||||
builder: (context, child) {
|
||||
return FadeTransition(
|
||||
opacity: _revealAnimFade,
|
||||
child: Material(
|
||||
color: Colors.black.withOpacity(.75),
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.secondary.withOpacity(.05),
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: RadialGradient(
|
||||
colors: [Colors.transparent, Colors.black],
|
||||
radius: 1.5,
|
||||
stops: [0.2, 1.0],
|
||||
),
|
||||
),
|
||||
child: bg.AnimatedBackground(
|
||||
vsync: this,
|
||||
behaviour: bg.RandomParticleBehaviour(
|
||||
options: bg.ParticleOptions(
|
||||
baseColor: Theme.of(context).colorScheme.secondary,
|
||||
spawnMinSpeed: 5.0,
|
||||
spawnMaxSpeed: 10.0,
|
||||
minOpacity: .05,
|
||||
maxOpacity: .08,
|
||||
spawnMinRadius: 30.0,
|
||||
spawnMaxRadius: 50.0,
|
||||
particleCount: 20,
|
||||
),
|
||||
),
|
||||
child: ScaleTransition(
|
||||
scale: _revealAnimScale,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: AnimatedBuilder(
|
||||
animation: _revealAnimGrade,
|
||||
builder: (context, child) {
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SlideTransition(
|
||||
position: _revealAnimGrade.drive(Tween(begin: Offset.zero, end: const Offset(0, 0.7))),
|
||||
child: AnimatedScale(
|
||||
scale: hold ? 1.1 : 1.0,
|
||||
curve: Curves.easeOutBack,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: GestureDetector(
|
||||
onLongPressDown: (_) => setState(() => hold = true),
|
||||
onLongPressEnd: (_) => reveal(),
|
||||
onLongPressCancel: reveal,
|
||||
child: ScaleTransition(
|
||||
scale: CurvedAnimation(curve: Curves.easeInOut, parent: _revealAnimGrade.drive(Tween(begin: 1.0, end: 0.8))),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 300,
|
||||
height: 300,
|
||||
child: rive.RiveAnimation.asset(
|
||||
"assets/animations/backpack-2.riv",
|
||||
fit: BoxFit.contain,
|
||||
controllers: [_controller],
|
||||
antialiasing: false,
|
||||
),
|
||||
),
|
||||
SlideTransition(
|
||||
position: _revealAnimParticle.drive(Tween(begin: const Offset(0, 0.3), end: const Offset(0, 0.8))),
|
||||
child: FadeTransition(
|
||||
opacity: _revealAnimParticle,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 32.0, sigmaY: 32.0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32.0, vertical: 20.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(.3),
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
border: Border.all(color: Colors.black.withOpacity(.3), width: 1.0),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (widget.grade.description != "")
|
||||
Text(
|
||||
widget.grade.description,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 26.0,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
widget.grade.subject.renamedTo ?? widget.grade.subject.name.capital(),
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(.8),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24.0,
|
||||
fontStyle: widget.grade.subject.isRenamed ? FontStyle.italic : null),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
"${widget.grade.value.weight}%",
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(.7),
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 20.0,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 20.0),
|
||||
Icon(
|
||||
SubjectIcon.resolveVariant(subject: widget.grade.subject, context: context),
|
||||
color: Colors.white,
|
||||
size: 82.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 42.0),
|
||||
AnimatedOpacity(
|
||||
opacity: subtitle ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: Text(
|
||||
"open_subtitle".i18n,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(.8),
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 24.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_revealAnimGrade.value > 0)
|
||||
AnimatedBuilder(
|
||||
animation: _revealAnimParticle,
|
||||
builder: (context, child) {
|
||||
bool shouldPaint = false;
|
||||
if (_revealAnimParticle.status == AnimationStatus.forward || _revealAnimParticle.status == AnimationStatus.reverse) {
|
||||
shouldPaint = true;
|
||||
}
|
||||
return ScaleTransition(
|
||||
scale: _revealAnimGrade,
|
||||
child: FadeTransition(
|
||||
opacity: _revealAnimGrade,
|
||||
child: SlideTransition(
|
||||
position: _revealAnimGrade.drive(Tween(begin: Offset.zero, end: const Offset(0, -0.6))),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SlideTransition(
|
||||
position: _revealAnimGrade.drive(Tween(begin: Offset.zero, end: const Offset(0, -0.9))),
|
||||
child: Text(
|
||||
["legendary", "epic", "rare", "uncommon", "common"][5 - widget.grade.value.value].i18n,
|
||||
style: TextStyle(
|
||||
fontSize: 46.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: gradeColor(context: context, value: widget.grade.value.value),
|
||||
shadows: [
|
||||
Shadow(
|
||||
color: gradeColor(context: context, value: widget.grade.value.value).withOpacity(.5),
|
||||
blurRadius: 24.0,
|
||||
),
|
||||
Shadow(
|
||||
color: gradeColor(context: context, value: widget.grade.value.value).withOpacity(.3),
|
||||
offset: const Offset(-3, -3),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32.0),
|
||||
ScaleTransition(
|
||||
scale: CurvedAnimation(curve: Curves.easeInOutBack, parent: _revealAnimParticle.drive(Tween(begin: 0.6, end: 1.0))),
|
||||
child: CustomPaint(
|
||||
painter: PimpPainter(
|
||||
particle: Sprinkles(),
|
||||
controller: _revealAnimParticle,
|
||||
seed: seed + 1,
|
||||
shouldPaint: shouldPaint,
|
||||
),
|
||||
child: CustomPaint(
|
||||
painter: PimpPainter(
|
||||
particle: Sprinkles(),
|
||||
controller: _revealAnimParticle,
|
||||
seed: seed,
|
||||
shouldPaint: shouldPaint,
|
||||
),
|
||||
child: RotationTransition(
|
||||
turns:
|
||||
CurvedAnimation(curve: Curves.easeInBack, parent: _revealAnimGrade).drive(Tween(begin: 0.95, end: 1.0)),
|
||||
child: GradeValueWidget(
|
||||
widget.grade.value,
|
||||
fill: true,
|
||||
contrast: true,
|
||||
shadow: true,
|
||||
outline: true,
|
||||
size: 100.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PimpPainter extends CustomPainter {
|
||||
PimpPainter({required this.particle, required this.seed, required this.controller, required this.shouldPaint}) : super(repaint: controller);
|
||||
|
||||
final Particle particle;
|
||||
final int seed;
|
||||
final AnimationController controller;
|
||||
final bool shouldPaint;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
if (shouldPaint) {
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
particle.paint(canvas, size, controller.value, seed);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(PimpPainter oldDelegate) => shouldPaint;
|
||||
}
|
||||
|
||||
Color randomColor(int c) {
|
||||
c = c % 5;
|
||||
if (c == 0) return Colors.red.shade300;
|
||||
if (c == 1) return Colors.green.shade300;
|
||||
if (c == 2) return Colors.orange.shade300;
|
||||
if (c == 3) return Colors.blue.shade300;
|
||||
if (c == 4) return Colors.pink.shade300;
|
||||
if (c == 5) return Colors.brown.shade300;
|
||||
return Colors.black;
|
||||
}
|
||||
|
||||
class Sprinkles extends Particle {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size, progress, seed) {
|
||||
Random random = Random(seed);
|
||||
int randomMirrorOffset = random.nextInt(8) + 1;
|
||||
CompositeParticle(children: [
|
||||
Firework(),
|
||||
RectangleMirror.builder(
|
||||
numberOfParticles: 6,
|
||||
particleBuilder: (n) {
|
||||
return AnimatedPositionedParticle(
|
||||
begin: const Offset(0.0, -10.0),
|
||||
end: const Offset(0.0, -60.0),
|
||||
child: FadingRect(width: 5.0, height: 15.0, color: randomColor(n)),
|
||||
);
|
||||
},
|
||||
initialDistance: -pi / randomMirrorOffset),
|
||||
]).paint(canvas, size, progress, seed);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user