censor stuff

This commit is contained in:
ezyyeah 2022-12-29 00:40:27 +01:00
parent 0f5bf5f66e
commit c478380c04
2 changed files with 134 additions and 48 deletions

View File

@ -10,11 +10,12 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class GradeTile extends StatelessWidget { class GradeTile extends StatelessWidget {
const GradeTile(this.grade, {Key? key, this.onTap, this.padding}) : super(key: key); const GradeTile(this.grade, {Key? key, this.onTap, this.padding, this.censored = false}) : super(key: key);
final Grade grade; final Grade grade;
final void Function()? onTap; final void Function()? onTap;
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
final bool censored;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -76,7 +77,14 @@ class GradeTile extends StatelessWidget {
: SizedBox( : SizedBox(
width: 44, width: 44,
height: 44, height: 44,
child: Center( child: censored
? Container(
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(.55),
borderRadius: BorderRadius.circular(60.0),
),
)
: Center(
child: Padding( child: Padding(
padding: leadingPadding, padding: leadingPadding,
child: Icon( child: Icon(
@ -87,14 +95,40 @@ class GradeTile extends StatelessWidget {
), ),
), ),
), ),
title: Text( title: censored
? Wrap(
children: [
Container(
width: 110,
height: 15,
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(.85),
borderRadius: BorderRadius.circular(8.0),
),
),
],
)
: Text(
title, title,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w600), style: const TextStyle(fontWeight: FontWeight.w600),
), ),
subtitle: subtitle != "" subtitle: subtitle != ""
? Text( ? censored
? Wrap(
children: [
Container(
width: 50,
height: 10,
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(.45),
borderRadius: BorderRadius.circular(8.0),
),
),
],
)
: Text(
subtitle, subtitle,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@ -111,6 +145,15 @@ class GradeTile extends StatelessWidget {
calculatorProvider.removeGrade(grade); calculatorProvider.removeGrade(grade);
}, },
) )
: censored
? Container(
width: 15,
height: 15,
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(.45),
borderRadius: BorderRadius.circular(8.0),
),
)
: GradeValueWidget(grade.value), : GradeValueWidget(grade.value),
minLeadingWidth: isSubjectView ? 32.0 : 0, minLeadingWidth: isSubjectView ? 32.0 : 0,
), ),

View File

@ -15,12 +15,14 @@ class MessageTile extends StatelessWidget {
this.messages, this.messages,
this.padding, this.padding,
this.onTap, this.onTap,
this.censored = false,
}) : super(key: key); }) : super(key: key);
final Message message; final Message message;
final List<Message>? messages; final List<Message>? messages;
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
final Function()? onTap; final Function()? onTap;
final bool censored;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -38,13 +40,28 @@ class MessageTile extends StatelessWidget {
name: message.author, name: message.author,
radius: 22.0, radius: 22.0,
backgroundColor: ColorUtils.stringToColor(message.author), backgroundColor: ColorUtils.stringToColor(message.author),
censored: censored,
) )
: ProfileImage( : ProfileImage(
name: "Béla", name: "Béla",
radius: 22.0, radius: 22.0,
backgroundColor: Theme.of(context).colorScheme.secondary, backgroundColor: Theme.of(context).colorScheme.secondary,
censored: censored,
), ),
title: Row( title: censored
? Wrap(
children: [
Container(
width: 105,
height: 15,
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(.85),
borderRadius: BorderRadius.circular(8.0),
),
),
],
)
: Row(
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
@ -57,13 +74,39 @@ class MessageTile extends StatelessWidget {
if (message.attachments.isNotEmpty) const Icon(FeatherIcons.paperclip, size: 16.0) if (message.attachments.isNotEmpty) const Icon(FeatherIcons.paperclip, size: 16.0)
], ],
), ),
subtitle: Text( subtitle: censored
? Wrap(
children: [
Container(
width: 150,
height: 10,
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(.45),
borderRadius: BorderRadius.circular(8.0),
),
),
],
)
: Text(
message.subject, message.subject,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14.0), style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14.0),
), ),
trailing: Text( trailing: censored
? Wrap(
children: [
Container(
width: 35,
height: 15,
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(.45),
borderRadius: BorderRadius.circular(8.0),
),
),
],
)
: Text(
message.date.format(context), message.date.format(context),
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,