feat: test bottom sheet and design fixes

This commit is contained in:
checkedear
2026-06-04 12:20:43 +02:00
parent 729c281f1e
commit e1b571afa0
12 changed files with 420 additions and 352 deletions

View File

@@ -16,7 +16,7 @@ class Constants {
} }
static const applicationId = "hu.ekreta.student"; static const applicationId = "hu.ekreta.student";
static const applicationVersion = "5.7.0"; static const applicationVersion = "5.15.0";
static String get userAgent { static String get userAgent {
if (Platform.isAndroid) { if (Platform.isAndroid) {

View File

@@ -3,22 +3,17 @@ import 'package:firka_common/ui/components/filled_circle.dart';
import 'package:firka_common/ui/shared/grade_small_card.dart'; import 'package:firka_common/ui/shared/grade_small_card.dart';
import 'package:kreta_api/kreta_api.dart'; import 'package:kreta_api/kreta_api.dart';
import 'package:firka/data/models/homework_cache_model.dart'; import 'package:firka/data/models/homework_cache_model.dart';
import 'package:firka/core/debug_helper.dart';
import 'package:firka/core/extensions.dart'; import 'package:firka/core/extensions.dart';
import 'package:firka/core/settings.dart'; import 'package:firka/core/settings.dart';
import 'package:firka/ui/components/firka_shadow.dart';
import 'package:firka/ui/shared/firka_icon.dart'; import 'package:firka/ui/shared/firka_icon.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:majesticons_flutter/majesticons_flutter.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:firka/app/app_state.dart'; import 'package:firka/app/app_state.dart';
import 'package:firka/core/bloc/theme_cubit.dart';
import 'package:firka/ui/theme/style.dart'; import 'package:firka/ui/theme/style.dart';
import 'package:firka/ui/phone/pages/home/home_grades.dart';
import 'package:firka/ui/phone/widgets/lesson.dart'; import 'package:firka/ui/phone/widgets/lesson.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:firka/ui/shared/class_icon.dart'; import 'package:firka/ui/shared/class_icon.dart';
@@ -82,7 +77,6 @@ Future<void> showLessonBottomSheet(
BuildContext context, BuildContext context,
AppInitialization data, AppInitialization data,
Lesson lesson, Lesson lesson,
int? lessonNo,
Color accent, Color accent,
Color secondary, Color secondary,
Color bgColor, Color bgColor,
@@ -110,26 +104,28 @@ Future<void> showLessonBottomSheet(
showFirkaBottomSheet(context, [ showFirkaBottomSheet(context, [
Row( Row(
children: [ children: [
SizedBox( lesson.lessonNumber == null
width: 24, ? SizedBox()
height: 24, : SizedBox(
child: Stack(
alignment: Alignment.center,
children: [
SvgPicture.asset(
"assets/icons/subtract.svg",
color: bgColor,
width: 24, width: 24,
height: 24, height: 24,
child: Stack(
alignment: Alignment.center,
children: [
SvgPicture.asset(
"assets/icons/subtract.svg",
color: bgColor,
width: 24,
height: 24,
),
Text(
lesson.lessonNumber!.toString(),
style: appStyle.fonts.B_16R.apply(color: secondary),
textAlign: TextAlign.center,
),
],
),
), ),
Text(
lessonNo.toString(),
style: appStyle.fonts.B_16R.apply(color: secondary),
textAlign: TextAlign.center,
),
],
),
),
FilledCircle( FilledCircle(
diameter: 40, diameter: 40,
color: bgColor, color: bgColor,
@@ -230,22 +226,12 @@ Future<void> showLessonBottomSheet(
Future<void> showTestBottomSheet( Future<void> showTestBottomSheet(
BuildContext context, BuildContext context,
AppInitialization data, AppInitialization data,
Lesson lesson,
int? lessonNo,
Color accent,
Color secondary,
Color bgColor,
Test test, Test test,
) async { ) async {
final date = lesson.start; final date = test.date;
final formattedDate = final formattedDate =
"${date.format(data.l10n, FormatMode.yearly).firstUpper()}, ${DateFormat.EEEE(data.l10n.localeName).format(date).firstUpper()}"; "${date.format(data.l10n, FormatMode.yearly).firstUpper()}, ${DateFormat.EEEE(data.l10n.localeName).format(date).firstUpper()}";
final statsForNerdsEnabled = data.settings
.group("settings")
.subGroup("developer")
.boolean("stats_for_nerds");
showFirkaBottomSheet(context, [ showFirkaBottomSheet(context, [
FilledCircle( FilledCircle(
diameter: 40, diameter: 40,
@@ -264,7 +250,7 @@ Future<void> showTestBottomSheet(
spacing: 4, spacing: 4,
children: [ children: [
Text( Text(
"${test.theme} ${statsForNerdsEnabled ? "(${lesson.classGroup?.name ?? ''})" : ""}", "${test.theme}",
style: appStyle.fonts.H_18px.apply( style: appStyle.fonts.H_18px.apply(
color: appStyle.colors.textPrimary, color: appStyle.colors.textPrimary,
), ),
@@ -297,7 +283,64 @@ Future<void> showTestBottomSheet(
), ),
), ),
SizedBox(height: 10), SizedBox(height: 10),
LessonWidget(data, lessonNo, lesson, null), FirkaCard.single(
height: 64,
margin: EdgeInsets.all(0),
padding: EdgeInsets.only(left: 14, right: 16),
color: appStyle.colors.card,
child: Column(
spacing: 12,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
SizedBox(
width: 18,
height: 18,
child: Stack(
alignment: Alignment.center,
children: [
SvgPicture.asset(
"assets/icons/subtract.svg",
color: appStyle.colors.a15p,
width: 18,
height: 18,
),
Text(
test.lessonNumber.toString(),
style: appStyle.fonts.B_14SB.apply(
color: appStyle.colors.secondary,
),
textAlign: TextAlign.center,
),
],
),
),
FilledCircle(
diameter: 36,
color: appStyle.colors.a15p,
child: ClassIconWidget(
uid: test.uid,
className: test.subjectName,
category: test.subject.name,
color: appStyle.colors.accent,
size: 24,
),
),
Expanded(
child: Text(
test.subject.name,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
],
),
),
]); ]);
} }

View File

@@ -164,8 +164,9 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
), ),
], ],
), ),
SizedBox(height: 20),
GradeChartWithInteraction(grades: allGrades), GradeChartWithInteraction(grades: allGrades),
SizedBox(height: 2), SizedBox(height: 10),
GradeSummaryBar(grades: allGrades, l10n: widget.data.l10n), GradeSummaryBar(grades: allGrades, l10n: widget.data.l10n),
SizedBox(height: 20), SizedBox(height: 20),
Expanded( Expanded(

View File

@@ -60,7 +60,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
} }
Future<void> fetchData({bool cacheOnly = false}) async { Future<void> fetchData({bool cacheOnly = false}) async {
final midnight = now.getMidnight(); final midnight = timeNow().getMidnight();
var lessonsFetched = 0; var lessonsFetched = 0;
var noticeBoardFetched = 0; var noticeBoardFetched = 0;
@@ -213,6 +213,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
Widget _buildContent(BuildContext context) { Widget _buildContent(BuildContext context) {
if (student != null && lessons != null) { if (student != null && lessons != null) {
final now = timeNow();
final infoItems = [...(infoBoard ?? []), ...(noticeBoard ?? [])]; final infoItems = [...(infoBoard ?? []), ...(noticeBoard ?? [])];
final gradeItems = grades ?? []; final gradeItems = grades ?? [];
final testItems = tests ?? []; final testItems = tests ?? [];
@@ -239,11 +240,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
(item1, item2) => item2.$2.difference(item1.$2).inMilliseconds, (item1, item2) => item2.$2.difference(item1.$2).inMilliseconds,
); );
var currentLesson = lessons!.firstWhereOrNull( LinkedHashMap<Lesson, Test?> lessonTestMap = LinkedHashMap.fromEntries(
(lesson) => now.isBefore(lesson.end),
);
Map<Lesson, Test?> lessonTestMap = Map.fromEntries(
lessons!.indexed.map( lessons!.indexed.map(
(i) => MapEntry( (i) => MapEntry(
i.$2, i.$2,
@@ -256,30 +253,13 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
), ),
); );
int tmpIndex = lessons!.isEmpty || now.isBefore(lessons!.first.start)
? 0
: currentLesson == null
? lessons!.length + 1
: lessons!.indexOf(currentLesson) + 1;
if (activeLessonIndex == null || tmpIndex != activeLessonIndex) {
activeLessonIndex = tmpIndex;
swipeBack = 0;
}
centeredPageIndex ??= activeLessonIndex!;
if (controller.ready && swipeBack == 0) {
controller.animateToPage(activeLessonIndex!);
}
int testsTomorrow = testItems int testsTomorrow = testItems
.where( .where(
(test) => (test) =>
test.date.isAfter( test.date.isAfter(
now.getMidnight().add(Duration(hours: 23, minutes: 59)), now.getMidnight().add(Duration(hours: 23, minutes: 59)),
) && ) &&
test.date.isBefore(now.getMidnight().add(Duration(days: 1))), test.date.isBefore(now.getMidnight().add(Duration(days: 2))),
) )
.length; .length;
@@ -290,157 +270,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
children: [ children: [
WelcomeWidget(widget.data.l10n, now, student!, lessons!), WelcomeWidget(widget.data.l10n, now, student!, lessons!),
SizedBox(height: 48), SizedBox(height: 48),
if (lessons!.isNotEmpty) LessonSlider(lessonTestMap, testsTomorrow),
OverflowBox(
maxWidth: MediaQuery.widthOf(context),
fit: OverflowBoxFit.deferToChild,
child: CarouselSlider(
items: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: StartingSoonWidget(
widget.data.l10n,
now,
lessons!,
),
),
...lessonTestMap.entries.map(
(entry) => Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: LessonBigWidget(
widget.data,
lessons!.getLessonNo(entry.key),
entry.key,
entry.value,
active: currentLesson == entry.key,
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: FirkaCard.single(
padding: EdgeInsets.all(16),
margin: EdgeInsets.only(bottom: 1),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
FilledCircle(
diameter: 32,
color: appStyle.colors.a15p,
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.moonSolid,
size: 20,
color: appStyle.colors.accent,
),
),
SizedBox(width: 8),
Text(
testsTomorrow == 0
? widget.data.l10n.tt_no_classes_l2
: widget.data.l10n.get_ready,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
),
),
],
),
Container(
height: 28,
padding: EdgeInsets.symmetric(horizontal: 6),
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
color: appStyle.colors.background,
),
child: Row(
children: [
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
size: 12,
color: appStyle.colors.accent,
),
SizedBox(width: 8),
Text(
testsTomorrow == 0
? widget.data.l10n.no_tests_tomorrow
: widget.data.l10n.tests_tomorrow(
testsTomorrow.toString(),
),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
),
),
],
),
),
],
),
),
),
],
carouselController: controller,
options: CarouselOptions(
initialPage: activeLessonIndex!,
height: 106,
viewportFraction: 346 / 376,
enableInfiniteScroll: false,
onPageChanged: (index, reason) {
centeredPageIndex = index;
if (index == activeLessonIndex) {
swipeBack = null;
} else if (reason == CarouselPageChangedReason.manual) {
swipeBack = 5;
} else {
return;
}
setState(() {});
},
),
),
),
if (lessons!.isNotEmpty) SizedBox(height: 12),
if (lessons!.isNotEmpty)
SizedBox(
height: 16,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 8,
children: [
FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"sunSolid",
color: centeredPageIndex == 0
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
size: centeredPageIndex == 0 ? 16 : 12,
),
...lessons!.indexed.map(
(i) => FilledCircle(
diameter: centeredPageIndex == i.$1 + 1 ? 10 : 8,
color: centeredPageIndex == i.$1 + 1
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
child: SizedBox(),
),
),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.moonSolid,
color: centeredPageIndex == lessons!.length + 1
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
size: centeredPageIndex == lessons!.length + 1 ? 16 : 12,
),
],
),
),
if (lessons!.isNotEmpty) SizedBox(height: 12),
Expanded( Expanded(
child: RefreshIndicator( child: RefreshIndicator(
onRefresh: () => fetchData(), onRefresh: () => fetchData(),

View File

@@ -1,7 +1,7 @@
import 'dart:math' as math;
import 'package:firka/app/app_state.dart'; import 'package:firka/app/app_state.dart';
import 'package:firka/core/settings.dart'; import 'package:firka/core/settings.dart';
import 'package:firka_common/firka_common.dart'; import 'package:firka_common/firka_common.dart';
import 'package:firka_common/ui/components/filled_circle.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:kreta_api/kreta_api.dart'; import 'package:kreta_api/kreta_api.dart';
import 'package:firka/routing/chart_interaction_scope.dart'; import 'package:firka/routing/chart_interaction_scope.dart';
@@ -90,6 +90,7 @@ class _GradeChartState extends State<GradeChart> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FirkaCard.single( return FirkaCard.single(
margin: EdgeInsets.all(0),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
child: AspectRatio(aspectRatio: 1.82, child: LineChart(avgData())), child: AspectRatio(aspectRatio: 1.82, child: LineChart(avgData())),
@@ -147,24 +148,13 @@ class _GradeChartState extends State<GradeChart> {
required Color bgColor, required Color bgColor,
required Color textColor, required Color textColor,
}) { }) {
return SizedBox( return FilledCircle(
width: 24, diameter: 18,
height: 24, color: bgColor,
child: Material( child: Text(
shape: const CircleBorder(), text,
color: bgColor, textAlign: TextAlign.center,
child: Center( style: appStyle.fonts.H_14px.copyWith(color: textColor),
child: Text(
text,
textAlign: TextAlign.center,
style: TextStyle(
color: textColor,
fontSize: 14,
fontWeight: FontWeight.bold,
fontFamily: appStyle.fonts.B_14SB.fontFamily,
),
),
),
), ),
); );
} }

View File

@@ -1,3 +1,4 @@
import 'package:firka/ui/components/firka_card.dart';
import 'package:kreta_api/kreta_api.dart'; import 'package:kreta_api/kreta_api.dart';
import 'package:firka/ui/components/grade.dart'; import 'package:firka/ui/components/grade.dart';
import 'package:firka/ui/components/grade_helpers.dart'; import 'package:firka/ui/components/grade_helpers.dart';
@@ -33,89 +34,75 @@ class _GradeSummaryBarState extends State<GradeSummaryBar> {
final averageText = widget.showAverage final averageText = widget.showAverage
? (widget.grades.getAverage() ?? 0).toStringAsFixed(2) ? (widget.grades.getAverage() ?? 0).toStringAsFixed(2)
: ''; : '';
final bar = ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Row(
children: List.generate(5, (i) {
final flex = total > 0 ? countsByGrade[i] : 1;
return Expanded(
flex: flex,
child: Container(height: 12, color: getGradeColor(i + 1)),
);
}),
),
);
return Card( return GestureDetector(
shadowColor: Colors.transparent, onTap: () => setState(() => _expanded = !_expanded),
color: appStyle.colors.a15p, child: FirkaCard.single(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), margin: EdgeInsets.zero,
child: InkWell( padding: EdgeInsets.symmetric(horizontal: 16),
onTap: () => setState(() => _expanded = !_expanded), height: _expanded ? 115 : 52,
borderRadius: BorderRadius.circular(16), child: Column(
child: Padding( mainAxisSize: MainAxisSize.min,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), mainAxisAlignment: MainAxisAlignment.center,
child: Column( spacing: 12,
mainAxisSize: MainAxisSize.min, children: [
crossAxisAlignment: CrossAxisAlignment.stretch, Row(
children: [ spacing: 12,
Row( children: [
children: [ Text(
Text( widget.showAverage
widget.showAverage ? '${widget.l10n.gradesCount(total)} ($averageText)'
? '${widget.l10n.gradesCount(total)} ($averageText)' : widget.l10n.gradesCount(total),
: widget.l10n.gradesCount(total), style: appStyle.fonts.B_16SB.apply(
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
const SizedBox(width: 12),
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.circular(4),
child: Row(
children: List.generate(5, (i) {
final flex = total > 0 ? countsByGrade[i] : 1;
return Expanded(
flex: flex,
child: Container(
height: 10,
color: getGradeColor(i + 1),
),
);
}),
),
),
),
const SizedBox(width: 12),
FirkaIconWidget(
FirkaIconType.majesticons,
_expanded
? Majesticon.chevronUpLine
: Majesticon.chevronDownLine,
color: appStyle.colors.textPrimary, color: appStyle.colors.textPrimary,
size: 24,
), ),
], ),
), Expanded(child: _expanded ? SizedBox() : bar),
if (_expanded) ...[ FirkaIconWidget(
const SizedBox(height: 12), FirkaIconType.majesticons,
Row( _expanded
mainAxisAlignment: MainAxisAlignment.spaceBetween, ? Majesticon.chevronUpLine
children: List.generate(5, (i) { : Majesticon.chevronDownLine,
final grade = i + 1; color: appStyle.colors.textPrimary,
return Row( size: 24,
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 32,
height: 32,
child: FittedBox(
child: GradeWidget.gradeValue(grade),
),
),
const SizedBox(width: 4),
Text(
countsByGrade[i].toString(),
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
],
);
}),
), ),
], ],
),
if (_expanded) ...[
bar,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(5, (i) {
final grade = i + 1;
return Row(
mainAxisSize: MainAxisSize.min,
spacing: 6,
children: [
GradeWidget.gradeValue(grade, size: 27),
Text(
countsByGrade[i].toString(),
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
],
);
}),
),
], ],
), ],
), ),
), ),
); );

View File

@@ -58,6 +58,7 @@ class InfoCard extends StatelessWidget {
), ),
texts: [test.theme.firstUpper(), test.subject.name.firstUpper()], texts: [test.theme.firstUpper(), test.subject.name.firstUpper()],
right: [buildSubject(color, test.subject)], right: [buildSubject(color, test.subject)],
onTap: (context) => showTestBottomSheet(context, initData, test),
); );
} }
@@ -77,6 +78,7 @@ class InfoCard extends StatelessWidget {
), ),
texts: [test.theme.firstUpper(), test.method.description.firstUpper()], texts: [test.theme.firstUpper(), test.method.description.firstUpper()],
right: [buildSubject(color, test.subject)], right: [buildSubject(color, test.subject)],
onTap: (context) => showTestBottomSheet(context, initData, test),
); );
} }

