added event functionality and summary to livecard

This commit is contained in:
kima 2023-06-13 23:27:40 +02:00
parent 580c92b13d
commit 1a9080dcc2
6 changed files with 303 additions and 153 deletions

View File

@ -19,7 +19,8 @@ enum LiveCardState {
duringBreak, duringBreak,
morning, morning,
afternoon, afternoon,
night night,
summary
} }
class LiveCardProvider extends ChangeNotifier { class LiveCardProvider extends ChangeNotifier {

View File

@ -7,6 +7,7 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <dynamic_color/dynamic_color_plugin.h> #include <dynamic_color/dynamic_color_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <flutter_acrylic/flutter_acrylic_plugin.h> #include <flutter_acrylic/flutter_acrylic_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
@ -14,6 +15,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) dynamic_color_registrar = g_autoptr(FlPluginRegistrar) dynamic_color_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin");
dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); dynamic_color_plugin_register_with_registrar(dynamic_color_registrar);
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar = g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin");
flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar); flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar);

View File

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
dynamic_color dynamic_color
file_selector_linux
flutter_acrylic flutter_acrylic
url_launcher_linux url_launcher_linux
) )

View File

@ -7,6 +7,7 @@ import Foundation
import connectivity_plus import connectivity_plus
import dynamic_color import dynamic_color
import file_selector_macos
import flutter_local_notifications import flutter_local_notifications
import macos_window_utils import macos_window_utils
import package_info_plus import package_info_plus
@ -18,6 +19,7 @@ import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))

View File

