finished new exam tile

This commit is contained in:
Kima 2023-12-31 00:05:43 +01:00
parent 6297b9cc24
commit 71e9bbc830
3 changed files with 47 additions and 30 deletions

View File

@ -1,16 +1,18 @@
import 'package:filcnaplo/helpers/subject.dart'; import 'package:filcnaplo/helpers/subject.dart';
import 'package:filcnaplo/theme/colors/colors.dart'; import 'package:filcnaplo/theme/colors/colors.dart';
import 'package:filcnaplo_kreta_api/models/exam.dart'; import 'package:filcnaplo_kreta_api/models/exam.dart';
import 'package:filcnaplo_mobile_ui/common/round_border_icon.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:flutter_feather_icons/flutter_feather_icons.dart';
class ExamTile extends StatelessWidget { class ExamTile extends StatelessWidget {
const ExamTile(this.exam, {super.key, this.onTap, this.padding}); const ExamTile(this.exam,
{super.key, this.onTap, this.padding, this.showSubject = true});
final Exam exam; final Exam exam;
final void Function()? onTap; final void Function()? onTap;
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
final bool showSubject;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -20,42 +22,46 @@ class ExamTile extends StatelessWidget {
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: 10.0),
onTap: onTap, onTap: onTap,
shape: shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)), RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)),
leading: SizedBox( leading: const RoundBorderIcon(
width: 44, icon: Icon(
height: 44, Icons.edit_document,
child: Padding( size: 22.0,
padding: const EdgeInsets.only(top: 2.0), weight: 2.5,
child: Icon( ),
SubjectIcon.resolveVariant( padding: 5.0,
subject: exam.subject, context: context), width: 1.0,
size: 28.0,
color: AppColors.of(context).text.withOpacity(.75),
), ),
)),
title: Text( title: Text(
exam.description != "" showSubject
? exam.mode?.description ?? 'Számonkérés'
: (exam.description != ""
? exam.description ? exam.description
: (exam.mode?.description ?? "Számonkérés"), : (exam.mode?.description ?? "Számonkérés")),
maxLines: 2, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w600), style: const TextStyle(fontWeight: FontWeight.w600),
), ),
subtitle: Text( subtitle: Text(
exam.subject.isRenamed showSubject
? (exam.subject.isRenamed
? exam.subject.renamedTo! ? exam.subject.renamedTo!
: exam.subject.name.capital(), : exam.subject.name.capital())
: exam.mode?.description ?? 'Számonkérés',
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w500), style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 13.0),
),
trailing: Icon(
FeatherIcons.edit,
color: AppColors.of(context).text.withOpacity(.75),
), ),
trailing: showSubject
? Icon(
SubjectIcon.resolveVariant(
context: context, subject: exam.subject),
color: AppColors.of(context).text.withOpacity(.5),
)
: null,
minLeadingWidth: 0, minLeadingWidth: 0,
), ),
), ),

View File

@ -6,14 +6,21 @@ import 'package:filcnaplo_mobile_ui/common/widgets/exam/exam_view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExamViewable extends StatelessWidget { class ExamViewable extends StatelessWidget {
const ExamViewable(this.exam, {super.key}); const ExamViewable(this.exam,
{super.key, this.showSubject = true, this.tilePadding});
final Exam exam; final Exam exam;
final bool showSubject;
final EdgeInsetsGeometry? tilePadding;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Viewable( return Viewable(
tile: ExamTile(exam), tile: ExamTile(
exam,
showSubject: showSubject,
padding: tilePadding,
),
view: CardHandle(child: ExamView(exam)), view: CardHandle(child: ExamView(exam)),
); );
} }

View File

@ -217,7 +217,11 @@ class GradesPageState extends State<GradesPage> {
), ),
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
), ),
child: ExamViewable(nearestExam), child: ExamViewable(
nearestExam,
showSubject: false,
tilePadding: const EdgeInsets.symmetric(horizontal: 6.0),
),
), ),
], ],
), ),