progress in new subject page

This commit is contained in:
Kima 2024-04-02 00:04:05 +02:00
parent 98efdfd8cf
commit 7f88c8c3e1
4 changed files with 88 additions and 31 deletions

View File

@ -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) {

View File

@ -1,10 +1,11 @@
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,
@ -12,7 +13,9 @@ class HeroScrollView extends StatefulWidget {
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,18 +101,27 @@ 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(
padding: const EdgeInsets.only(top: 46.0),
child: RoundBorderIcon(
color: AppColors.of(context).text.withOpacity(.9),
width: 1.5,
padding: 12.0,
icon: Icon(
widget.icon, widget.icon,
size: widget.iconSize, size: widget.iconSize / 2,
color: AppColors.of(context).text.withOpacity(.15), color: AppColors.of(context).text.withOpacity(.8),
), ),
), ),
),
),
if (widget.showTitleUnscroll)
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
margin: const EdgeInsets.only(top: 82), margin: const EdgeInsets.only(top: 82),

View File

@ -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();

View File

@ -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));