finished the entire new live card thingie
This commit is contained in:
parent
6ba105f08c
commit
93d56fec28
@ -27,6 +27,7 @@ class LessonTile extends StatelessWidget {
|
||||
this.currentLessonIndicator = true,
|
||||
this.padding,
|
||||
this.contentPadding,
|
||||
this.showSubTiles = false,
|
||||
});
|
||||
|
||||
final Lesson lesson;
|
||||
@ -37,6 +38,7 @@ class LessonTile extends StatelessWidget {
|
||||
final bool currentLessonIndicator;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final EdgeInsetsGeometry? contentPadding;
|
||||
final bool showSubTiles;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -446,7 +448,7 @@ class LessonTile extends StatelessWidget {
|
||||
),
|
||||
|
||||
// Homework & Exams
|
||||
...subtiles,
|
||||
if (showSubTiles) ...subtiles,
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -213,8 +213,8 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
// }
|
||||
|
||||
// TODO: REMOVE IN PRODUCTION BUILD!!!
|
||||
print(_liveCard.currentState);
|
||||
_liveCard.currentState = LiveCardState.morning;
|
||||
// print(_liveCard.currentState);
|
||||
// _liveCard.currentState = LiveCardState.duringBreak;
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
@ -326,8 +326,10 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
expandedHeight: _liveCardAnimation.value *
|
||||
(_liveCard.currentState == LiveCardState.morning
|
||||
? 274.0
|
||||
: (_liveCard.currentState ==
|
||||
LiveCardState.duringLesson
|
||||
: ((_liveCard.currentState ==
|
||||
LiveCardState.duringLesson ||
|
||||
_liveCard.currentState ==
|
||||
LiveCardState.duringBreak)
|
||||
? 288.0
|
||||
: 238.0)),
|
||||
|
||||
@ -340,7 +342,9 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
top: ((_liveCard.currentState ==
|
||||
LiveCardState.morning ||
|
||||
_liveCard.currentState ==
|
||||
LiveCardState.duringLesson)
|
||||
LiveCardState.duringLesson ||
|
||||
_liveCard.currentState ==
|
||||
LiveCardState.duringBreak)
|
||||
? 0.0
|
||||
: 62.0) +
|
||||
MediaQuery.of(context).padding.top,
|
||||
|
@ -3,15 +3,12 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/helpers/subject.dart';
|
||||
import 'package:refilc/icons/filc_icons.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc/ui/widgets/lesson/lesson_tile.dart';
|
||||
import 'package:refilc_kreta_api/models/category.dart';
|
||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||
import 'package:refilc_kreta_api/models/subject.dart';
|
||||
import 'package:refilc_kreta_api/models/teacher.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_mobile_ui/common/progress_bar.dart';
|
||||
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
||||
// import 'package:refilc_kreta_api/models/category.dart';
|
||||
// import 'package:refilc_kreta_api/models/lesson.dart';
|
||||
// import 'package:refilc_kreta_api/models/subject.dart';
|
||||
@ -70,30 +67,30 @@ class LiveCardStateA extends State<LiveCard> {
|
||||
|
||||
// test
|
||||
// TODO: REMOVE IN PRODUCTION BUILD!!!
|
||||
liveCard.currentState = LiveCardState.morning;
|
||||
liveCard.nextLesson = Lesson(
|
||||
date: DateTime.now().add(Duration(
|
||||
minutes: 30,
|
||||
)),
|
||||
subject: GradeSubject(
|
||||
category: Category(id: 'asd'), id: 'asd', name: 'Matematika'),
|
||||
lessonIndex: '1',
|
||||
teacher: Teacher(id: 'id', name: 'name'),
|
||||
start: DateTime.now().subtract(Duration(
|
||||
minutes: 30,
|
||||
)),
|
||||
end: DateTime.now().add(Duration(
|
||||
minutes: 15,
|
||||
)),
|
||||
homeworkId: 'homeworkId',
|
||||
id: 'id',
|
||||
description: 'description',
|
||||
room: 'ABC69',
|
||||
groupName: 'groupName',
|
||||
name: 'name',
|
||||
);
|
||||
// liveCard.currentState = LiveCardState.duringBreak;
|
||||
// liveCard.nextLesson = Lesson(
|
||||
// date: DateTime.now().add(Duration(
|
||||
// minutes: 30,
|
||||
// )),
|
||||
// subject: GradeSubject(
|
||||
// category: Category(id: 'asd'), id: 'asd', name: 'Matematika'),
|
||||
// lessonIndex: '1',
|
||||
// teacher: Teacher(id: 'id', name: 'name'),
|
||||
// start: DateTime.now().subtract(Duration(
|
||||
// minutes: 30,
|
||||
// )),
|
||||
// end: DateTime.now().add(Duration(
|
||||
// minutes: 15,
|
||||
// )),
|
||||
// homeworkId: 'homeworkId',
|
||||
// id: 'id',
|
||||
// description: 'description',
|
||||
// room: 'ABC69',
|
||||
// groupName: 'groupName',
|
||||
// name: 'name',
|
||||
// );
|
||||
|
||||
// liveCard.nextLesson = liveCard.currentLesson;
|
||||
// liveCard.prevLesson = liveCard.nextLesson;
|
||||
|
||||
// final dt = DateTime(2024, 3, 22, 17, 12, 1, 1, 1);
|
||||
|
||||
@ -304,7 +301,7 @@ class LiveCardStateA extends State<LiveCard> {
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
'${DateFormat('H:mm').format(liveCard.nextLesson!.start)}-${DateFormat('H:mm').format(liveCard.nextLesson!.end)}',
|
||||
'${DateFormat('H:mm').format(liveCard.nextLesson!.start)} - ${DateFormat('H:mm').format(liveCard.nextLesson!.end)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w500,
|
||||
@ -546,7 +543,7 @@ class LiveCardStateA extends State<LiveCard> {
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
'${DateFormat('H:mm').format(liveCard.nextLesson!.start)}-${DateFormat('H:mm').format(liveCard.nextLesson!.end)}',
|
||||
'${DateFormat('H:mm').format(liveCard.nextLesson!.start)} - ${DateFormat('H:mm').format(liveCard.nextLesson!.end)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w500,
|
||||
@ -566,12 +563,17 @@ class LiveCardStateA extends State<LiveCard> {
|
||||
);
|
||||
break;
|
||||
case LiveCardState.duringBreak:
|
||||
final iconFloorMap = {
|
||||
"to room": FeatherIcons.chevronsRight,
|
||||
"up floor": FilcIcons.upstairs,
|
||||
"down floor": FilcIcons.downstairs,
|
||||
"ground floor": FilcIcons.downstairs,
|
||||
};
|
||||
if (liveCard.prevLesson == null || liveCard.nextLesson == null) {
|
||||
child = Container();
|
||||
break;
|
||||
}
|
||||
|
||||
// final iconFloorMap = {
|
||||
// "to room": FeatherIcons.chevronsRight,
|
||||
// "up floor": FilcIcons.upstairs,
|
||||
// "down floor": FilcIcons.downstairs,
|
||||
// "ground floor": FilcIcons.downstairs,
|
||||
// };
|
||||
|
||||
final diff = liveCard.getFloorDifference();
|
||||
|
||||
@ -587,36 +589,352 @@ class LiveCardStateA extends State<LiveCard> {
|
||||
|
||||
final showMinutes = maxTime - elapsedTime > 60;
|
||||
|
||||
// child = LiveCardWidget(
|
||||
// key: const Key('livecard.duringBreak'),
|
||||
// title: "break".i18n,
|
||||
// icon: iconFloorMap[diff],
|
||||
// description: liveCard.nextLesson!.room != liveCard.prevLesson!.room
|
||||
// ? Text("go $diff".i18n.fill([
|
||||
// diff != "to room"
|
||||
// ? (liveCard.nextLesson!.getFloor() ?? 0)
|
||||
// : liveCard.nextLesson!.room
|
||||
// ]))
|
||||
// : Text("stay".i18n),
|
||||
// nextSubject: liveCard.nextLesson?.subject.renamedTo ??
|
||||
// liveCard.nextLesson?.subject.name.capital(),
|
||||
// nextSubjectItalic: liveCard.nextLesson?.subject.isRenamed == true &&
|
||||
// settingsProvider.renamedSubjectsItalics,
|
||||
// nextRoom: diff != "to room" ? liveCard.nextLesson?.room : null,
|
||||
// progressMax: showMinutes ? maxTime / 60 : maxTime,
|
||||
// progressCurrent: showMinutes ? elapsedTime / 60 : elapsedTime,
|
||||
// progressAccuracy:
|
||||
// showMinutes ? ProgressAccuracy.minutes : ProgressAccuracy.seconds,
|
||||
// onProgressTap: () {
|
||||
// showDialog(
|
||||
// barrierColor: Colors.black,
|
||||
// context: context,
|
||||
// builder: (context) => HeadsUpCountdown(
|
||||
// maxTime: maxTime,
|
||||
// elapsedTime: elapsedTime,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
|
||||
var nextSubject = liveCard.nextLesson?.subject.renamedTo ??
|
||||
liveCard.nextLesson?.subject.name.capital();
|
||||
var nextSubjectItalic =
|
||||
liveCard.nextLesson?.subject.isRenamed == true &&
|
||||
settingsProvider.renamedSubjectsItalics;
|
||||
// var nextRoom = diff != "to room" ? liveCard.nextLesson?.room : null;
|
||||
var progressMax = showMinutes ? maxTime / 60 : maxTime;
|
||||
var progressCurrent = showMinutes ? elapsedTime / 60 : elapsedTime;
|
||||
var progressAccuracy =
|
||||
showMinutes ? ProgressAccuracy.minutes : ProgressAccuracy.seconds;
|
||||
|
||||
// Lesson breakLesson = Lesson(
|
||||
// date: DateTime.now(),
|
||||
// start: liveCard.prevLesson!.end,
|
||||
// end: liveCard.nextLesson!.start,
|
||||
// name: 'break'.i18n,
|
||||
// description: 'Menj a XY terembe...',
|
||||
// );
|
||||
|
||||
child = LiveCardWidget(
|
||||
key: const Key('livecard.duringBreak'),
|
||||
title: "break".i18n,
|
||||
icon: iconFloorMap[diff],
|
||||
description: liveCard.nextLesson!.room != liveCard.prevLesson!.room
|
||||
children: liveCard.nextLesson != null
|
||||
? [
|
||||
SplittedPanel(
|
||||
hasShadow: false,
|
||||
padding: EdgeInsets.zero,
|
||||
cardPadding: EdgeInsets.zero,
|
||||
spacing: 8.0,
|
||||
children: [
|
||||
SplittedPanel(
|
||||
hasShadow: false,
|
||||
isTransparent: true,
|
||||
padding: EdgeInsets.zero,
|
||||
cardPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
vertical: 0.0,
|
||||
),
|
||||
spacing: 0.0,
|
||||
children: [
|
||||
// LessonTile(
|
||||
// liveCard.currentLesson!,
|
||||
// swapRoom: true,
|
||||
// currentLessonIndicator: false,
|
||||
// padding:
|
||||
// const EdgeInsets.only(top: 8.0, bottom: 4.0),
|
||||
// contentPadding: EdgeInsets.zero,
|
||||
// ),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 8.0, bottom: 4.0),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
child: Visibility(
|
||||
visible:
|
||||
liveCard.nextLesson!.subject.id != '' ||
|
||||
liveCard.nextLesson!.isEmpty,
|
||||
replacement: Padding(
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
child: PanelTitle(
|
||||
title: Text(liveCard.nextLesson!.name)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
minVerticalPadding: 0.0,
|
||||
dense: true,
|
||||
// onLongPress: kDebugMode ? () => log(jsonEncode(lesson.json)) : null,
|
||||
visualDensity: VisualDensity.compact,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(12.0)),
|
||||
title: Text(
|
||||
"break".i18n,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16.5,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(!liveCard
|
||||
.nextLesson!.isEmpty
|
||||
? 1.0
|
||||
: 0.5),
|
||||
fontStyle: liveCard.nextLesson!
|
||||
.subject.isRenamed &&
|
||||
settingsProvider
|
||||
.renamedSubjectsItalics
|
||||
? FontStyle.italic
|
||||
: null),
|
||||
),
|
||||
|
||||
subtitle: DefaultTextStyle(
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 15.0,
|
||||
height: 1.0,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.75),
|
||||
),
|
||||
maxLines: !(nextSubject == null &&
|
||||
progressCurrent == null &&
|
||||
progressMax == null)
|
||||
? 1
|
||||
: 2,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
child: liveCard.nextLesson!.room !=
|
||||
liveCard.prevLesson!.room
|
||||
? Text("go $diff".i18n.fill([
|
||||
diff != "to room"
|
||||
? (liveCard.nextLesson!.getFloor() ?? 0)
|
||||
? (liveCard.nextLesson!
|
||||
.getFloor() ??
|
||||
0)
|
||||
: liveCard.nextLesson!.room
|
||||
]))
|
||||
: Text("stay".i18n),
|
||||
nextSubject: liveCard.nextLesson?.subject.renamedTo ??
|
||||
liveCard.nextLesson?.subject.name.capital(),
|
||||
nextSubjectItalic: liveCard.nextLesson?.subject.isRenamed == true &&
|
||||
settingsProvider.renamedSubjectsItalics,
|
||||
nextRoom: diff != "to room" ? liveCard.nextLesson?.room : null,
|
||||
progressMax: showMinutes ? maxTime / 60 : maxTime,
|
||||
progressCurrent: showMinutes ? elapsedTime / 60 : elapsedTime,
|
||||
progressAccuracy:
|
||||
showMinutes ? ProgressAccuracy.minutes : ProgressAccuracy.seconds,
|
||||
onProgressTap: () {
|
||||
),
|
||||
|
||||
// subtitle: description != ""
|
||||
// ? Text(
|
||||
// description,
|
||||
// style: const TextStyle(
|
||||
// fontWeight: FontWeight.w500,
|
||||
// fontSize: 14.0,
|
||||
// ),
|
||||
// maxLines: 1,
|
||||
// softWrap: false,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// )
|
||||
// : null,
|
||||
minLeadingWidth: 34.0,
|
||||
leading: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Center(
|
||||
child: Stack(
|
||||
children: [
|
||||
RoundBorderIcon(
|
||||
color:
|
||||
AppColors.of(context).text,
|
||||
width: 1.0,
|
||||
icon: const SizedBox(
|
||||
width: 25,
|
||||
height: 25,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.local_cafe,
|
||||
size: 20.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
// xix alignment hack :p
|
||||
const Opacity(
|
||||
opacity: 0,
|
||||
child: Text("EE:EE")),
|
||||
Text(
|
||||
"${DateFormat("H:mm").format(liveCard.prevLesson!.end)}\n${DateFormat("H:mm").format(liveCard.nextLesson!.start)}",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.9),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!(nextSubject == null &&
|
||||
progressCurrent == null &&
|
||||
progressMax == null))
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
if (progressCurrent != null &&
|
||||
progressMax != null)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
barrierColor: Colors.black,
|
||||
context: context,
|
||||
builder: (context) => HeadsUpCountdown(
|
||||
maxTime: maxTime,
|
||||
elapsedTime: elapsedTime,
|
||||
),
|
||||
elapsedTime: elapsedTime),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Text(
|
||||
"remaining ${progressAccuracy == ProgressAccuracy.minutes ? 'min' : 'sec'}"
|
||||
.plural(
|
||||
(progressMax - progressCurrent)
|
||||
.round()),
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.75),
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
if (progressCurrent != null && progressMax != null)
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 4.0, bottom: 12.0),
|
||||
child: ProgressBar(
|
||||
value: progressCurrent / progressMax),
|
||||
)
|
||||
],
|
||||
),
|
||||
SplittedPanel(
|
||||
hasShadow: false,
|
||||
isTransparent: true,
|
||||
padding: EdgeInsets.zero,
|
||||
cardPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 18.0,
|
||||
vertical: 11.0,
|
||||
),
|
||||
spacing: 0.0,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
liveCard.nextLesson == null
|
||||
? Icons.home_outlined
|
||||
: SubjectIcon.resolveVariant(
|
||||
context: context,
|
||||
subject:
|
||||
liveCard.nextLesson!.subject,
|
||||
),
|
||||
size: 23.0,
|
||||
),
|
||||
const SizedBox(width: 12.0),
|
||||
Text(
|
||||
(liveCard.nextLesson?.subject
|
||||
.isRenamed ??
|
||||
false
|
||||
? liveCard
|
||||
.nextLesson?.subject.renamedTo
|
||||
: liveCard
|
||||
.nextLesson?.subject.name) ??
|
||||
'go_home'.i18n,
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontStyle: nextSubjectItalic
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: liveCard.nextLesson != null
|
||||
? [
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
'${DateFormat('H:mm').format(liveCard.nextLesson!.start)} - ${DateFormat('H:mm').format(liveCard.nextLesson!.end)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
]
|
||||
: [],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
: null,
|
||||
);
|
||||
break;
|
||||
case LiveCardState.afternoon:
|
||||
|
@ -1,11 +1,9 @@
|
||||
import 'package:refilc/api/providers/live_card_provider.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc_mobile_ui/common/progress_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc_mobile_ui/pages/home/live_card/live_card.dart';
|
||||
import 'live_card.i18n.dart';
|
||||
|
||||
enum ProgressAccuracy { minutes, seconds }
|
||||
|
Loading…
x
Reference in New Issue
Block a user