forked from firka/student-legacy
grade page done in summary
This commit is contained in:
parent
ce1c5eb0d8
commit
551b2849fe
@ -488,7 +488,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 3.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilc.naplo;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilctest.naplo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
@ -526,7 +526,7 @@
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilc.naplo.livecardpro;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilctest.naplo.livecardpro;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
@ -567,7 +567,7 @@
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilc.naplo.livecardpro;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilctest.naplo.livecardpro;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
@ -607,7 +607,7 @@
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilc.naplo.livecardpro;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilctest.naplo.livecardpro;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
@ -746,7 +746,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 3.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilc.naplo;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilctest.naplo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
@ -774,7 +774,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 3.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilc.naplo;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.refilctest.naplo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
|
@ -2,8 +2,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.refilcnaplo.livecard</string>
|
||||
|
@ -7,7 +7,5 @@
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
<key>NSSupportsLiveActivities</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -252,7 +252,10 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLesson != null) {
|
||||
if (now.isBefore(DateTime(now.year, DateTime.august, 31)) &&
|
||||
now.isAfter(DateTime(now.year, DateTime.june, 14))) {
|
||||
currentState = LiveCardState.summary;
|
||||
} else if (currentLesson != null) {
|
||||
currentState = LiveCardState.duringLesson;
|
||||
} else if (nextLesson != null && prevLesson != null) {
|
||||
currentState = LiveCardState.duringBreak;
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <dynamic_color/dynamic_color_plugin.h>
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <flutter_acrylic/flutter_acrylic_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
|
||||
@ -15,9 +14,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) dynamic_color_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin");
|
||||
dynamic_color_plugin_register_with_registrar(dynamic_color_registrar);
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin");
|
||||
flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar);
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
dynamic_color
|
||||
file_selector_linux
|
||||
flutter_acrylic
|
||||
url_launcher_linux
|
||||
)
|
||||
|
@ -7,7 +7,6 @@ import Foundation
|
||||
|
||||
import connectivity_plus
|
||||
import dynamic_color
|
||||
import file_selector_macos
|
||||
import flutter_local_notifications
|
||||
import macos_window_utils
|
||||
import package_info_plus
|
||||
@ -19,7 +18,6 @@ import url_launcher_macos
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
||||
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
|
||||
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
|
||||
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
|
||||
|
@ -56,9 +56,16 @@ class _LiveCardState extends State<LiveCard> {
|
||||
case LiveCardState.summary:
|
||||
child = LiveCardWidget(
|
||||
key: const Key('livecard.summary'),
|
||||
title: '',
|
||||
title: 'Vége a tanévnek! 🥳',
|
||||
icon: FeatherIcons.arrowRight,
|
||||
description: const Text(''),
|
||||
description: Text(
|
||||
'Irány az összefoglaláshoz',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18.0,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) => const SummaryScreen(
|
||||
|
@ -86,7 +86,10 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
|
||||
Text(
|
||||
widget.title ?? 'Esemény',
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24.0,
|
||||
color:
|
||||
Theme.of(context).textTheme.bodyMedium?.color,
|
||||
fontStyle:
|
||||
widget.titleItalic ? FontStyle.italic : null,
|
||||
),
|
||||
@ -96,7 +99,17 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
widget.description ??
|
||||
const Text('Nincs leírás megadva.'),
|
||||
Text(
|
||||
'Nincs leírás megadva.',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18.0,
|
||||
color: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.color,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
child: Container(
|
||||
|
@ -1,10 +1,288 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
class GradesBody extends StatelessWidget {
|
||||
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||
import 'package:filcnaplo/helpers/average_helper.dart';
|
||||
import 'package:filcnaplo/models/settings.dart';
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/empty.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/grades/grades_page.i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
|
||||
class GradesBody extends StatefulWidget {
|
||||
const GradesBody({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_GradesBodyState createState() => _GradesBodyState();
|
||||
}
|
||||
|
||||
class _GradesBodyState extends State<GradesBody> {
|
||||
late UserProvider user;
|
||||
late GradeProvider gradeProvider;
|
||||
late SettingsProvider settings;
|
||||
|
||||
late String firstName;
|
||||
late double subjectAvg;
|
||||
|
||||
List<Widget> subjectTiles5 = [];
|
||||
List<Widget> subjectTiles3 = [];
|
||||
List<Widget> subjectTiles1 = [];
|
||||
|
||||
int avgDropValue = 0;
|
||||
|
||||
List<Grade> getSubjectGrades(Subject subject, {int days = 0}) => gradeProvider
|
||||
.grades
|
||||
.where((e) =>
|
||||
e.subject == subject &&
|
||||
e.type == GradeType.midYear &&
|
||||
(days == 0 ||
|
||||
e.date.isBefore(DateTime.now().subtract(Duration(days: days)))))
|
||||
.toList();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||
}
|
||||
|
||||
void generateTiles({required int filter}) {
|
||||
List<Subject> subjects = gradeProvider.grades
|
||||
.map((e) => e.subject)
|
||||
.toSet()
|
||||
.toList()
|
||||
..sort((a, b) => a.name.compareTo(b.name));
|
||||
List<Widget> tiles = [];
|
||||
|
||||
Map<Subject, double> subjectAvgs = {};
|
||||
|
||||
tiles.addAll(subjects.map((subject) {
|
||||
List<Grade> subjectGrades = getSubjectGrades(subject);
|
||||
|
||||
double avg = AverageHelper.averageEvals(subjectGrades);
|
||||
if (avg != 0) subjectAvgs[subject] = avg;
|
||||
|
||||
if (avg.round() == filter) {
|
||||
return Row(
|
||||
children: [
|
||||
GradeValueWidget(
|
||||
GradeValue(avg.round(), '', '', 100),
|
||||
fill: true,
|
||||
size: 22.0,
|
||||
),
|
||||
Text(
|
||||
subject.renamedTo ?? subject.name.capital(),
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 18.0,
|
||||
color: AppColors.of(context).text,
|
||||
fontStyle: settings.renamedSubjectsItalics && subject.isRenamed
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
}));
|
||||
|
||||
if (tiles.isEmpty) {
|
||||
tiles.insert(0, Empty(subtitle: "empty".i18n));
|
||||
}
|
||||
|
||||
subjectAvg = subjectAvgs.isNotEmpty
|
||||
? subjectAvgs.values.fold(0.0, (double a, double b) => a + b) /
|
||||
subjectAvgs.length
|
||||
: 0.0;
|
||||
|
||||
if (filter == 5) {
|
||||
subjectTiles5 = List.castFrom(tiles);
|
||||
if (subjectTiles5.length > 5) {
|
||||
subjectTiles5.length = 5;
|
||||
}
|
||||
}
|
||||
if (filter == 3) {
|
||||
subjectTiles3 = List.castFrom(tiles);
|
||||
if (subjectTiles3.length > 3) {
|
||||
subjectTiles3.length = 3;
|
||||
}
|
||||
}
|
||||
if (filter == 1) {
|
||||
subjectTiles1 = List.castFrom(tiles);
|
||||
if (subjectTiles1.length > 2) {
|
||||
subjectTiles1.length = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column();
|
||||
user = Provider.of<UserProvider>(context);
|
||||
settings = Provider.of<SettingsProvider>(context);
|
||||
|
||||
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
||||
if (!settings.presentationMode) {
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
} else {
|
||||
firstName = "János";
|
||||
}
|
||||
|
||||
generateTiles(filter: 5);
|
||||
generateTiles(filter: 3);
|
||||
generateTiles(filter: 1);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
'Jó éved volt, $firstName!',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24.0,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Nézzük a jegyeidet... 📖',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: max(subjectTiles5.length, 1),
|
||||
itemBuilder: (context, index) {
|
||||
if (subjectTiles5.isNotEmpty) {
|
||||
EdgeInsetsGeometry panelPadding =
|
||||
const EdgeInsets.symmetric(horizontal: 24.0);
|
||||
|
||||
if (subjectTiles5[index].runtimeType == Row) {
|
||||
return subjectTiles5[index];
|
||||
} else {
|
||||
return Padding(
|
||||
padding: panelPadding, child: subjectTiles5[index]);
|
||||
}
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Text(
|
||||
'Próba teszi a mestert! 🔃',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: max(subjectTiles3.length, 1),
|
||||
itemBuilder: (context, index) {
|
||||
if (subjectTiles3.isNotEmpty) {
|
||||
EdgeInsetsGeometry panelPadding =
|
||||
const EdgeInsets.symmetric(horizontal: 24.0);
|
||||
|
||||
if (subjectTiles3[index].runtimeType == Row) {
|
||||
return subjectTiles3[index];
|
||||
} else {
|
||||
return Padding(
|
||||
padding: panelPadding, child: subjectTiles3[index]);
|
||||
}
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Text(
|
||||
'Ajajj... 🥴',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: max(subjectTiles1.length, 1),
|
||||
itemBuilder: (context, index) {
|
||||
if (subjectTiles1.isNotEmpty) {
|
||||
EdgeInsetsGeometry panelPadding =
|
||||
const EdgeInsets.symmetric(horizontal: 24.0);
|
||||
|
||||
if (subjectTiles1[index].runtimeType == Row) {
|
||||
return subjectTiles1[index];
|
||||
} else {
|
||||
return Padding(
|
||||
padding: panelPadding, child: subjectTiles1[index]);
|
||||
}
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 40.0),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Év végi átlagod',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 4.0),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
||||
decoration: BoxDecoration(
|
||||
color: gradeColor(context: context, value: subjectAvg)
|
||||
.withOpacity(.2),
|
||||
border: Border.all(
|
||||
color: (gradeColor(context: context, value: subjectAvg))
|
||||
.withOpacity(0.0),
|
||||
width: 2.0,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(45.0),
|
||||
),
|
||||
child: AutoSizeText.rich(
|
||||
TextSpan(
|
||||
text: subjectAvg.toString(),
|
||||
),
|
||||
maxLines: 1,
|
||||
minFontSize: 5,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: gradeColor(context: context, value: subjectAvg),
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 32.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LessonsBody extends StatelessWidget {
|
||||
const LessonsBody({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column();
|
||||
}
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
import 'package:confetti/confetti.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'pages/grades_page.dart';
|
||||
import 'pages/lessons_page.dart';
|
||||
import 'pages/personality_page.dart';
|
||||
|
||||
class SummaryScreen extends StatefulWidget {
|
||||
final String currentPage;
|
||||
@ -12,6 +16,8 @@ class SummaryScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SummaryScreenState extends State<SummaryScreen> {
|
||||
ConfettiController? _confettiController;
|
||||
|
||||
final LinearGradient _backgroundGradient = const LinearGradient(
|
||||
colors: [
|
||||
Color(0xff1d56ac),
|
||||
@ -22,6 +28,13 @@ class _SummaryScreenState extends State<SummaryScreen> {
|
||||
stops: [-1.0, 1.0],
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_confettiController?.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -42,10 +55,10 @@ class _SummaryScreenState extends State<SummaryScreen> {
|
||||
child: widget.currentPage == 'grades'
|
||||
? const GradesBody()
|
||||
: widget.currentPage == 'lessons'
|
||||
? const GradesBody()
|
||||
? const LessonsBody()
|
||||
: widget.currentPage == 'allsum'
|
||||
? const GradesBody()
|
||||
: const GradesBody(),
|
||||
: const PersonalityBody(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user