move scaffold from grades & tt pages to subpage

fixes random white stuttering in the background
This commit is contained in:
2025-09-13 14:14:27 +02:00
parent 2e425dd757
commit 6bf6b46119
4 changed files with 352 additions and 364 deletions

View File

@@ -166,129 +166,127 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
var subjectAvgColor = getGradeColor(subjectAvg);
return Scaffold(
backgroundColor: appStyle.colors.background,
body: Padding(
padding: const EdgeInsets.only(
left: 20.0,
right: 20.0,
top: 12.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
return Padding(
padding: const EdgeInsets.only(
left: 20.0,
right: 20.0,
top: 12.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Row(
children: [
Text(
widget.data.l10n.subjects,
style: appStyle.fonts.H_H2
.apply(color: appStyle.colors.textPrimary),
)
],
),
SizedBox(height: 16), // TODO: Add graphs here
// ...gradeCards,
SizedBox(
height: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top -
240,
child: ListView(
children: [
Text(
widget.data.l10n.subjects,
style: appStyle.fonts.H_H2
.apply(color: appStyle.colors.textPrimary),
)
],
),
SizedBox(height: 16), // TODO: Add graphs here
// ...gradeCards,
SizedBox(
height: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top -
240,
child: ListView(
children: [
Text(
widget.data.l10n.your_subjects,
style: appStyle.fonts.H_14px
.apply(color: appStyle.colors.textSecondary),
),
SizedBox(height: 16),
...gradeCards,
SizedBox(height: 16),
Text(
widget.data.l10n.data,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textSecondary),
),
SizedBox(height: 16),
FirkaCard(
left: [
Text(
widget.data.l10n.your_subjects,
style: appStyle.fonts.H_14px
.apply(color: appStyle.colors.textSecondary),
),
SizedBox(height: 16),
...gradeCards,
SizedBox(height: 16),
Text(
widget.data.l10n.data,
widget.data.l10n.subject_avg,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textSecondary),
.apply(color: appStyle.colors.textPrimary),
),
SizedBox(height: 16),
FirkaCard(
left: [
Text(
widget.data.l10n.subject_avg,
],
right: [
Card(
shadowColor: Colors.transparent,
color: subjectAvgColor.withAlpha(38),
child: Padding(
padding: EdgeInsets.only(
left: 8, right: 8, top: 4, bottom: 4),
child: Text(
subjectAvg.toStringAsFixed(2),
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
.apply(color: subjectAvgColor),
),
],
right: [
Card(
shadowColor: Colors.transparent,
color: subjectAvgColor.withAlpha(38),
child: Padding(
padding: EdgeInsets.only(
left: 8, right: 8, top: 4, bottom: 4),
child: Text(
subjectAvg.toStringAsFixed(2),
style: appStyle.fonts.B_16SB
.apply(color: subjectAvgColor),
),
),
),
],
),
FirkaCard(
left: [
Text(
widget.data.l10n.subject_avg_rounded,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
),
],
right: [
Card(
shadowColor: Colors.transparent,
color: subjectAvgColor.withAlpha(38),
child: Padding(
padding: EdgeInsets.only(
left: 8, right: 8, top: 4, bottom: 4),
child: Text(
subjectAvgRounded.toStringAsFixed(2),
style: appStyle.fonts.B_16SB
.apply(color: subjectAvgColor),
),
),
),
],
),
FirkaCard(left: [
Text(
widget.data.l10n.class_avg,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
),
]),
FirkaCard(
left: [
Text(
widget.data.l10n.class_n,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
),
],
right: [
Text(
week!.response!
.where((lesson) =>
lesson.type.name != TimetableConsts.event)
.length
.toString(),
style: appStyle.fonts.B_14SB
.apply(color: appStyle.colors.textPrimary),
),
],
),
],
),
),
],
FirkaCard(
left: [
Text(
widget.data.l10n.subject_avg_rounded,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
),
],
right: [
Card(
shadowColor: Colors.transparent,
color: subjectAvgColor.withAlpha(38),
child: Padding(
padding: EdgeInsets.only(
left: 8, right: 8, top: 4, bottom: 4),
child: Text(
subjectAvgRounded.toStringAsFixed(2),
style: appStyle.fonts.B_16SB
.apply(color: subjectAvgColor),
),
),
),
],
),
FirkaCard(left: [
Text(
widget.data.l10n.class_avg,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
),
]),
FirkaCard(
left: [
Text(
widget.data.l10n.class_n,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary),
),
],
right: [
Text(
week!.response!
.where((lesson) =>
lesson.type.name != TimetableConsts.event)
.length
.toString(),
style: appStyle.fonts.B_14SB
.apply(color: appStyle.colors.textPrimary),
),
],
),
],
),
),
));
],
),
);
}
}
}