@ -4,6 +4,7 @@ import 'package:filcnaplo/helpers/subject.dart';
import 'package:filcnaplo/icons/filc_icons.dart'; import 'package:filcnaplo/icons/filc_icons.dart';
import 'package:filcnaplo/models/settings.dart'; import 'package:filcnaplo/models/settings.dart';
import 'package:filcnaplo_mobile_ui/pages/home/live_card/heads_up_countdown.dart'; import 'package:filcnaplo_mobile_ui/pages/home/live_card/heads_up_countdown.dart';
import 'package:filcnaplo_mobile_ui/screens/summary/summary_screen.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:filcnaplo/utils/format.dart'; import 'package:filcnaplo/utils/format.dart';
import 'package:filcnaplo/api/providers/live_card_provider.dart'; import 'package:filcnaplo/api/providers/live_card_provider.dart';
@ -52,6 +53,21 @@ class _LiveCardState extends State<LiveCard> {
Duration bellDelay = liveCard.delay; Duration bellDelay = liveCard.delay;
switch (liveCard.currentState) { switch (liveCard.currentState) {
case LiveCardState.summary:
child = LiveCardWidget(
key: const Key('livecard.summary'),
title: '',
icon: FeatherIcons.arrowRight,
description: Text(''),
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) => const SummaryScreen(
currentPage: 'grades',
),
),
),
);
break;
case LiveCardState.morning: case LiveCardState.morning:
child = LiveCardWidget( child = LiveCardWidget(
key: const Key('livecard.morning'), key: const Key('livecard.morning'),

View File

@ -9,6 +9,7 @@ enum ProgressAccuracy { minutes, seconds }
class LiveCardWidget extends StatefulWidget { class LiveCardWidget extends StatefulWidget {
const LiveCardWidget({ const LiveCardWidget({
Key? key, Key? key,
this.isEvent = false,
this.leading, this.leading,
this.title, this.title,
this.titleItalic = false, this.titleItalic = false,
@ -22,8 +23,10 @@ class LiveCardWidget extends StatefulWidget {
this.progressMax, this.progressMax,
this.progressAccuracy = ProgressAccuracy.minutes, this.progressAccuracy = ProgressAccuracy.minutes,
this.onProgressTap, this.onProgressTap,
this.onTap,
}) : super(key: key); }) : super(key: key);
final bool isEvent;
final String? leading; final String? leading;
final String? title; final String? title;
final bool titleItalic; final bool titleItalic;
@ -37,6 +40,7 @@ class LiveCardWidget extends StatefulWidget {
final double? progressMax; final double? progressMax;
final ProgressAccuracy? progressAccuracy; final ProgressAccuracy? progressAccuracy;
final Function()? onProgressTap; final Function()? onProgressTap;
final Function()? onTap;
@override @override
State<LiveCardWidget> createState() => _LiveCardWidgetState(); State<LiveCardWidget> createState() => _LiveCardWidgetState();
@ -51,6 +55,7 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
onLongPressDown: (_) => setState(() => hold = true), onLongPressDown: (_) => setState(() => hold = true),
onLongPressEnd: (_) => setState(() => hold = false), onLongPressEnd: (_) => setState(() => hold = false),
onLongPressCancel: () => setState(() => hold = false), onLongPressCancel: () => setState(() => hold = false),
onTap: widget.onTap,
child: AnimatedScale( child: AnimatedScale(
scale: hold ? 1.03 : 1.0, scale: hold ? 1.03 : 1.0,
curve: Curves.easeInOutBack, curve: Curves.easeInOutBack,
@ -73,171 +78,292 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
padding: const EdgeInsets.symmetric(horizontal: 6.0), padding: const EdgeInsets.symmetric(horizontal: 6.0),
child: OverflowBox( child: OverflowBox(
maxHeight: 96.0, maxHeight: 96.0,
child: Column( child: widget.isEvent
crossAxisAlignment: CrossAxisAlignment.start, ? Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center,
children: [ mainAxisAlignment: MainAxisAlignment.spaceAround,
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (widget.leading != null) Text(
Padding( widget.title ?? 'Esemény',
padding: const EdgeInsets.only(right: 12.0, top: 8.0), style: TextStyle(
child: Text( fontSize: 32,
widget.leading!, fontStyle:
textAlign: TextAlign.center, widget.titleItalic ? FontStyle.italic : null,
style: TextStyle(
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!,
),
],
), ),
), ),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
widget.description ??
const Text('Nincs leírás megadva.'),
SizedBox(
height: 15,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.secondary
.withOpacity(0.5),
borderRadius: const BorderRadius.all(
Radius.circular(10),
),
),
child: Padding(
padding: const EdgeInsets.all(4),
child: Icon(widget.icon),
),
),
),
],
),
], ],
), )
), : Column(
if (!(widget.nextSubject == null && widget.progressCurrent == null && widget.progressMax == null)) crossAxisAlignment: CrossAxisAlignment.start,
Padding( mainAxisAlignment: MainAxisAlignment.spaceAround,
padding: const EdgeInsets.only(top: 8.0), children: [
child: Row( Expanded(
children: [ child: Row(
if (widget.nextSubject != null) const Icon(FeatherIcons.arrowRight, size: 12.0), crossAxisAlignment: CrossAxisAlignment.start,
if (widget.nextSubject != null) const SizedBox(width: 4.0), children: [
if (widget.nextSubject != null) if (widget.leading != null)
Expanded( Padding(
child: Text.rich( padding: const EdgeInsets.only(
TextSpan( right: 12.0, top: 8.0),
child: Text(
widget.leading!,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.colorScheme
.secondary,
),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [ children: [
TextSpan( Row(
text: widget.nextSubject!, style: TextStyle(fontStyle: widget.nextSubjectItalic ? FontStyle.italic : null)), children: [
if (widget.nextRoom != null) if (widget.title != null)
WidgetSpan( Expanded(
child: Container( child: Text.rich(
margin: const EdgeInsets.only(left: 4.0), TextSpan(
padding: const EdgeInsets.symmetric(horizontal: 3.0, vertical: 1.5), children: [
decoration: BoxDecoration( TextSpan(
color: Theme.of(context).colorScheme.secondary.withOpacity(.25), text: widget.title!,
borderRadius: BorderRadius.circular(4.0), style: TextStyle(
), fontStyle: widget
child: Text( .titleItalic
widget.nextRoom!, ? FontStyle.italic
style: TextStyle( : null)),
height: 1.1, if (widget.subtitle != null)
fontSize: 11.0, WidgetSpan(
fontWeight: FontWeight.w600, child: Container(
color: Theme.of(context).colorScheme.secondary.withOpacity(.9), 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!,
), ),
], ],
), ),
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( if (!(widget.nextSubject == null &&
onTap: widget.onProgressTap, widget.progressCurrent == null &&
child: Container( widget.progressMax == null))
color: Colors.transparent, Padding(
child: Text( padding: const EdgeInsets.only(top: 8.0),
"remaining ${widget.progressAccuracy == ProgressAccuracy.minutes ? 'min' : 'sec'}" child: Row(
.plural((widget.progressMax! - widget.progressCurrent!).round()), children: [
maxLines: 1, if (widget.nextSubject != null)
style: TextStyle( const Icon(FeatherIcons.arrowRight,
fontWeight: FontWeight.w500, size: 12.0),
color: AppColors.of(context).text.withOpacity(.75), 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: 11.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!),
)
],
), ),
if (widget.progressCurrent != null && widget.progressMax != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: ProgressBar(value: widget.progressCurrent! / widget.progressMax!),
)
],
),
), ),
), ),
), ),