forked from firka/student-legacy
added new style widgets and total grade counter
This commit is contained in:
parent
5476397af6
commit
e010242469
@ -132,6 +132,7 @@ List<Widget> sortDateWidgets(
|
||||
items.add(DateWidget(
|
||||
date: date,
|
||||
widget: Panel(
|
||||
isTransparent: true,
|
||||
key: ValueKey(date),
|
||||
padding: padding ?? const EdgeInsets.symmetric(vertical: 6.0),
|
||||
title: cst ? Text(date.format(context, forceToday: true)) : null,
|
||||
@ -141,8 +142,13 @@ List<Widget> sortDateWidgets(
|
||||
spawnIsolate: false,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, animation, item, index) =>
|
||||
filterItemBuilder(context, animation, item.widget, index),
|
||||
itemBuilder: (context, animation, item, index) => filterItemBuilder(
|
||||
context,
|
||||
animation,
|
||||
item.widget,
|
||||
index,
|
||||
len: elements.length,
|
||||
),
|
||||
items: elements,
|
||||
),
|
||||
),
|
||||
|
@ -25,6 +25,7 @@ import 'package:filcnaplo_kreta_api/providers/homework_provider.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/message_provider.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/note_provider.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/timetable_provider.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/note/note_viewable.dart';
|
||||
import 'package:filcnaplo_premium/providers/premium_provider.dart';
|
||||
import 'package:filcnaplo_premium/ui/mobile/premium/premium_inline.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
||||
@ -135,7 +136,7 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData,
|
||||
|
||||
// Homework
|
||||
case FilterType.homework:
|
||||
items = homework_filter.getWidgets(homeworkProvider.homework);
|
||||
items = homework_filter.getWidgets(homeworkProvider.homework, context);
|
||||
break;
|
||||
|
||||
// Exams
|
||||
@ -183,7 +184,12 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData,
|
||||
}
|
||||
|
||||
Widget filterItemBuilder(
|
||||
BuildContext context, Animation<double> animation, Widget item, int index) {
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Widget item,
|
||||
int index, {
|
||||
int len = 0,
|
||||
}) {
|
||||
if (item.key == const Key("\$premium")) {
|
||||
return Provider.of<PremiumProvider>(context, listen: false).hasPremium ||
|
||||
DateTime.now().weekday <= 5
|
||||
@ -236,5 +242,32 @@ Widget filterItemBuilder(
|
||||
),
|
||||
);
|
||||
})
|
||||
: wrappedItem;
|
||||
: (len > 0
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(top: index == 0 ? 0.0 : 6.0),
|
||||
child: Container(
|
||||
padding: item is NoteViewable
|
||||
? const EdgeInsets.symmetric(vertical: 8.0)
|
||||
: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: index == 0
|
||||
? const Radius.circular(16.0)
|
||||
: const Radius.circular(8.0),
|
||||
topRight: index == 0
|
||||
? const Radius.circular(16.0)
|
||||
: const Radius.circular(8.0),
|
||||
bottomLeft: index + 1 == len
|
||||
? const Radius.circular(16.0)
|
||||
: const Radius.circular(8.0),
|
||||
bottomRight: index + 1 == len
|
||||
? const Radius.circular(16.0)
|
||||
: const Radius.circular(8.0),
|
||||
),
|
||||
),
|
||||
child: wrappedItem,
|
||||
),
|
||||
)
|
||||
: wrappedItem);
|
||||
}
|
||||
|
@ -1,14 +1,20 @@
|
||||
import 'package:filcnaplo/ui/date_widget.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/homework.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/homework/homework_viewable.dart' as mobile;
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/homework/homework_viewable.dart'
|
||||
as mobile;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
List<DateWidget> getWidgets(List<Homework> providerHomework) {
|
||||
List<DateWidget> getWidgets(
|
||||
List<Homework> providerHomework, BuildContext context) {
|
||||
List<DateWidget> items = [];
|
||||
|
||||
for (var homework in providerHomework) {
|
||||
items.add(DateWidget(
|
||||
key: homework.id,
|
||||
date: homework.deadline.year != 0 ? homework.deadline : homework.date,
|
||||
widget: mobile.HomeworkViewable(homework),
|
||||
widget: mobile.HomeworkViewable(
|
||||
homework,
|
||||
),
|
||||
));
|
||||
}
|
||||
return items;
|
||||
|
@ -8,8 +8,13 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class HomeworkTile extends StatelessWidget {
|
||||
const HomeworkTile(this.homework,
|
||||
{super.key, this.onTap, this.padding, this.censored = false});
|
||||
const HomeworkTile(
|
||||
this.homework, {
|
||||
super.key,
|
||||
this.onTap,
|
||||
this.padding,
|
||||
this.censored = false,
|
||||
});
|
||||
|
||||
final Homework homework;
|
||||
final void Function()? onTap;
|
||||
@ -20,95 +25,90 @@ class HomeworkTile extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
|
||||
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: Padding(
|
||||
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: ListTile(
|
||||
visualDensity: VisualDensity.compact,
|
||||
contentPadding: const EdgeInsets.only(left: 8.0, right: 12.0),
|
||||
onTap: onTap,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||
leading: SizedBox(
|
||||
width: 44,
|
||||
height: 44,
|
||||
child: censored
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.55),
|
||||
borderRadius: BorderRadius.circular(60.0),
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 2.0),
|
||||
child: Icon(
|
||||
SubjectIcon.resolveVariant(
|
||||
subject: homework.subject, context: context),
|
||||
size: 28.0,
|
||||
color: AppColors.of(context).text.withOpacity(.75),
|
||||
),
|
||||
),
|
||||
),
|
||||
title: censored
|
||||
? Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: 160,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.85),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
homework.subject.renamedTo ?? homework.subject.name.capital(),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontStyle: homework.subject.isRenamed &&
|
||||
settingsProvider.renamedSubjectsItalics
|
||||
? FontStyle.italic
|
||||
: null),
|
||||
),
|
||||
subtitle: censored
|
||||
? Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: 100,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.45),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
homework.content.escapeHtml().replaceAll('\n', ' '),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
trailing: censored
|
||||
return Padding(
|
||||
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: ListTile(
|
||||
visualDensity: VisualDensity.compact,
|
||||
contentPadding: const EdgeInsets.only(left: 8.0, right: 12.0),
|
||||
onTap: onTap,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||
leading: SizedBox(
|
||||
width: 44,
|
||||
height: 44,
|
||||
child: censored
|
||||
? Container(
|
||||
width: 15,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.45),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
color: AppColors.of(context).text.withOpacity(.55),
|
||||
borderRadius: BorderRadius.circular(60.0),
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
FeatherIcons.home,
|
||||
color: AppColors.of(context).text.withOpacity(.75),
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 2.0),
|
||||
child: Icon(
|
||||
SubjectIcon.resolveVariant(
|
||||
subject: homework.subject, context: context),
|
||||
size: 28.0,
|
||||
color: AppColors.of(context).text.withOpacity(.75),
|
||||
),
|
||||
),
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
title: censored
|
||||
? Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: 160,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.85),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
homework.subject.renamedTo ?? homework.subject.name.capital(),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontStyle: homework.subject.isRenamed &&
|
||||
settingsProvider.renamedSubjectsItalics
|
||||
? FontStyle.italic
|
||||
: null),
|
||||
),
|
||||
subtitle: censored
|
||||
? Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: 100,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.45),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
homework.content.escapeHtml().replaceAll('\n', ' '),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
trailing: censored
|
||||
? Container(
|
||||
width: 15,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.45),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
FeatherIcons.home,
|
||||
color: AppColors.of(context).text.withOpacity(.75),
|
||||
),
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -16,12 +16,51 @@ class GradesCount extends StatelessWidget {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 6.0, top: 6.0, left: 12.0, right: 6.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: gradesCount
|
||||
.mapIndexed(
|
||||
(index, e) => GradesCountItem(count: e, value: index + 1))
|
||||
.toList(),
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(children: [
|
||||
TextSpan(
|
||||
text: gradesCount.reduce((a, b) => a + b).toString(),
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const TextSpan(
|
||||
text: "x",
|
||||
style: TextStyle(
|
||||
fontSize: 13.0,
|
||||
),
|
||||
),
|
||||
]),
|
||||
style: const TextStyle(fontSize: 15.0),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10.0,
|
||||
),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
child: VerticalDivider(
|
||||
width: 2,
|
||||
thickness: 2,
|
||||
indent: 2,
|
||||
endIndent: 2,
|
||||
color: MediaQuery.of(context).platformBrightness ==
|
||||
Brightness.light
|
||||
? Colors.grey.shade300
|
||||
: Colors.grey.shade700,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: gradesCount
|
||||
.mapIndexed((index, e) => Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0),
|
||||
child: GradesCountItem(count: e, value: index + 1)))
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class GradesCountItem extends StatelessWidget {
|
||||
]),
|
||||
style: const TextStyle(fontSize: 15.0),
|
||||
),
|
||||
const SizedBox(width: 5.0),
|
||||
const SizedBox(width: 3.0),
|
||||
GradeValueWidget(GradeValue(value, "Value", "Value", 100),
|
||||
size: 19.0, fill: true, shadow: false),
|
||||
],
|
||||
|
@ -351,7 +351,8 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
if (index == 0)
|
||||
const SizedBox(key: Key("\$premium")),
|
||||
...sortDateWidgets(context,
|
||||
dateWidgets: dateWidgets.data!),
|
||||
dateWidgets: dateWidgets.data!,
|
||||
padding: EdgeInsets.zero),
|
||||
],
|
||||
itemBuilder: filterItemBuilder,
|
||||
spawnIsolate: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user