chore: use theme.of(context) text theme in FlowyText (#1463)

This commit is contained in:
Richard Shiue 2022-11-19 17:53:30 +08:00 committed by GitHub
parent 500d5efc33
commit 81bc31d1b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 83 additions and 105 deletions

View File

@ -40,8 +40,7 @@ class BlankPagePlugin extends Plugin {
class BlankPagePluginDisplay extends PluginDisplay with NavigationItem {
@override
Widget get leftBarItem =>
FlowyText.medium(LocaleKeys.blankPageTitle.tr(), fontSize: 12);
Widget get leftBarItem => FlowyText.medium(LocaleKeys.blankPageTitle.tr());
@override
Widget buildWidget(PluginContext context) => const BlankPage();

View File

@ -7,7 +7,6 @@ import 'package:app_flowy/plugins/grid/presentation/widgets/toolbar/grid_propert
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
@ -105,10 +104,7 @@ class _SettingItem extends StatelessWidget {
height: 30,
child: FlowyButton(
isSelected: isSelected,
text: FlowyText.medium(
action.title(),
fontSize: FontSizes.s12,
),
text: FlowyText.medium(action.title()),
onTap: () {
context
.read<BoardSettingBloc>()

View File

@ -91,7 +91,6 @@ class SelectOptionTag extends StatelessWidget {
pressElevation: 1,
label: FlowyText.medium(
name,
fontSize: 12,
overflow: TextOverflow.clip,
),
selectedColor: color,

View File

@ -190,7 +190,6 @@ class _Title extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 6),
child: FlowyText.medium(
LocaleKeys.grid_selectOption_panelTitle.tr(),
fontSize: 12,
color: Theme.of(context).hintColor,
),
),
@ -208,7 +207,6 @@ class _CreateOptionCell extends StatelessWidget {
children: [
FlowyText.medium(
LocaleKeys.grid_selectOption_create.tr(),
fontSize: 12,
color: Theme.of(context).hintColor,
),
const HSpace(10),

View File

@ -174,7 +174,6 @@ class FieldCellButton extends StatelessWidget {
),
text: FlowyText.medium(
text,
fontSize: 12,
maxLines: maxLines,
overflow: TextOverflow.ellipsis,
),

View File

@ -78,7 +78,6 @@ class _EditFieldButton extends StatelessWidget {
child: FlowyButton(
text: FlowyText.medium(
LocaleKeys.grid_field_editProperty.tr(),
fontSize: 12,
),
onTap: onTap,
),
@ -150,7 +149,6 @@ class FieldActionCell extends StatelessWidget {
return FlowyButton(
text: FlowyText.medium(
action.title(),
fontSize: 12,
color: enable ? null : Theme.of(context).disabledColor,
),
onTap: () {

View File

@ -66,7 +66,6 @@ class _FieldEditorState extends State<FieldEditor> {
children: [
FlowyText.medium(
LocaleKeys.grid_field_editProperty.tr(),
fontSize: 12,
),
const VSpace(10),
_FieldNameTextField(popoverMutex: popoverMutex),
@ -223,7 +222,6 @@ class _DeleteFieldButton extends StatelessWidget {
Widget button = FlowyButton(
text: FlowyText.medium(
LocaleKeys.grid_field_delete.tr(),
fontSize: 12,
color: enable ? null : Theme.of(context).disabledColor,
),
onTap: () => onDeleted?.call(),

View File

@ -61,7 +61,7 @@ class FieldTypeCell extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(fieldType.title(), fontSize: 12),
text: FlowyText.medium(fieldType.title()),
onTap: () => onSelectField(fieldType),
leftIcon: svgWidget(
fieldType.iconName(),

View File

@ -111,7 +111,6 @@ class _SwitchFieldButton extends StatelessWidget {
return FlowyButton(
text: FlowyText.medium(
bloc.state.field.fieldType.title(),
fontSize: 12,
),
margin: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
leftIcon: svgWidget(

View File

@ -178,10 +178,7 @@ class CreateFieldButton extends StatelessWidget {
constraints: BoxConstraints.loose(const Size(240, 600)),
child: FlowyButton(
radius: BorderRadius.zero,
text: FlowyText.medium(
LocaleKeys.grid_field_newColumn.tr(),
fontSize: 12,
),
text: FlowyText.medium(LocaleKeys.grid_field_newColumn.tr()),
hoverColor: AFThemeExtension.of(context).lightGreyHover,
onTap: () {},
leftIcon: svgWidget(

View File

@ -122,8 +122,7 @@ class DateFormatButton extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.grid_field_dateFormat.tr(),
fontSize: 12),
text: FlowyText.medium(LocaleKeys.grid_field_dateFormat.tr()),
margin: GridSize.typeOptionContentInsets,
onTap: onTap,
onHover: onHover,
@ -149,8 +148,7 @@ class TimeFormatButton extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.grid_field_timeFormat.tr(),
fontSize: 12),
text: FlowyText.medium(LocaleKeys.grid_field_timeFormat.tr()),
margin: GridSize.typeOptionContentInsets,
onTap: onTap,
onHover: onHover,
@ -177,8 +175,7 @@ class _IncludeTimeButton extends StatelessWidget {
padding: GridSize.typeOptionContentInsets,
child: Row(
children: [
FlowyText.medium(LocaleKeys.grid_field_includeTime.tr(),
fontSize: 12),
FlowyText.medium(LocaleKeys.grid_field_includeTime.tr()),
const Spacer(),
Toggle(
value: includeTime,
@ -254,7 +251,7 @@ class DateFormatCell extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(dateFormat.title(), fontSize: 12),
text: FlowyText.medium(dateFormat.title()),
rightIcon: checkmark,
onTap: () => onSelected(dateFormat),
),
@ -336,7 +333,7 @@ class TimeFormatCell extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(timeFormat.title(), fontSize: 12),
text: FlowyText.medium(timeFormat.title()),
rightIcon: checkmark,
onTap: () => onSelected(timeFormat),
),

View File

@ -72,12 +72,10 @@ class NumberTypeOptionWidget extends TypeOptionWidget {
),
text: Row(
children: [
FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr(),
fontSize: 12),
FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr()),
// const HSpace(6),
const Spacer(),
FlowyText.regular(state.typeOption.format.title(),
fontSize: 12),
FlowyText.regular(state.typeOption.format.title()),
],
),
),
@ -173,7 +171,7 @@ class NumberFormatCell extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(format.title(), fontSize: 12),
text: FlowyText.medium(format.title()),
onTap: () => onSelected(format),
rightIcon: checkmark,
),

View File

@ -72,7 +72,6 @@ class OptionTitle extends StatelessWidget {
List<Widget> children = [
FlowyText.medium(
LocaleKeys.grid_field_optionTitle.tr(),
fontSize: 12,
color: Theme.of(context).hintColor,
)
];
@ -101,7 +100,6 @@ class _OptionTitleButton extends StatelessWidget {
child: FlowyButton(
text: FlowyText.medium(
LocaleKeys.grid_field_addOption.tr(),
fontSize: 12,
textAlign: TextAlign.center,
),
onTap: () {
@ -232,8 +230,7 @@ class _AddOptionButton extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(),
fontSize: 12),
text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr()),
onTap: () {
context
.read<SelectOptionTypeOptionBloc>()

View File

@ -1,7 +1,6 @@
import 'package:app_flowy/plugins/grid/application/field/type_option/edit_select_option_bloc.dart';
import 'package:app_flowy/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
@ -86,8 +85,7 @@ class _DeleteTag extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr(),
fontSize: 12),
text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr()),
leftIcon: svgWidget(
"grid/delete",
color: Theme.of(context).colorScheme.onSurface,
@ -145,7 +143,6 @@ class SelectOptionColorList extends StatelessWidget {
height: GridSize.typeOptionItemHeight,
child: FlowyText.medium(
LocaleKeys.grid_selectOption_colorPanelTitle.tr(),
fontSize: FontSizes.s12,
textAlign: TextAlign.left,
color: Theme.of(context).hintColor,
),
@ -195,7 +192,7 @@ class _SelectOptionColorCell extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(color.optionName(), fontSize: 12),
text: FlowyText.medium(color.optionName()),
leftIcon: colorIcon,
rightIcon: checkmark,
onTap: () {

View File

@ -60,7 +60,6 @@ class _RowActionCell extends StatelessWidget {
child: FlowyButton(
text: FlowyText.medium(
action.title(),
fontSize: 12,
color: action.enable() ? null : Theme.of(context).disabledColor,
),
onTap: () {

View File

@ -198,10 +198,7 @@ class _CreateFieldButtonState extends State<_CreateFieldButton> {
height: 40,
decoration: _makeBoxDecoration(context),
child: FlowyButton(
text: FlowyText.medium(
LocaleKeys.grid_field_newColumn.tr(),
fontSize: 12,
),
text: FlowyText.medium(LocaleKeys.grid_field_newColumn.tr()),
hoverColor: AFThemeExtension.of(context).lightGreyHover,
onTap: () {},
leftIcon: svgWidget("home/add"),

View File

@ -81,7 +81,7 @@ class _GridGroupCell extends StatelessWidget {
return SizedBox(
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(fieldContext.name, fontSize: 12),
text: FlowyText.medium(fieldContext.name),
leftIcon: svgWidget(
fieldContext.fieldType.iconName(),
color: Theme.of(context).colorScheme.onSurface,

View File

@ -118,7 +118,7 @@ class _GridPropertyCell extends StatelessWidget {
offset: const Offset(20, 0),
constraints: BoxConstraints.loose(const Size(240, 400)),
child: FlowyButton(
text: FlowyText.medium(fieldContext.name, fontSize: 12),
text: FlowyText.medium(fieldContext.name),
leftIcon: svgWidget(
fieldContext.fieldType.iconName(),
color: Theme.of(context).colorScheme.onSurface,

View File

@ -100,7 +100,6 @@ class _SettingItem extends StatelessWidget {
isSelected: isSelected,
text: FlowyText.medium(
action.title(),
fontSize: 12,
color: action.enable() ? null : Theme.of(context).disabledColor,
),
onTap: () {

View File

@ -39,7 +39,7 @@ class MenuTrash extends StatelessWidget {
),
),
const HSpace(6),
FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12),
FlowyText.medium(LocaleKeys.trash_text.tr()),
],
);
}

View File

@ -25,14 +25,17 @@ class TrashCell extends StatelessWidget {
return Row(
children: [
SizedBox(
width: TrashSizes.fileNameWidth,
child: FlowyText(object.name, fontSize: 12)),
width: TrashSizes.fileNameWidth,
child: FlowyText(object.name),
),
SizedBox(
width: TrashSizes.lashModifyWidth,
child: FlowyText(dateFormatter(object.modifiedTime), fontSize: 12)),
width: TrashSizes.lashModifyWidth,
child: FlowyText(dateFormatter(object.modifiedTime)),
),
SizedBox(
width: TrashSizes.createTimeWidth,
child: FlowyText(dateFormatter(object.createTime), fontSize: 12)),
width: TrashSizes.createTimeWidth,
child: FlowyText(dateFormatter(object.createTime)),
),
const Spacer(),
FlowyIconButton(
width: 26,

View File

@ -57,7 +57,6 @@ class TrashHeader extends StatelessWidget {
width: item.width,
child: FlowyText(
item.title,
fontSize: 12,
color: Theme.of(context).disabledColor,
),
),

View File

@ -49,8 +49,7 @@ class TrashPlugin extends Plugin {
class TrashPluginDisplay extends PluginDisplay {
@override
Widget get leftBarItem =>
FlowyText.medium(LocaleKeys.trash_text.tr(), fontSize: 12);
Widget get leftBarItem => FlowyText.medium(LocaleKeys.trash_text.tr());
@override
Widget? get rightBarItem => null;

View File

@ -4,6 +4,7 @@ import 'package:app_flowy/plugins/trash/src/trash_header.dart';
import 'package:app_flowy/startup/startup.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
@ -86,12 +87,14 @@ class _TrashPageState extends State<TrashPage> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FlowyText.semibold(LocaleKeys.trash_text.tr()),
FlowyText.semibold(
LocaleKeys.trash_text.tr(),
fontSize: FontSizes.s16,
),
const Spacer(),
IntrinsicWidth(
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr(),
fontSize: 12),
text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr()),
leftIcon: svgWidget(
'editor/restore',
color: Theme.of(context).colorScheme.onSurface,
@ -104,8 +107,7 @@ class _TrashPageState extends State<TrashPage> {
const HSpace(6),
IntrinsicWidth(
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr(),
fontSize: 12),
text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr()),
leftIcon: svgWidget(
'editor/delete',
color: Theme.of(context).colorScheme.onSurface,

View File

@ -100,7 +100,6 @@ class SignUpPrompt extends StatelessWidget {
children: [
FlowyText.medium(
LocaleKeys.signIn_dontHaveAnAccount.tr(),
fontSize: FontSizes.s12,
color: Theme.of(context).hintColor,
),
TextButton(

View File

@ -169,7 +169,6 @@ class AppActionList extends StatelessWidget {
selector: (state) => state.app,
builder: (context, app) => FlowyText.medium(
app.name,
fontSize: 12,
overflow: TextOverflow.ellipsis,
),
),

View File

@ -87,7 +87,6 @@ class ViewSectionItem extends StatelessWidget {
Expanded(
child: FlowyText.regular(
state.view.name,
fontSize: 12,
overflow: TextOverflow.ellipsis,
),
),

View File

@ -67,7 +67,6 @@ class MenuUser extends StatelessWidget {
}
return FlowyText.medium(
name,
fontSize: FontSizes.s12,
overflow: TextOverflow.ellipsis,
);
}

View File

@ -191,7 +191,10 @@ class EllipsisNaviItem extends NavigationItem {
});
@override
Widget get leftBarItem => const FlowyText.medium('...');
Widget get leftBarItem => FlowyText.medium(
'...',
fontSize: FontSizes.s16,
);
@override
NavigationCallback get action => (id) {};

View File

@ -1,4 +1,5 @@
import 'package:app_flowy/startup/startup.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -16,7 +17,11 @@ class FlowyMessageToast extends StatelessWidget {
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: FlowyText.medium(message, color: Colors.white),
child: FlowyText.medium(
message,
color: Colors.white,
fontSize: FontSizes.s16,
),
),
);
}

View File

@ -1,4 +1,5 @@
import 'package:app_flowy/startup/startup.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flutter/material.dart';
import 'package:app_flowy/workspace/application/user/settings_user_bloc.dart';
@ -93,7 +94,10 @@ class _CurrentIcon extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return SimpleDialog(
title: const FlowyText.medium('Select an Icon'),
title: FlowyText.medium(
'Select an Icon',
fontSize: FontSizes.s16,
),
children: <Widget>[
SizedBox(
height: 300, width: 300, child: IconGallery(_setIcon))

View File

@ -46,8 +46,11 @@ class _CreateTextFieldDialog extends State<NavigatorTextFieldDialog> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
...[
FlowyText.medium(widget.title,
color: Theme.of(context).disabledColor),
FlowyText.medium(
widget.title,
color: Theme.of(context).disabledColor,
fontSize: FontSizes.s16,
),
VSpace(Insets.sm * 1.5),
],
FlowyFormTextInput(
@ -117,6 +120,7 @@ class _CreateFlowyAlertDialog extends State<NavigatorAlertDialog> {
...[
FlowyText.medium(
widget.title,
fontSize: FontSizes.s16,
color: Theme.of(context).disabledColor,
),
],
@ -164,13 +168,16 @@ class NavigatorOkCancelDialog extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (title != null) ...[
FlowyText.medium(title!.toUpperCase()),
FlowyText.medium(
title!.toUpperCase(),
fontSize: FontSizes.s16,
),
VSpace(Insets.sm * 1.5),
Container(
color: Theme.of(context).colorScheme.surfaceVariant, height: 1),
VSpace(Insets.m * 1.5),
],
FlowyText.medium(message, fontSize: FontSizes.s12),
FlowyText.medium(message),
SizedBox(height: Insets.l),
OkCancelButton(
onOkPressed: () {

View File

@ -3,7 +3,6 @@ import 'package:app_flowy/workspace/presentation/home/toast.dart';
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
@ -125,7 +124,6 @@ class FlowyVersionDescription extends CustomActionCell {
if (snapshot.hasError) {
return FlowyText(
"Error: ${snapshot.error}",
fontSize: FontSizes.s12,
color: Theme.of(context).disabledColor,
);
}
@ -148,7 +146,6 @@ class FlowyVersionDescription extends CustomActionCell {
const VSpace(6),
FlowyText(
"$appName $version.$buildNumber",
fontSize: FontSizes.s12,
color: Theme.of(context).hintColor,
),
],
@ -171,7 +168,7 @@ class BubbleActionWrapper extends ActionCell {
BubbleActionWrapper(this.inner);
@override
Widget? icon(Color iconColor) => FlowyText.regular(inner.emoji, fontSize: 12);
Widget? icon(Color iconColor) => FlowyText.regular(inner.emoji);
@override
String get name => inner.name;

View File

@ -127,7 +127,6 @@ class ActionCellWidget<T extends PopoverAction> extends StatelessWidget {
Expanded(
child: FlowyText.medium(
actionCell.name,
fontSize: 12,
overflow: TextOverflow.visible,
),
),

View File

@ -1,11 +1,10 @@
import 'package:flowy_infra/text_style.dart';
import 'package:flutter/material.dart';
class FlowyText extends StatelessWidget {
final String title;
final TextOverflow? overflow;
final double fontSize;
final FontWeight fontWeight;
final double? fontSize;
final FontWeight? fontWeight;
final TextAlign? textAlign;
final int? maxLines;
final Color? color;
@ -14,28 +13,28 @@ class FlowyText extends StatelessWidget {
this.title, {
Key? key,
this.overflow = TextOverflow.clip,
this.fontSize = 16,
this.fontWeight = FontWeight.w400,
this.fontSize,
this.fontWeight,
this.textAlign,
this.color,
this.maxLines = 1,
}) : super(key: key);
const FlowyText.semibold(
const FlowyText.regular(
this.title, {
Key? key,
this.fontSize = 16,
this.fontSize,
this.overflow,
this.color,
this.textAlign,
this.maxLines = 1,
}) : fontWeight = FontWeight.w600,
}) : fontWeight = FontWeight.w400,
super(key: key);
const FlowyText.medium(
this.title, {
Key? key,
this.fontSize = 16,
this.fontSize,
this.overflow,
this.color,
this.textAlign,
@ -43,15 +42,15 @@ class FlowyText extends StatelessWidget {
}) : fontWeight = FontWeight.w500,
super(key: key);
const FlowyText.regular(
const FlowyText.semibold(
this.title, {
Key? key,
this.fontSize = 16,
this.fontSize,
this.overflow,
this.color,
this.textAlign,
this.maxLines = 1,
}) : fontWeight = FontWeight.w400,
}) : fontWeight = FontWeight.w600,
super(key: key);
@override
@ -61,11 +60,11 @@ class FlowyText extends StatelessWidget {
maxLines: maxLines,
textAlign: textAlign,
overflow: overflow ?? TextOverflow.clip,
style: TextStyles.general(
fontSize: fontSize,
fontWeight: fontWeight,
color: color,
),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: fontSize,
fontWeight: fontWeight,
color: color,
),
);
}
}

View File

@ -1,5 +1,5 @@
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra/text_style.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flutter/material.dart';
class RoundedTextButton extends StatelessWidget {
@ -44,12 +44,10 @@ class RoundedTextButton extends StatelessWidget {
child: SizedBox.expand(
child: TextButton(
onPressed: onPressed,
child: Text(
child: FlowyText.medium(
title ?? '',
style: TextStyles.general(
fontSize: fontSize,
color: textColor,
),
fontSize: fontSize,
color: textColor,
),
),
),