some livecard progress

This commit is contained in:
Kima 2024-04-21 23:18:37 +02:00
parent 3f782e762a
commit 51d8ef7707
2 changed files with 375 additions and 289 deletions

View File

@ -3,6 +3,8 @@ import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/helpers/subject.dart'; import 'package:refilc/helpers/subject.dart';
import 'package:refilc/icons/filc_icons.dart'; import 'package:refilc/icons/filc_icons.dart';
import 'package:refilc/models/settings.dart'; import 'package:refilc/models/settings.dart';
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'package:refilc_mobile_ui/pages/home/live_card/heads_up_countdown.dart'; import 'package:refilc_mobile_ui/pages/home/live_card/heads_up_countdown.dart';
import 'package:refilc_mobile_ui/screens/summary/summary_screen.dart'; import 'package:refilc_mobile_ui/screens/summary/summary_screen.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -54,7 +56,7 @@ class LiveCardStateA extends State<LiveCard> {
Duration bellDelay = liveCard.delay; Duration bellDelay = liveCard.delay;
// test // test
// liveCard.currentState = LiveCardState.morning; liveCard.currentState = LiveCardState.morning;
switch (liveCard.currentState) { switch (liveCard.currentState) {
case LiveCardState.summary: case LiveCardState.summary:
@ -102,60 +104,113 @@ class LiveCardStateA extends State<LiveCard> {
case LiveCardState.morning: case LiveCardState.morning:
child = LiveCardWidget( child = LiveCardWidget(
key: const Key('livecard.morning'), key: const Key('livecard.morning'),
title: DateFormat("EEEE", I18n.of(context).locale.toString()) // title: DateFormat("EEEE", I18n.of(context).locale.toString())
.format(DateTime.now()) // .format(DateTime.now())
.capital(), // .capital(),
icon: FeatherIcons.sun, // icon: FeatherIcons.sun,
onTap: () async { onTap: () async {
await MapsLauncher.launchQuery( await MapsLauncher.launchQuery(
'${_userProvider.student?.school.city ?? ''} ${_userProvider.student?.school.name ?? ''}'); '${_userProvider.student?.school.city ?? ''} ${_userProvider.student?.school.name ?? ''}');
}, },
description: liveCard.nextLesson != null // description: liveCard.nextLesson != null
? Text.rich( // ? Text.rich(
TextSpan( // TextSpan(
// children: [
// TextSpan(text: "first_lesson_1".i18n),
// TextSpan(
// text: liveCard.nextLesson!.subject.renamedTo ??
// liveCard.nextLesson!.subject.name.capital(),
// style: TextStyle(
// fontWeight: FontWeight.w600,
// color: Theme.of(context)
// .colorScheme
// .secondary
// .withOpacity(.85),
// fontStyle: liveCard.nextLesson!.subject.isRenamed &&
// settingsProvider.renamedSubjectsItalics
// ? FontStyle.italic
// : null),
// ),
// TextSpan(text: "first_lesson_2".i18n),
// TextSpan(
// text: liveCard.nextLesson!.room.capital(),
// style: TextStyle(
// fontWeight: FontWeight.w600,
// color: Theme.of(context)
// .colorScheme
// .secondary
// .withOpacity(.85),
// ),
// ),
// TextSpan(text: "first_lesson_3".i18n),
// TextSpan(
// text: DateFormat('H:mm')
// .format(liveCard.nextLesson!.start),
// style: TextStyle(
// fontWeight: FontWeight.w600,
// color: Theme.of(context)
// .colorScheme
// .secondary
// .withOpacity(.85),
// ),
// ),
// TextSpan(text: "first_lesson_4".i18n),
// ],
// ),
// )
// : null,
children: liveCard.nextLesson == null
? [
SplittedPanel(
hasShadow: false,
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(18.0),
spacing: 8.0,
children: [ children: [
TextSpan(text: "first_lesson_1".i18n), Column(
TextSpan( crossAxisAlignment: CrossAxisAlignment.start,
text: liveCard.nextLesson!.subject.renamedTo ?? children: [
liveCard.nextLesson!.subject.name.capital(), Text('Hamarosan kezdődik az első órád!'),
style: TextStyle( Text('1 óra 32 perc 26 másodperc'),
fontWeight: FontWeight.w600, ],
color: Theme.of(context)
.colorScheme
.secondary
.withOpacity(.85),
fontStyle: liveCard.nextLesson!.subject.isRenamed &&
settingsProvider.renamedSubjectsItalics
? FontStyle.italic
: null),
), ),
TextSpan(text: "first_lesson_2".i18n), Row(
TextSpan( mainAxisAlignment: MainAxisAlignment.spaceBetween,
text: liveCard.nextLesson!.room.capital(), children: [
style: TextStyle( Row(
fontWeight: FontWeight.w600, children: [
color: Theme.of(context) Icon(
.colorScheme SubjectIcon.resolveVariant(
.secondary context: context,
.withOpacity(.85), subjectName: 'matekgeci',
), ),
),
const SizedBox(width: 12.0),
Text(
'matekfasz',
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w600,
),
),
],
),
Row(
children: [
Text(
'8:00-8:45',
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w500,
),
),
],
),
],
), ),
TextSpan(text: "first_lesson_3".i18n),
TextSpan(
text: DateFormat('H:mm')
.format(liveCard.nextLesson!.start),
style: TextStyle(
fontWeight: FontWeight.w600,
color: Theme.of(context)
.colorScheme
.secondary
.withOpacity(.85),
),
),
TextSpan(text: "first_lesson_4".i18n),
], ],
), ),
) ]
: null, : null,
); );
break; break;

View File

@ -1,3 +1,4 @@
import 'package:i18n_extension/i18n_extension.dart';
import 'package:refilc/models/settings.dart'; import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/colors.dart'; import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_mobile_ui/common/progress_bar.dart'; import 'package:refilc_mobile_ui/common/progress_bar.dart';
@ -26,6 +27,7 @@ class LiveCardWidget extends StatefulWidget {
this.progressAccuracy = ProgressAccuracy.minutes, this.progressAccuracy = ProgressAccuracy.minutes,
this.onProgressTap, this.onProgressTap,
this.onTap, this.onTap,
this.children,
}); });
final bool isEvent; final bool isEvent;
@ -43,6 +45,7 @@ class LiveCardWidget extends StatefulWidget {
final ProgressAccuracy? progressAccuracy; final ProgressAccuracy? progressAccuracy;
final Function()? onProgressTap; final Function()? onProgressTap;
final Function()? onTap; final Function()? onTap;
final List<Widget>? children;
@override @override
State<LiveCardWidget> createState() => _LiveCardWidgetState(); State<LiveCardWidget> createState() => _LiveCardWidgetState();
@ -63,11 +66,17 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
curve: Curves.easeInOutBack, curve: Curves.easeInOutBack,
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
child: Container( child: Container(
margin: const EdgeInsets.symmetric(vertical: 2.0), margin: widget.children == null
padding: const EdgeInsets.all(12.0), ? const EdgeInsets.symmetric(vertical: 2.0)
: EdgeInsets.zero,
padding: widget.children == null
? const EdgeInsets.all(12.0)
: EdgeInsets.zero,
decoration: BoxDecoration( decoration: BoxDecoration(
// color: Theme.of(context).colorScheme.background, // color: Theme.of(context).colorScheme.background,
color: Colors.transparent, color: widget.children != null
? Colors.transparent
: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(16.0), borderRadius: BorderRadius.circular(16.0),
boxShadow: [ boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false) if (Provider.of<SettingsProvider>(context, listen: false)
@ -80,7 +89,9 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
], ],
), ),
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 6.0), padding: widget.children == null
? const EdgeInsets.symmetric(horizontal: 6.0)
: EdgeInsets.zero,
child: OverflowBox( child: OverflowBox(
maxHeight: 96.0, maxHeight: 96.0,
child: widget.isEvent child: widget.isEvent
@ -137,251 +148,271 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
), ),
], ],
) )
: Column( : widget.children != null
crossAxisAlignment: CrossAxisAlignment.start, ? Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, children: widget.children ?? [],
children: [ )
Expanded( : Column(
child: Row( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
if (widget.leading != null) Expanded(
Padding( child: Row(
padding: const EdgeInsets.only( crossAxisAlignment: CrossAxisAlignment.start,
right: 12.0, top: 8.0), children: [
child: Text( if (widget.leading != null)
widget.leading!, Padding(
textAlign: TextAlign.center, padding: const EdgeInsets.only(
style: TextStyle( right: 12.0, top: 8.0),
fontSize: 32.0,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.colorScheme
.secondary,
),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Row(
children: [
if (widget.title != null)
Expanded(
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: widget.title!,
style: TextStyle(
fontStyle: widget
.titleItalic
? FontStyle.italic
: null)),
if (widget.subtitle != null)
WidgetSpan(
child: Container(
margin: const EdgeInsets
.only(
left: 6.0,
bottom: 3.0),
padding:
const EdgeInsets
.symmetric(
horizontal: 4.0,
vertical: 2.0),
decoration:
BoxDecoration(
color: Theme.of(
context)
.colorScheme
.secondary
.withOpacity(.3),
borderRadius:
BorderRadius
.circular(
4.0),
),
child: Text(
widget.subtitle!,
style: TextStyle(
height: 1.2,
fontSize: 14.0,
fontWeight:
FontWeight.w600,
color: Theme.of(
context)
.colorScheme
.secondary,
),
),
),
),
],
),
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 22.0),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.ellipsis,
),
),
if (widget.title != null)
const SizedBox(width: 6.0),
if (widget.icon != null)
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0),
child: Icon(
widget.icon,
size: 26.0,
color: AppColors.of(context)
.text
.withOpacity(.75),
),
),
],
),
if (widget.description != null)
DefaultTextStyle(
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
fontWeight: FontWeight.w500,
fontSize: 16.0,
height: 1.0,
color: AppColors.of(context)
.text
.withOpacity(.75),
),
maxLines:
!(widget.nextSubject == null &&
widget.progressCurrent ==
null &&
widget.progressMax == null)
? 1
: 2,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: widget.description!,
),
],
),
),
],
),
),
if (!(widget.nextSubject == null &&
widget.progressCurrent == null &&
widget.progressMax == null))
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
children: [
if (widget.nextSubject != null)
const Icon(FeatherIcons.arrowRight,
size: 12.0),
if (widget.nextSubject != null)
const SizedBox(width: 4.0),
if (widget.nextSubject != null)
Expanded(
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: widget.nextSubject!,
style: TextStyle(
fontStyle:
widget.nextSubjectItalic
? FontStyle.italic
: null)),
if (widget.nextRoom != null)
WidgetSpan(
child: Container(
margin: const EdgeInsets.only(
left: 4.0),
padding:
const EdgeInsets.symmetric(
horizontal: 3.0,
vertical: 1.5),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.secondary
.withOpacity(.25),
borderRadius:
BorderRadius.circular(
4.0),
),
child: Text(
widget.nextRoom!,
style: TextStyle(
height: 1.1,
fontSize: 12.0,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.colorScheme
.secondary
.withOpacity(.9),
),
),
),
),
],
),
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(.8),
fontWeight: FontWeight.w600,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
),
if (widget.nextRoom == null &&
widget.nextSubject == null)
const Spacer(),
if (widget.progressCurrent != null &&
widget.progressMax != null)
GestureDetector(
onTap: widget.onProgressTap,
child: Container(
color: Colors.transparent,
child: Text( child: Text(
"remaining ${widget.progressAccuracy == ProgressAccuracy.minutes ? 'min' : 'sec'}" widget.leading!,
.plural((widget.progressMax! - textAlign: TextAlign.center,
widget.progressCurrent!)
.round()),
maxLines: 1,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 32.0,
color: AppColors.of(context) fontWeight: FontWeight.w600,
.text color: Theme.of(context)
.withOpacity(.75), .colorScheme
.secondary,
), ),
), ),
), ),
) Expanded(
], child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Row(
children: [
if (widget.title != null)
Expanded(
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: widget.title!,
style: TextStyle(
fontStyle: widget
.titleItalic
? FontStyle
.italic
: null)),
if (widget.subtitle !=
null)
WidgetSpan(
child: Container(
margin:
const EdgeInsets
.only(
left: 6.0,
bottom:
3.0),
padding:
const EdgeInsets
.symmetric(
horizontal:
4.0,
vertical:
2.0),
decoration:
BoxDecoration(
color: Theme.of(
context)
.colorScheme
.secondary
.withOpacity(
.3),
borderRadius:
BorderRadius
.circular(
4.0),
),
child: Text(
widget.subtitle!,
style: TextStyle(
height: 1.2,
fontSize: 14.0,
fontWeight:
FontWeight
.w600,
color: Theme.of(
context)
.colorScheme
.secondary,
),
),
),
),
],
),
style: const TextStyle(
fontWeight:
FontWeight.w600,
fontSize: 22.0),
maxLines: 1,
softWrap: false,
overflow:
TextOverflow.ellipsis,
),
),
if (widget.title != null)
const SizedBox(width: 6.0),
if (widget.icon != null)
Padding(
padding:
const EdgeInsets.symmetric(
vertical: 4.0),
child: Icon(
widget.icon,
size: 26.0,
color: AppColors.of(context)
.text
.withOpacity(.75),
),
),
],
),
if (widget.description != null)
DefaultTextStyle(
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
fontWeight: FontWeight.w500,
fontSize: 16.0,
height: 1.0,
color: AppColors.of(context)
.text
.withOpacity(.75),
),
maxLines:
!(widget.nextSubject == null &&
widget.progressCurrent ==
null &&
widget.progressMax ==
null)
? 1
: 2,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: widget.description!,
),
],
),
),
],
),
), ),
), if (!(widget.nextSubject == null &&
if (widget.progressCurrent != null && widget.progressCurrent == null &&
widget.progressMax != null) widget.progressMax == null))
Padding( Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0), padding: const EdgeInsets.only(top: 8.0),
child: ProgressBar( child: Row(
value: widget.progressCurrent! / children: [
widget.progressMax!), if (widget.nextSubject != null)
) const Icon(FeatherIcons.arrowRight,
], size: 12.0),
), if (widget.nextSubject != null)
const SizedBox(width: 4.0),
if (widget.nextSubject != null)
Expanded(
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: widget.nextSubject!,
style: TextStyle(
fontStyle: widget
.nextSubjectItalic
? FontStyle.italic
: null)),
if (widget.nextRoom != null)
WidgetSpan(
child: Container(
margin:
const EdgeInsets.only(
left: 4.0),
padding: const EdgeInsets
.symmetric(
horizontal: 3.0,
vertical: 1.5),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.secondary
.withOpacity(.25),
borderRadius:
BorderRadius.circular(
4.0),
),
child: Text(
widget.nextRoom!,
style: TextStyle(
height: 1.1,
fontSize: 12.0,
fontWeight:
FontWeight.w600,
color: Theme.of(context)
.colorScheme
.secondary
.withOpacity(.9),
),
),
),
),
],
),
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(.8),
fontWeight: FontWeight.w600,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
),
if (widget.nextRoom == null &&
widget.nextSubject == null)
const Spacer(),
if (widget.progressCurrent != null &&
widget.progressMax != null)
GestureDetector(
onTap: widget.onProgressTap,
child: Container(
color: Colors.transparent,
child: Text(
"remaining ${widget.progressAccuracy == ProgressAccuracy.minutes ? 'min' : 'sec'}"
.plural((widget.progressMax! -
widget.progressCurrent!)
.round()),
maxLines: 1,
style: TextStyle(
fontWeight: FontWeight.w500,
color: AppColors.of(context)
.text
.withOpacity(.75),
),
),
),
)
],
),
),
if (widget.progressCurrent != null &&
widget.progressMax != null)
Padding(
padding:
const EdgeInsets.symmetric(vertical: 4.0),
child: ProgressBar(
value: widget.progressCurrent! /
widget.progressMax!),
)
],
),
), ),
), ),
), ),