fix: svg sizes (#3238)

* refactor: svg impl

* fix: icon sizes in appearance settings

* chore: change button icon

* fix: size of restore button

* chore: fix iconbutton api

* fix: analyzer issues
This commit is contained in:
Alex Wallen 2023-08-18 18:53:10 -07:00 committed by GitHub
parent de01bf70cd
commit c5719be7ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 22 deletions

View File

@ -31,7 +31,6 @@ class ColorSchemeSetting extends StatelessWidget {
onResetRequested: context.read<AppearanceSettingsCubit>().resetTheme,
trailing: [
ColorSchemeUploadOverlayButton(bloc: bloc),
const SizedBox(width: 4),
ColorSchemeUploadPopover(currentTheme: currentTheme, bloc: bloc),
],
);
@ -49,6 +48,7 @@ class ColorSchemeUploadOverlayButton extends StatelessWidget {
width: 24,
icon: const FlowySvg(
FlowySvgs.folder_m,
size: Size.square(16),
),
iconColorOnHover: Theme.of(context).colorScheme.onPrimary,
onPressed: () => Dialogs.show(

View File

@ -36,7 +36,7 @@ class ThemeSettingEntryTemplateWidget extends StatelessWidget {
key: resetButtonKey,
width: 24,
icon: FlowySvg(
FlowySvgs.reload_s,
FlowySvgs.restore_s,
color: Theme.of(context).iconTheme.color,
),
iconColorOnHover: Theme.of(context).colorScheme.onPrimary,

View File

@ -236,9 +236,9 @@ class _RecoverDefaultStorageButtonState
return FlowyIconButton(
hoverColor: Theme.of(context).colorScheme.secondaryContainer,
tooltipText: LocaleKeys.settings_files_recoverLocationTooltips.tr(),
icon: FlowySvg(
icon: const FlowySvg(
FlowySvgs.restore_s,
color: Theme.of(context).iconTheme.color,
size: Size.square(24),
),
onPressed: () async {
// reset to the default directory and reload app

View File

@ -1,4 +1,3 @@
import 'dart:math';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flowy_svg/flowy_svg.dart';
@ -48,10 +47,6 @@ 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 childSize = Size(childWidth, childWidth);
return ConstrainedBox(
constraints: BoxConstraints.tightFor(
width: size.width,
@ -85,7 +80,9 @@ class FlowyIconButton extends StatelessWidget {
),
child: Padding(
padding: iconPadding,
child: SizedBox.fromSize(size: childSize, child: child),
child: Center(
child: child,
),
),
),
),

View File

@ -50,25 +50,17 @@ class FlowySvg extends StatelessWidget {
Widget build(BuildContext context) {
final iconColor = color ?? Theme.of(context).iconTheme.color;
final child = SvgPicture.asset(
return SvgPicture.asset(
_normalized(),
colorFilter:
iconColor != null && blendMode != null
width: size?.width,
height: size?.height,
colorFilter: iconColor != null && blendMode != null
? ColorFilter.mode(
iconColor,
blendMode!,
)
: null,
);
if (size != null) {
return SizedBox.fromSize(
size: size,
child: child,
);
}
return child;
}
/// If the SVG's path does not start with `assets/`, it is