Skip to content

Commit

Permalink
refactor: flowy icon refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
richardshiue committed Oct 31, 2022
1 parent 92c5fcc commit f4d41d7
Show file tree
Hide file tree
Showing 25 changed files with 15 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class _SettingItem extends StatelessWidget {
action.title(),
fontSize: FontSizes.s12,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () {
context
.read<BoardSettingBloc>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class _SettingButtonState extends State<_SettingButton> {
controller: popoverController,
constraints: BoxConstraints.loose(const Size(260, 400)),
child: FlowyIconButton(
hoverColor: Theme.of(context).colorScheme.secondary,
width: 22,
icon: Padding(
padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 3.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ class _DateTypeOptionButton extends StatelessWidget {
constraints: BoxConstraints.loose(const Size(140, 100)),
child: FlowyButton(
text: FlowyText.medium(title, fontSize: 14),
hoverColor: Theme.of(context).colorScheme.secondary,
margin: kMargin,
rightIcon: svgWidget(
"grid/more",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class _SelectOptionCellState extends State<_SelectOptionCell> {
FlowyIconButton(
width: 30,
onPressed: () => _popoverController.show(),
hoverColor: Colors.transparent,
iconPadding: const EdgeInsets.fromLTRB(4, 4, 4, 4),
icon: svgWidget(
"editor/details",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class _EditFieldButton extends StatelessWidget {
LocaleKeys.grid_field_editProperty.tr(),
fontSize: 12,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: onTap,
),
);
Expand Down Expand Up @@ -154,7 +153,6 @@ class FieldActionCell extends StatelessWidget {
fontSize: 12,
color: enable ? null : Theme.of(context).disabledColor,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () {
if (enable) {
action.run(context, fieldContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ class _DeleteFieldButton extends StatelessWidget {
color: enable ? null : Theme.of(context).disabledColor,
),
onTap: () => onDeleted?.call(),
hoverColor: Theme.of(context).colorScheme.secondary,
onHover: (_) => popoverMutex.close(),
);
return SizedBox(height: 36, child: button);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class FieldTypeCell extends StatelessWidget {
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(fieldType.title(), fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () => onSelectField(fieldType),
leftIcon: svgWidget(
fieldType.iconName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class _SwitchFieldButton extends StatelessWidget {
fontSize: 12,
),
margin: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
hoverColor: Theme.of(context).colorScheme.secondary,
leftIcon: svgWidget(
bloc.state.field.fieldType.iconName(),
color: Theme.of(context).colorScheme.onSurface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class DateFormatButton extends StatelessWidget {
text: FlowyText.medium(LocaleKeys.grid_field_dateFormat.tr(),
fontSize: 12),
margin: GridSize.typeOptionContentInsets,
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: onTap,
onHover: onHover,
rightIcon: svgWidget(
Expand Down Expand Up @@ -153,7 +152,6 @@ class TimeFormatButton extends StatelessWidget {
text: FlowyText.medium(LocaleKeys.grid_field_timeFormat.tr(),
fontSize: 12),
margin: GridSize.typeOptionContentInsets,
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: onTap,
onHover: onHover,
rightIcon: svgWidget(
Expand Down Expand Up @@ -257,7 +255,6 @@ class DateFormatCell extends StatelessWidget {
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(dateFormat.title(), fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
rightIcon: checkmark,
onTap: () => onSelected(dateFormat),
),
Expand Down Expand Up @@ -340,7 +337,6 @@ class TimeFormatCell extends StatelessWidget {
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(timeFormat.title(), fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
rightIcon: checkmark,
onTap: () => onSelected(timeFormat),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class NumberTypeOptionWidget extends TypeOptionWidget {
constraints: BoxConstraints.loose(const Size(460, 440)),
child: FlowyButton(
margin: GridSize.typeOptionContentInsets,
hoverColor: Theme.of(context).colorScheme.secondary,
rightIcon: svgWidget(
"grid/more",
color: Theme.of(context).colorScheme.onSurface,
Expand Down Expand Up @@ -175,7 +174,6 @@ class NumberFormatCell extends StatelessWidget {
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(format.title(), fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () => onSelected(format),
rightIcon: checkmark,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class _OptionTitleButton extends StatelessWidget {
fontSize: 12,
textAlign: TextAlign.center,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () {
context
.read<SelectOptionTypeOptionBloc>()
Expand Down Expand Up @@ -233,7 +232,6 @@ class _AddOptionButton extends StatelessWidget {
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(),
fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () {
context
.read<SelectOptionTypeOptionBloc>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class _DeleteTag extends StatelessWidget {
child: FlowyButton(
text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr(),
fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
leftIcon: svgWidget(
"grid/delete",
color: Theme.of(context).colorScheme.onSurface,
Expand Down Expand Up @@ -197,7 +196,6 @@ class _SelectOptionColorCell extends StatelessWidget {
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(color.optionName(), fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
leftIcon: colorIcon,
rightIcon: checkmark,
onTap: () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ class _InsertButton extends StatelessWidget {
Widget build(BuildContext context) {
return FlowyIconButton(
tooltipText: LocaleKeys.tooltip_addNewRow.tr(),
hoverColor: Theme.of(context).colorScheme.secondary,
width: 20,
height: 30,
onPressed: () => context.read<RowBloc>().add(const RowEvent.createRow()),
Expand Down Expand Up @@ -184,7 +183,6 @@ class _MenuButtonState extends State<_MenuButton> {
Widget build(BuildContext context) {
return FlowyIconButton(
tooltipText: LocaleKeys.tooltip_openMenu.tr(),
hoverColor: Theme.of(context).colorScheme.secondary,
width: 20,
height: 30,
onPressed: () => widget.openMenu(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class _RowActionCell extends StatelessWidget {
fontSize: 12,
color: action.enable() ? null : Theme.of(context).disabledColor,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () {
if (action.enable()) {
action.performAction(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class _GridGroupCell extends StatelessWidget {
height: GridSize.typeOptionItemHeight,
child: FlowyButton(
text: FlowyText.medium(fieldContext.name, fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
leftIcon: svgWidget(
fieldContext.fieldType.iconName(),
color: Theme.of(context).colorScheme.onSurface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class _GridPropertyCell extends StatelessWidget {
),
),
FlowyIconButton(
hoverColor: Theme.of(context).colorScheme.secondary,
width: GridSize.typeOptionItemHeight,
onPressed: () {
context.read<GridPropertyBloc>().add(
Expand All @@ -120,7 +119,6 @@ class _GridPropertyCell extends StatelessWidget {
constraints: BoxConstraints.loose(const Size(240, 400)),
child: FlowyButton(
text: FlowyText.medium(fieldContext.name, fontSize: 12),
hoverColor: Theme.of(context).colorScheme.secondary,
leftIcon: svgWidget(
fieldContext.fieldType.iconName(),
color: Theme.of(context).colorScheme.onSurface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class _SettingItem extends StatelessWidget {
fontSize: 12,
color: action.enable() ? null : Theme.of(context).disabledColor,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () {
context
.read<GridSettingBloc>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class _SettingButton extends StatelessWidget {
margin: const EdgeInsets.all(6),
child: FlowyIconButton(
width: 22,
hoverColor: Theme.of(context).colorScheme.secondary,
icon: svgWidget(
"grid/setting/setting",
color: Theme.of(context).colorScheme.onSurface,
Expand Down
2 changes: 0 additions & 2 deletions frontend/app_flowy/lib/plugins/trash/src/trash_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class TrashCell extends StatelessWidget {
FlowyIconButton(
width: 26,
onPressed: onRestore,
hoverColor: Theme.of(context).colorScheme.secondary,
iconPadding: const EdgeInsets.all(5),
icon: svgWidget(
"editor/restore",
Expand All @@ -48,7 +47,6 @@ class TrashCell extends StatelessWidget {
FlowyIconButton(
width: 26,
onPressed: onDelete,
hoverColor: Theme.of(context).colorScheme.secondary,
iconPadding: const EdgeInsets.all(5),
icon: svgWidget(
"editor/delete",
Expand Down
2 changes: 0 additions & 2 deletions frontend/app_flowy/lib/plugins/trash/trash_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class _TrashPageState extends State<TrashPage> {
'editor/restore',
color: Theme.of(context).colorScheme.onSurface,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () => context.read<TrashBloc>().add(
const TrashEvent.restoreAll(),
),
Expand All @@ -111,7 +110,6 @@ class _TrashPageState extends State<TrashPage> {
'editor/delete',
color: Theme.of(context).colorScheme.onSurface,
),
hoverColor: Theme.of(context).colorScheme.secondary,
onTap: () =>
context.read<TrashBloc>().add(const TrashEvent.deleteAll()),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class NewAppButton extends StatelessWidget {
Widget build(BuildContext context) {
final child = FlowyTextButton(
LocaleKeys.newPageText.tr(),
hoverColor: Colors.transparent,
fontSize: FontSizes.s12,
fontWeight: FontWeight.w500,
onPressed: () async => await _showCreateAppDialog(context),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class AddButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlowyIconButton(
hoverColor: Theme.of(context).colorScheme.secondary,
width: 22,
onPressed: () {
ActionList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class ViewDisclosureButton extends StatelessWidget {
.toList(),
buildChild: (controller) {
return FlowyIconButton(
hoverColor: Colors.transparent,
iconPadding: const EdgeInsets.all(5),
width: 26,
icon: svgWidget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FlowyButton extends StatelessWidget {
final EdgeInsets margin;
final Widget? leftIcon;
final Widget? rightIcon;
final Color hoverColor;
final Color? hoverColor;
final bool isSelected;
final BorderRadius radius;

Expand All @@ -24,7 +24,7 @@ class FlowyButton extends StatelessWidget {
this.margin = const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
this.leftIcon,
this.rightIcon,
this.hoverColor = Colors.transparent,
this.hoverColor,
this.isSelected = false,
this.radius = const BorderRadius.all(Radius.circular(6)),
}) : super(key: key);
Expand All @@ -37,7 +37,7 @@ class FlowyButton extends StatelessWidget {
child: FlowyHover(
style: HoverStyle(
borderRadius: radius,
hoverColor: hoverColor,
hoverColor: hoverColor ?? Theme.of(context).colorScheme.secondary,
),
onHover: onHover,
isSelected: () => isSelected,
Expand Down Expand Up @@ -138,7 +138,7 @@ class FlowyTextButton extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: radius ?? BorderRadius.circular(2)),
fillColor: fillColor,
hoverColor: hoverColor ?? Colors.transparent,
hoverColor: hoverColor ?? Theme.of(context).colorScheme.secondary,
focusColor: Colors.transparent,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FlowyIconButton extends StatelessWidget {
this.height,
this.onPressed,
this.fillColor = Colors.transparent,
this.hoverColor = Colors.transparent,
this.hoverColor,
this.iconPadding = EdgeInsets.zero,
this.radius,
this.tooltipText,
Expand All @@ -35,21 +35,24 @@ class FlowyIconButton extends StatelessWidget {
assert(size.width > iconPadding.horizontal);
assert(size.height > iconPadding.vertical);

final childWidth = min(size.width - iconPadding.horizontal, size.height - iconPadding.vertical);
final childWidth = min(size.width - iconPadding.horizontal,
size.height - iconPadding.vertical);
final childSize = Size(childWidth, childWidth);

return ConstrainedBox(
constraints: BoxConstraints.tightFor(width: size.width, height: size.height),
constraints:
BoxConstraints.tightFor(width: size.width, height: size.height),
child: Tooltip(
message: tooltipText ?? '',
showDuration: Duration.zero,
child: RawMaterialButton(
visualDensity: VisualDensity.compact,
hoverElevation: 0,
highlightElevation: 0,
shape: RoundedRectangleBorder(borderRadius: radius ?? BorderRadius.circular(2)),
shape: RoundedRectangleBorder(
borderRadius: radius ?? BorderRadius.circular(2)),
fillColor: fillColor,
hoverColor: hoverColor,
hoverColor: hoverColor ?? Theme.of(context).colorScheme.secondary,
focusColor: Colors.transparent,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
Expand Down

0 comments on commit f4d41d7

Please sign in to comment.