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(
|
items.add(DateWidget(
|
||||||
date: date,
|
date: date,
|
||||||
widget: Panel(
|
widget: Panel(
|
||||||
|
isTransparent: true,
|
||||||
key: ValueKey(date),
|
key: ValueKey(date),
|
||||||
padding: padding ?? const EdgeInsets.symmetric(vertical: 6.0),
|
padding: padding ?? const EdgeInsets.symmetric(vertical: 6.0),
|
||||||
title: cst ? Text(date.format(context, forceToday: true)) : null,
|
title: cst ? Text(date.format(context, forceToday: true)) : null,
|
||||||
@ -141,8 +142,13 @@ List<Widget> sortDateWidgets(
|
|||||||
spawnIsolate: false,
|
spawnIsolate: false,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemBuilder: (context, animation, item, index) =>
|
itemBuilder: (context, animation, item, index) => filterItemBuilder(
|
||||||
filterItemBuilder(context, animation, item.widget, index),
|
context,
|
||||||
|
animation,
|
||||||
|
item.widget,
|
||||||
|
index,
|
||||||
|
len: elements.length,
|
||||||
|
),
|
||||||
items: elements,
|
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/message_provider.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/note_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/note_provider.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/timetable_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/providers/premium_provider.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/premium/premium_inline.dart';
|
import 'package:filcnaplo_premium/ui/mobile/premium/premium_inline.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
||||||
@ -135,7 +136,7 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData,
|
|||||||
|
|
||||||
// Homework
|
// Homework
|
||||||
case FilterType.homework:
|
case FilterType.homework:
|
||||||
items = homework_filter.getWidgets(homeworkProvider.homework);
|
items = homework_filter.getWidgets(homeworkProvider.homework, context);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Exams
|
// Exams
|
||||||
@ -183,7 +184,12 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget filterItemBuilder(
|
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")) {
|
if (item.key == const Key("\$premium")) {
|
||||||
return Provider.of<PremiumProvider>(context, listen: false).hasPremium ||
|
return Provider.of<PremiumProvider>(context, listen: false).hasPremium ||
|
||||||
DateTime.now().weekday <= 5
|
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/ui/date_widget.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/homework.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 = [];
|
List<DateWidget> items = [];
|
||||||
|
|
||||||
for (var homework in providerHomework) {
|
for (var homework in providerHomework) {
|
||||||
items.add(DateWidget(
|
items.add(DateWidget(
|
||||||
key: homework.id,
|
key: homework.id,
|
||||||
date: homework.deadline.year != 0 ? homework.deadline : homework.date,
|
date: homework.deadline.year != 0 ? homework.deadline : homework.date,
|
||||||
widget: mobile.HomeworkViewable(homework),
|
widget: mobile.HomeworkViewable(
|
||||||
|
homework,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
|
@ -8,8 +8,13 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class HomeworkTile extends StatelessWidget {
|
class HomeworkTile extends StatelessWidget {
|
||||||
const HomeworkTile(this.homework,
|
const HomeworkTile(
|
||||||
{super.key, this.onTap, this.padding, this.censored = false});
|
this.homework, {
|
||||||
|
super.key,
|
||||||
|
this.onTap,
|
||||||
|
this.padding,
|
||||||
|
this.censored = false,
|
||||||
|
});
|
||||||
|
|
||||||
final Homework homework;
|
final Homework homework;
|
||||||
final void Function()? onTap;
|
final void Function()? onTap;
|
||||||
@ -20,17 +25,13 @@ class HomeworkTile extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
|
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
|
||||||
|
|
||||||
return Material(
|
return Padding(
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
|
||||||
child: Padding(
|
|
||||||
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
|
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
contentPadding: const EdgeInsets.only(left: 8.0, right: 12.0),
|
contentPadding: const EdgeInsets.only(left: 8.0, right: 12.0),
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
shape:
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
|
||||||
leading: SizedBox(
|
leading: SizedBox(
|
||||||
width: 44,
|
width: 44,
|
||||||
height: 44,
|
height: 44,
|
||||||
@ -109,7 +110,6 @@ class HomeworkTile extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
minLeadingWidth: 0,
|
minLeadingWidth: 0,
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,52 @@ class GradesCount extends StatelessWidget {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(bottom: 6.0, top: 6.0, left: 12.0, right: 6.0),
|
const EdgeInsets.only(bottom: 6.0, top: 6.0, left: 12.0, right: 6.0),
|
||||||
|
child: IntrinsicHeight(
|
||||||
child: Row(
|
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,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: gradesCount
|
children: gradesCount
|
||||||
.mapIndexed(
|
.mapIndexed((index, e) => Padding(
|
||||||
(index, e) => GradesCountItem(count: e, value: index + 1))
|
padding: const EdgeInsets.only(left: 10.0),
|
||||||
|
child: GradesCountItem(count: e, value: index + 1)))
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class GradesCountItem extends StatelessWidget {
|
|||||||
]),
|
]),
|
||||||
style: const TextStyle(fontSize: 15.0),
|
style: const TextStyle(fontSize: 15.0),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5.0),
|
const SizedBox(width: 3.0),
|
||||||
GradeValueWidget(GradeValue(value, "Value", "Value", 100),
|
GradeValueWidget(GradeValue(value, "Value", "Value", 100),
|
||||||
size: 19.0, fill: true, shadow: false),
|
size: 19.0, fill: true, shadow: false),
|
||||||
],
|
],
|
||||||
|
@ -351,7 +351,8 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
|||||||
if (index == 0)
|
if (index == 0)
|
||||||
const SizedBox(key: Key("\$premium")),
|
const SizedBox(key: Key("\$premium")),
|
||||||
...sortDateWidgets(context,
|
...sortDateWidgets(context,
|
||||||
dateWidgets: dateWidgets.data!),
|
dateWidgets: dateWidgets.data!,
|
||||||
|
padding: EdgeInsets.zero),
|
||||||
],
|
],
|
||||||
itemBuilder: filterItemBuilder,
|
itemBuilder: filterItemBuilder,
|
||||||
spawnIsolate: false,
|
spawnIsolate: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user