forked from firka/student-legacy
progress in new subject page
This commit is contained in:
parent
98efdfd8cf
commit
7f88c8c3e1
@ -1,3 +1,5 @@
|
|||||||
|
import 'package:refilc_kreta_api/models/teacher.dart';
|
||||||
|
|
||||||
import 'category.dart';
|
import 'category.dart';
|
||||||
|
|
||||||
class GradeSubject {
|
class GradeSubject {
|
||||||
@ -6,6 +8,7 @@ class GradeSubject {
|
|||||||
String name;
|
String name;
|
||||||
String? renamedTo;
|
String? renamedTo;
|
||||||
double? customRounding;
|
double? customRounding;
|
||||||
|
Teacher? teacher;
|
||||||
|
|
||||||
bool get isRenamed => renamedTo != null;
|
bool get isRenamed => renamedTo != null;
|
||||||
bool get hasCustomRounding => customRounding != null;
|
bool get hasCustomRounding => customRounding != null;
|
||||||
@ -17,6 +20,7 @@ class GradeSubject {
|
|||||||
this.renamedTo,
|
this.renamedTo,
|
||||||
// v5
|
// v5
|
||||||
this.customRounding,
|
this.customRounding,
|
||||||
|
this.teacher,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory GradeSubject.fromJson(Map json) {
|
factory GradeSubject.fromJson(Map json) {
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
import 'package:refilc/theme/colors/colors.dart';
|
import 'package:refilc/theme/colors/colors.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:refilc/utils/format.dart';
|
import 'package:refilc/utils/format.dart';
|
||||||
|
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
||||||
|
|
||||||
class HeroScrollView extends StatefulWidget {
|
class HeroScrollView extends StatefulWidget {
|
||||||
const HeroScrollView(
|
const HeroScrollView({
|
||||||
{super.key,
|
super.key,
|
||||||
required this.child,
|
required this.child,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
this.italic = false,
|
this.italic = false,
|
||||||
this.navBarItems = const [],
|
this.navBarItems = const [],
|
||||||
this.onClose,
|
this.onClose,
|
||||||
this.iconSize = 64.0,
|
this.iconSize = 64.0,
|
||||||
this.scrollController});
|
this.scrollController,
|
||||||
|
this.showTitleUnscroll = true,
|
||||||
|
});
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final String title;
|
final String title;
|
||||||
@ -22,6 +25,7 @@ class HeroScrollView extends StatefulWidget {
|
|||||||
final double iconSize;
|
final double iconSize;
|
||||||
final ScrollController? scrollController;
|
final ScrollController? scrollController;
|
||||||
final bool italic;
|
final bool italic;
|
||||||
|
final bool showTitleUnscroll;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
HeroScrollViewState createState() => HeroScrollViewState();
|
HeroScrollViewState createState() => HeroScrollViewState();
|
||||||
@ -97,34 +101,43 @@ class HeroScrollViewState extends State<HeroScrollView> {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
actions: widget.navBarItems,
|
actions: widget.navBarItems,
|
||||||
expandedHeight: 145.69,
|
expandedHeight: 155.69,
|
||||||
stretch: true,
|
stretch: true,
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
background: Stack(
|
background: Stack(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
child: Icon(
|
child: Padding(
|
||||||
widget.icon,
|
padding: const EdgeInsets.only(top: 46.0),
|
||||||
size: widget.iconSize,
|
child: RoundBorderIcon(
|
||||||
color: AppColors.of(context).text.withOpacity(.15),
|
color: AppColors.of(context).text.withOpacity(.9),
|
||||||
|
width: 1.5,
|
||||||
|
padding: 12.0,
|
||||||
|
icon: Icon(
|
||||||
|
widget.icon,
|
||||||
|
size: widget.iconSize / 2,
|
||||||
|
color: AppColors.of(context).text.withOpacity(.8),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
if (widget.showTitleUnscroll)
|
||||||
alignment: Alignment.center,
|
Container(
|
||||||
margin: const EdgeInsets.only(top: 82),
|
alignment: Alignment.center,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
margin: const EdgeInsets.only(top: 82),
|
||||||
child: Text(
|
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||||
widget.title.capital(),
|
child: Text(
|
||||||
maxLines: 2,
|
widget.title.capital(),
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 2,
|
||||||
textAlign: TextAlign.center,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
textAlign: TextAlign.center,
|
||||||
fontSize: 36.0,
|
style: TextStyle(
|
||||||
color: AppColors.of(context).text.withOpacity(.9),
|
fontSize: 36.0,
|
||||||
fontStyle: widget.italic ? FontStyle.italic : null,
|
color: AppColors.of(context).text.withOpacity(.9),
|
||||||
fontWeight: FontWeight.bold),
|
fontStyle: widget.italic ? FontStyle.italic : null,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -96,6 +96,38 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
void buildTiles(List<Grade> subjectGrades) {
|
void buildTiles(List<Grade> subjectGrades) {
|
||||||
List<Widget> tiles = [];
|
List<Widget> tiles = [];
|
||||||
|
|
||||||
|
tiles.add(Panel(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.subject.renamedTo ?? widget.subject.name.capital(),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20.0,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
height: 1.2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8.0,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
((widget.subject.teacher?.isRenamed ?? false) &&
|
||||||
|
settingsProvider.renamedTeachersEnabled
|
||||||
|
? widget.subject.teacher?.renamedTo
|
||||||
|
: widget.subject.teacher?.name.capital()) ??
|
||||||
|
'',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14.0,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
height: 1.6,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
if (showGraph(subjectGrades)) {
|
if (showGraph(subjectGrades)) {
|
||||||
tiles.add(gradeGraph);
|
tiles.add(gradeGraph);
|
||||||
} else {
|
} else {
|
||||||
@ -269,6 +301,7 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
onRefresh: () async {},
|
onRefresh: () async {},
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
child: HeroScrollView(
|
child: HeroScrollView(
|
||||||
|
showTitleUnscroll: false,
|
||||||
onClose: () {
|
onClose: () {
|
||||||
if (_sheetController != null && gradeCalcMode) {
|
if (_sheetController != null && gradeCalcMode) {
|
||||||
_sheetController!.close();
|
_sheetController!.close();
|
||||||
|
@ -94,7 +94,14 @@ class GradesPageState extends State<GradesPage> {
|
|||||||
|
|
||||||
void generateTiles() {
|
void generateTiles() {
|
||||||
List<GradeSubject> subjects = gradeProvider.grades
|
List<GradeSubject> subjects = gradeProvider.grades
|
||||||
.map((e) => e.subject)
|
.map((e) => GradeSubject(
|
||||||
|
category: e.subject.category,
|
||||||
|
id: e.subject.id,
|
||||||
|
name: e.subject.name,
|
||||||
|
renamedTo: e.subject.renamedTo,
|
||||||
|
customRounding: e.subject.customRounding,
|
||||||
|
teacher: e.teacher,
|
||||||
|
))
|
||||||
.toSet()
|
.toSet()
|
||||||
.toList()
|
.toList()
|
||||||
..sort((a, b) => a.name.compareTo(b.name));
|
..sort((a, b) => a.name.compareTo(b.name));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user