View File

@@ -129,89 +129,82 @@ class _HomeGradesSubjectScreen extends FirkaState<HomeGradesSubjectScreen> {
}
}
return Scaffold(
backgroundColor: appStyle.colors.background,
body: Padding(
padding: const EdgeInsets.only(
left: 16.0,
right: 16.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
return Padding(
padding: const EdgeInsets.only(
left: 16.0,
right: 16.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Row(
children: [
Text(
widget.data.l10n.subjects,
style: appStyle.fonts
.H_16px // TODO: Replace this with the proper font
.apply(color: appStyle.colors.textPrimary),
)
],
),
SizedBox(height: 16),
SizedBox(
height: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top -
230,
child: ListView(
children: [
FirkaCard(
left: [
Padding(
padding: EdgeInsets.only(left: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width:
MediaQuery.of(context).size.width / 1.45,
child: Text(
aGrade.subject.name,
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary),
),
),
Text(
aGrade
.teacher, // For some reason the teacher's
// name isn't stored in the subject, so we need
// to get *a* grade, and then get the teacher's
// name from there :3
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textPrimary),
)
],
),
)
],
),
Text(
widget.data.l10n.subjects,
style: appStyle
.fonts.H_16px // TODO: Replace this with the proper font
.apply(color: appStyle.colors.textPrimary),
)
],
),
SizedBox(height: 16),
SizedBox(
height: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top -
230,
child: ListView(
children: [
FirkaCard(
left: [
Padding(
padding: EdgeInsets.only(left: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: gradeWidgets,
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 1.45,
child: Text(
aGrade.subject.name,
style: appStyle.fonts.H_H2
.apply(color: appStyle.colors.textPrimary),
),
),
Text(
aGrade.teacher, // For some reason the teacher's
// name isn't stored in the subject, so we need
// to get *a* grade, and then get the teacher's
// name from there :3
style: appStyle.fonts.B_14R
.apply(color: appStyle.colors.textPrimary),
)
],
),
)
],
),
),
],
Padding(
padding: EdgeInsets.only(left: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: gradeWidgets,
),
)
],
),
),
));
} else {
return Scaffold(
backgroundColor: appStyle.colors.background,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [DelayedSpinnerWidget()],
)
],
),
);
} else {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [DelayedSpinnerWidget()],
)
],
);
}
}
}

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '../../../../helpers/firka_state.dart';
import '../../../model/style.dart';
class PageWithSubPages extends StatefulWidget {
final int pageIndex;
@@ -19,6 +20,7 @@ class _PageWithSubPagesState extends FirkaState<PageWithSubPages> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: appStyle.colors.background,
body: widget.subPages[_currentSubPage]((page) {
setState(() {
_currentSubPage = page;

View File

@@ -308,44 +308,42 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
ttEmptyCards.clear();
}
return Scaffold(
backgroundColor: appStyle.colors.background,
body: Stack(children: [
SizedBox(
width: MediaQuery.of(context).size.width,
height: 74 + 16,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
return Stack(children: [
SizedBox(
width: MediaQuery.of(context).size.width,
height: 74 + 16,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.data.l10n.timetable,
style: appStyle.fonts.H_H2
.apply(color: appStyle.colors.textPrimary),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.data.l10n.timetable,
style: appStyle.fonts.H_H2
.apply(color: appStyle.colors.textPrimary),
),
Row(
children: [
GestureDetector(
child: Card(
color: appStyle.colors.buttonSecondaryFill,
child: Padding(
padding: const EdgeInsets.all(8),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.tableSolid,
size: 26.0,
color: appStyle.colors.accent,
),
),
GestureDetector(
child: Card(
color: appStyle.colors.buttonSecondaryFill,
child: Padding(
padding: const EdgeInsets.all(8),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.tableSolid,
size: 26.0,
color: appStyle.colors.accent,
),
onTap: () {
widget.pageController(1);
},
),
/* TODO: 1.1.0
),
onTap: () {
widget.pageController(1);
},
),
/* TODO: 1.1.0
Card(
color: appStyle.colors.buttonSecondaryFill,
@@ -360,166 +358,163 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
),
),
*/
GestureDetector(
child: Card(
color: appStyle.colors.buttonSecondaryFill,
child: Padding(
padding: const EdgeInsets.all(8),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.settingsCogSolid,
size: 26.0,
color: appStyle.colors.accent,
),
),
),
onTap: () {
showSettingsSheet(
context,
MediaQuery.of(context).size.height * 0.4,
widget.data,
widget.data.settings
.group("settings")
.subGroup("timetable_toast"));
},
)
],
),
],
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
child: SizedBox(
width: 24,
height: 24,
child: FirkaIconWidget(
FirkaIconType.icons,
"dropdownLeft",
size: 24,
color: appStyle.colors.accent,
child: Card(
color: appStyle.colors.buttonSecondaryFill,
child: Padding(
padding: const EdgeInsets.all(8),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.settingsCogSolid,
size: 26.0,
color: appStyle.colors.accent,
),
),
),
onTap: () async {
var newNow = now!.subtract(Duration(days: 7));
if (!mounted) return;
setState(() {
now = newNow;
lessons = null;
dates = null;
});
await initForWeek(newNow);
setState(() {
now = newNow;
});
},
),
GestureDetector(
child: Row(
children: [
Text(
now!.format(widget.data.l10n,
FormatMode.yyyymmddwedd),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textPrimary)),
SizedBox(width: 4),
Text("",
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.accent)),
SizedBox(width: 4),
Text(
now!.isAWeek()
? widget.data.l10n.a_week
: widget.data.l10n.b_week,
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textPrimary)),
],
),
onTap: () {
now = timeNow();
setActiveToToday();
_controller.jumpToPage(active);
showSettingsSheet(
context,
MediaQuery.of(context).size.height * 0.4,
widget.data,
widget.data.settings
.group("settings")
.subGroup("timetable_toast"));
},
),
GestureDetector(
child: FirkaIconWidget(
FirkaIconType.icons,
"dropdownRight",
size: 24,
color: appStyle.colors.accent,
),
onTap: () async {
var newNow = now!.add(Duration(days: 7));
now = newNow;
if (now!.getMonday().getMidnight() ==
timeNow().getMonday().getMidnight()) {
now = timeNow();
}
await initForWeek(newNow);
if (!mounted) return;
setState(() {
now = newNow;
});
},
),
)
],
)
],
),
),
),
Column(
children: [
TransparentPointer(
child: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 1.4,
child: CarouselSlider(
items: ttDays,
carouselController: _controller,
options: CarouselOptions(
height: MediaQuery.of(context).size.height / 1.36,
viewportFraction: 1,
enableInfiniteScroll: false,
initialPage: active,
onPageChanged: (i, _) {
if (animating || !mounted) return;
setState(() {
active = i;
});
}),
))),
Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: ttEmptyCards,
),
TransparentPointer(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: ttWidgets,
)),
],
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
child: SizedBox(
width: 24,
height: 24,
child: FirkaIconWidget(
FirkaIconType.icons,
"dropdownLeft",
size: 24,
color: appStyle.colors.accent,
),
),
onTap: () async {
var newNow = now!.subtract(Duration(days: 7));
if (!mounted) return;
setState(() {
now = newNow;
lessons = null;
dates = null;
});
await initForWeek(newNow);
setState(() {
now = newNow;
});
},
),
GestureDetector(
child: Row(
children: [
Text(
now!.format(
widget.data.l10n, FormatMode.yyyymmddwedd),
style: appStyle.fonts.B_14R
.apply(color: appStyle.colors.textPrimary)),
SizedBox(width: 4),
Text("",
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.accent)),
SizedBox(width: 4),
Text(
now!.isAWeek()
? widget.data.l10n.a_week
: widget.data.l10n.b_week,
style: appStyle.fonts.B_14R
.apply(color: appStyle.colors.textPrimary)),
],
),
onTap: () {
now = timeNow();
setActiveToToday();
_controller.jumpToPage(active);
},
),
GestureDetector(
child: FirkaIconWidget(
FirkaIconType.icons,
"dropdownRight",
size: 24,
color: appStyle.colors.accent,
),
onTap: () async {
var newNow = now!.add(Duration(days: 7));
now = newNow;
if (now!.getMonday().getMidnight() ==
timeNow().getMonday().getMidnight()) {
now = timeNow();
}
await initForWeek(newNow);
if (!mounted) return;
setState(() {
now = newNow;
});
},
),
],
)
],
)
]));
} else {
return Scaffold(
backgroundColor: appStyle.colors.background,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [DelayedSpinnerWidget()],
)
],
),
),
),
Column(
children: [
TransparentPointer(
child: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 1.4,
child: CarouselSlider(
items: ttDays,
carouselController: _controller,
options: CarouselOptions(
height: MediaQuery.of(context).size.height / 1.36,
viewportFraction: 1,
enableInfiniteScroll: false,
initialPage: active,
onPageChanged: (i, _) {
if (animating || !mounted) return;
setState(() {
active = i;
});
}),
))),
Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: ttEmptyCards,
),
TransparentPointer(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: ttWidgets,
)),
],
),
],
)
]);
} else {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [DelayedSpinnerWidget()],
)
],
);
}
}