View File

@@ -1,5 +1,3 @@
import 'dart:math';
import 'package:firka/core/extensions.dart'; import 'package:firka/core/extensions.dart';
import 'package:firka/core/settings.dart'; import 'package:firka/core/settings.dart';
import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/ui/components/firka_card.dart';
@@ -11,7 +9,6 @@ import 'package:flutter_svg/svg.dart';
import 'package:majesticons_flutter/majesticons_flutter.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart';
import 'package:kreta_api/kreta_api.dart'; import 'package:kreta_api/kreta_api.dart';
import 'package:firka/core/debug_helper.dart';
import 'package:firka/ui/components/common_bottom_sheets.dart'; import 'package:firka/ui/components/common_bottom_sheets.dart';
import 'package:firka/ui/shared/class_icon.dart'; import 'package:firka/ui/shared/class_icon.dart';
import 'package:firka/ui/shared/firka_icon.dart'; import 'package:firka/ui/shared/firka_icon.dart';
@@ -19,14 +16,12 @@ import 'bubble_test.dart';
class LessonWidget extends StatelessWidget { class LessonWidget extends StatelessWidget {
final AppInitialization data; final AppInitialization data;
final int? lessonNo;
final Lesson lesson; final Lesson lesson;
final bool active; final bool active;
final Test? test; final Test? test;
const LessonWidget( const LessonWidget(
this.data, this.data,
this.lessonNo,
this.lesson, this.lesson,
this.test, { this.test, {
this.active = false, this.active = false,
@@ -48,7 +43,7 @@ class LessonWidget extends StatelessWidget {
.subGroup("timetable_toast") .subGroup("timetable_toast")
.boolean("substitution"); .boolean("substitution");
final showLessonNos = final showLessonNos =
lessonNo != null && lesson.lessonNumber != null &&
data.settings data.settings
.group("settings") .group("settings")
.subGroup("timetable_toast") .subGroup("timetable_toast")
@@ -79,12 +74,10 @@ class LessonWidget extends StatelessWidget {
elements.add( elements.add(
GestureDetector( GestureDetector(
onTap: () { onTap: () {
if (lessonNo == null) return;
showLessonBottomSheet( showLessonBottomSheet(
context, context,
data, data,
lesson, lesson,
lessonNo,
accent, accent,
secondary, secondary,
bgColor, bgColor,
@@ -122,8 +115,8 @@ class LessonWidget extends StatelessWidget {
height: 18, height: 18,
), ),
Text( Text(
lessonNo.toString(), lesson.lessonNumber!.toString(),
style: appStyle.fonts.B_12R.apply( style: appStyle.fonts.B_14SB.apply(
color: secondary, color: secondary,
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
@@ -195,8 +188,8 @@ class LessonWidget extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 6), padding: EdgeInsets.symmetric(horizontal: 6),
child: Text( child: Text(
roomName, roomName,
style: appStyle.fonts.B_12R.apply( style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary, color: appStyle.colors.secondary,
), ),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@@ -244,16 +237,7 @@ class LessonWidget extends StatelessWidget {
elements.add( elements.add(
GestureDetector( GestureDetector(
onTap: () { onTap: () {
showTestBottomSheet( showTestBottomSheet(context, data, test!);
context,
data,
lesson,
lessonNo,
accent,
secondary,
bgColor,
test!,
);
}, },
child: FirkaCard.single( child: FirkaCard.single(
height: 48, height: 48,

View File

@@ -1,5 +1,4 @@
import 'package:firka/core/extensions.dart'; import 'package:firka/core/extensions.dart';
import 'package:firka/core/settings.dart';
import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/ui/components/firka_card.dart';
import 'package:firka/app/app_state.dart'; import 'package:firka/app/app_state.dart';
import 'package:firka/ui/theme/style.dart'; import 'package:firka/ui/theme/style.dart';
@@ -13,7 +12,6 @@ import 'package:firka/core/debug_helper.dart';
import 'package:firka/ui/components/common_bottom_sheets.dart'; import 'package:firka/ui/components/common_bottom_sheets.dart';
import 'package:firka/ui/shared/class_icon.dart'; import 'package:firka/ui/shared/class_icon.dart';
import 'package:firka/ui/shared/firka_icon.dart'; import 'package:firka/ui/shared/firka_icon.dart';
import 'bubble_test.dart';
class LessonBigWidget extends StatelessWidget { class LessonBigWidget extends StatelessWidget {
final AppInitialization data; final AppInitialization data;
@@ -96,7 +94,7 @@ class LessonBigWidget extends StatelessWidget {
) )
: Container( : Container(
height: 28, height: 28,
padding: EdgeInsets.symmetric(horizontal: 6), padding: EdgeInsets.symmetric(horizontal: 8),
decoration: ShapeDecoration( decoration: ShapeDecoration(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14), borderRadius: BorderRadius.circular(14),
@@ -112,12 +110,14 @@ class LessonBigWidget extends StatelessWidget {
color: appStyle.colors.accent, color: appStyle.colors.accent,
), ),
SizedBox(width: 8), SizedBox(width: 8),
Text( Expanded(
test!.theme, child: Text(
style: appStyle.fonts.B_16R.apply( test!.theme,
color: appStyle.colors.textPrimary, style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
), ),
overflow: TextOverflow.ellipsis,
), ),
], ],
), ),
@@ -129,7 +129,6 @@ class LessonBigWidget extends StatelessWidget {
context, context,
data, data,
lesson, lesson,
lessonNo,
accent, accent,
secondary, secondary,
bgColor, bgColor,
@@ -139,7 +138,7 @@ class LessonBigWidget extends StatelessWidget {
child: FirkaCard.single( child: FirkaCard.single(
height: 104, height: 104,
borderColor: active ? appStyle.colors.accent : null, borderColor: active ? appStyle.colors.accent : null,
margin: EdgeInsets.all(0), margin: EdgeInsets.only(bottom: active ? 0 : 1),
padding: EdgeInsets.only(left: 16, right: 16), padding: EdgeInsets.only(left: 16, right: 16),
color: isDismissed color: isDismissed
? appStyle.colors.cardTranslucent ? appStyle.colors.cardTranslucent
@@ -165,7 +164,7 @@ class LessonBigWidget extends StatelessWidget {
), ),
Text( Text(
lessonNo.toString(), lessonNo.toString(),
style: appStyle.fonts.B_12R.apply(color: secondary), style: appStyle.fonts.B_14SB.apply(color: secondary),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
], ],
@@ -227,8 +226,8 @@ class LessonBigWidget extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 6), padding: EdgeInsets.symmetric(horizontal: 6),
child: Text( child: Text(
roomName, roomName,
style: appStyle.fonts.B_12R.apply( style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary, color: appStyle.colors.secondary,
), ),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center, textAlign: TextAlign.center,

View File

@@ -0,0 +1,235 @@
import 'dart:async';
import 'dart:collection';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:firka/app/app_state.dart';
import 'package:firka/core/extensions.dart';
import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart';
import 'package:firka/ui/phone/widgets/lesson_big.dart';
import 'package:firka/ui/shared/firka_icon.dart';
import 'package:firka_common/firka_common.dart';
import 'package:firka_common/ui/components/filled_circle.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart';
import 'package:kreta_api/kreta_api.dart';
import 'package:majesticons_flutter/majesticons_flutter.dart';
class _LessonSliderState extends State<LessonSlider> {
DateTime now = timeNow();
int? swipeBack;
late Timer timer;
int? activeLessonIndex;
int? centeredPageIndex;
CarouselSliderController controller = CarouselSliderController();
@override
void initState() {
super.initState();
timer = Timer.periodic(Duration(seconds: 1), (timer) async {
if (widget.lessons.isEmpty || !mounted) return;
setState(() {
if (swipeBack != null) swipeBack = swipeBack! - 1;
now = timeNow();
});
});
}
@override
void dispose() {
timer.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.lessons.isEmpty) {
return SizedBox();
}
var lessons = widget.lessons.keys.toList();
var currentLesson = widget.lessons.keys.firstWhereOrNull(
(lesson) => now.isBefore(lesson.end),
);
int tmpIndex = lessons.isEmpty || now.isBefore(lessons.first.start)
? 0
: currentLesson == null
? lessons.length + 1
: lessons.indexOf(currentLesson) + 1;
if (activeLessonIndex == null || tmpIndex != activeLessonIndex) {
activeLessonIndex = tmpIndex;
swipeBack = 0;
}
centeredPageIndex ??= activeLessonIndex!;
if (controller.ready && swipeBack == 0) {
controller.animateToPage(activeLessonIndex!);
}
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
spacing: 12,
children: [
OverflowBox(
maxWidth: MediaQuery.widthOf(context),
fit: OverflowBoxFit.deferToChild,
child: CarouselSlider(
items: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: StartingSoonWidget(initData.l10n, now, lessons),
),
...widget.lessons.entries.map(
(entry) => Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: LessonBigWidget(
initData,
lessons.getLessonNo(entry.key),
entry.key,
entry.value,
active: currentLesson == entry.key,
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: FirkaCard.single(
padding: EdgeInsets.all(16),
margin: EdgeInsets.only(bottom: 1),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
FilledCircle(
diameter: 32,
color: appStyle.colors.a15p,
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.moonSolid,
size: 20,
color: appStyle.colors.accent,
),
),
SizedBox(width: 8),
Text(
widget.tomorrowTestAmount == 0
? initData.l10n.tt_no_classes_l2
: initData.l10n.get_ready,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
),
),
],
),
Container(
height: 28,
padding: EdgeInsets.symmetric(horizontal: 6),
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
color: appStyle.colors.background,
),
child: Row(
children: [
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
size: 12,
color: appStyle.colors.accent,
),
SizedBox(width: 8),
Text(
widget.tomorrowTestAmount == 0
? initData.l10n.no_tests_tomorrow
: initData.l10n.tests_tomorrow(
widget.tomorrowTestAmount.toString(),
),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
),
),
],
),
),
],
),
),
),
],
carouselController: controller,
options: CarouselOptions(
initialPage: activeLessonIndex!,
height: 106,
viewportFraction: 346 / 376,
enableInfiniteScroll: false,
onPageChanged: (index, reason) {
centeredPageIndex = index;
if (index == activeLessonIndex) {
swipeBack = null;
} else if (reason == CarouselPageChangedReason.manual) {
swipeBack = 5;
} else {
return;
}
setState(() {});
},
),
),
),
SizedBox(
height: 16,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 8,
children: [
FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"sunSolid",
color: centeredPageIndex == 0
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
size: centeredPageIndex == 0 ? 16 : 12,
),
...widget.lessons.keys.indexed.map(
(i) => FilledCircle(
diameter: centeredPageIndex == i.$1 + 1 ? 10 : 8,
color: centeredPageIndex == i.$1 + 1
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
child: SizedBox(),
),
),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.moonSolid,
color: centeredPageIndex == widget.lessons.keys.length + 1
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
size: centeredPageIndex == widget.lessons.keys.length + 1
? 16
: 12,
),
],
),
),
],
);
}
}
class LessonSlider extends StatefulWidget {
final LinkedHashMap<Lesson, Test?> lessons;
final int tomorrowTestAmount;
const LessonSlider(this.lessons, this.tomorrowTestAmount, {super.key});
@override
State<StatefulWidget> createState() => _LessonSliderState();
}

View File

@@ -90,9 +90,7 @@ class TimeTableDayWidget extends StatelessWidget {
} }
if (events.isNotEmpty) { if (events.isNotEmpty) {
ttLessons.add( ttLessons.add(SizedBox());
SizedBox()
);
} }
var showBreak = data.settings var showBreak = data.settings
@@ -106,7 +104,6 @@ class TimeTableDayWidget extends StatelessWidget {
ttLessons.add( ttLessons.add(
LessonWidget( LessonWidget(
data, data,
lessons.getLessonNo(lesson),
lesson, lesson,
tests.firstWhereOrNull( tests.firstWhereOrNull(
(test) => test.lessonNumber == lesson.lessonNumber, (test) => test.lessonNumber == lesson.lessonNumber,

View File

@@ -18,14 +18,14 @@ class FilledCircle extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return SizedBox(
width: diameter, width: diameter,
height: diameter, height: diameter,
decoration: ShapeDecoration( child: Material(
shape: const CircleBorder(),
color: color, color: color,
shape: CircleBorder(eccentricity: 1), child: Center(child: child),
), ),
child: Center(child: child),
); );
} }
} }