chore: add max height constraint for board text cell

This commit is contained in:
appflowy 2022-08-25 14:38:13 +08:00
parent 96429e29c5
commit d0f476dc72
2 changed files with 23 additions and 35 deletions

View File

@ -40,11 +40,12 @@ class _BoardTextCellState extends State<BoardTextCell> {
return Align( return Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Padding( child: Padding(
padding: padding: EdgeInsets.symmetric(
EdgeInsets.symmetric(vertical: BoardSizes.cardCellVPadding), vertical: BoardSizes.cardCellVPadding,
child: FlowyText.medium( ),
state.content, child: ConstrainedBox(
fontSize: 14, constraints: const BoxConstraints(maxHeight: 120),
child: FlowyText.medium(state.content, fontSize: 14),
), ),
), ),
); );

View File

@ -4,15 +4,16 @@ import 'package:provider/provider.dart';
class FlowyText extends StatelessWidget { class FlowyText extends StatelessWidget {
final String title; final String title;
final TextOverflow overflow; final TextOverflow? overflow;
final double fontSize; final double fontSize;
final FontWeight fontWeight; final FontWeight fontWeight;
final TextAlign? textAlign; final TextAlign? textAlign;
final Color? color; final Color? color;
const FlowyText( const FlowyText(
this.title, { this.title, {
Key? key, Key? key,
this.overflow = TextOverflow.ellipsis, this.overflow = TextOverflow.clip,
this.fontSize = 16, this.fontSize = 16,
this.fontWeight = FontWeight.w400, this.fontWeight = FontWeight.w400,
this.textAlign, this.textAlign,
@ -20,47 +21,33 @@ class FlowyText extends StatelessWidget {
}) : super(key: key); }) : super(key: key);
const FlowyText.semibold(this.title, const FlowyText.semibold(this.title,
{Key? key, {Key? key, this.fontSize = 16, this.overflow, this.color, this.textAlign})
this.fontSize = 16,
TextOverflow? overflow,
this.color,
this.textAlign})
: fontWeight = FontWeight.w600, : fontWeight = FontWeight.w600,
overflow = overflow ?? TextOverflow.ellipsis,
super(key: key); super(key: key);
const FlowyText.medium(this.title, const FlowyText.medium(this.title,
{Key? key, {Key? key, this.fontSize = 16, this.overflow, this.color, this.textAlign})
this.fontSize = 16,
TextOverflow? overflow,
this.color,
this.textAlign})
: fontWeight = FontWeight.w500, : fontWeight = FontWeight.w500,
overflow = overflow ?? TextOverflow.ellipsis,
super(key: key); super(key: key);
const FlowyText.regular(this.title, const FlowyText.regular(this.title,
{Key? key, {Key? key, this.fontSize = 16, this.overflow, this.color, this.textAlign})
this.fontSize = 16,
TextOverflow? overflow,
this.color,
this.textAlign})
: fontWeight = FontWeight.w400, : fontWeight = FontWeight.w400,
overflow = overflow ?? TextOverflow.ellipsis,
super(key: key); super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = context.watch<AppTheme>(); final theme = context.watch<AppTheme>();
return Text(title, return Text(
softWrap: false, title,
textAlign: textAlign, textAlign: textAlign,
overflow: overflow, overflow: overflow ?? TextOverflow.clip,
style: TextStyle( style: TextStyle(
color: color ?? theme.textColor, color: color ?? theme.textColor,
fontWeight: fontWeight, fontWeight: fontWeight,
fontSize: fontSize, fontSize: fontSize,
fontFamily: 'Mulish', fontFamily: 'Mulish',
)); ),
);
} }
} }