added new style widgets and total grade counter

This commit is contained in:
Kima
2023-12-30 22:27:42 +01:00
parent 5476397af6
commit e010242469
7 changed files with 186 additions and 101 deletions

View File

@@ -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,
),
);
}

View File

@@ -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(),
),
],
),
),
);
}

View File

@@ -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),
],

View File

@@ -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,