Files
SpotiFLAC-Mobile/lib/widgets/expressive_button.dart
T
zarzet 37e21b5712 feat(branding): rename app and native backend to Mornye
Rename the Dart package, Android and iOS identifiers, Rust crates, native libraries, and Discord plugin. Preserve legacy data readers and compatibility aliases.

Update localized branding, documentation, artwork, build tooling, and release artifacts. Route Telegram release notifications to @mornyeupdates and link @mornyecommunity.
2026-10-20 12:00:44 +07:00

118 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:material_3_expressive/material_3_expressive.dart';
import 'package:mornye/theme/material_expressive.dart';
import 'package:mornye/widgets/app_icon.dart';
/// Expressive actions retain caller colors, disabled states and flexible labels.
class ExpressiveButton extends StatelessWidget {
const ExpressiveButton({
super.key,
required this.onPressed,
required this.child,
this.icon,
this.style,
this.outlined = false,
this.tonal = false,
this.text = false,
});
final VoidCallback? onPressed;
final Widget child;
final Widget? icon;
final ButtonStyle? style;
final bool outlined;
final bool tonal;
/// Low-emphasis action without a container, like [TextButton].
final bool text;
@override
Widget build(BuildContext context) {
final icon = this.icon == null ? null : symbolIconWidget(this.icon!);
if (!materialExpressiveEnabled(context)) {
if (icon != null) {
// Keep the standard icon spacing and asymmetric padding.
if (text) {
return TextButton.icon(
onPressed: onPressed,
style: style,
icon: icon,
label: child,
);
}
if (outlined) {
return OutlinedButton.icon(
onPressed: onPressed,
style: style,
icon: icon,
label: child,
);
}
if (tonal) {
return FilledButton.tonalIcon(
onPressed: onPressed,
style: style,
icon: icon,
label: child,
);
}
return FilledButton.icon(
onPressed: onPressed,
style: style,
icon: icon,
label: child,
);
}
if (text) {
return TextButton(onPressed: onPressed, style: style, child: child);
}
if (outlined) {
return OutlinedButton(onPressed: onPressed, style: style, child: child);
}
if (tonal) {
return FilledButton.tonal(
onPressed: onPressed,
style: style,
child: child,
);
}
return FilledButton(onPressed: onPressed, style: style, child: child);
}
final content = Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[icon, const SizedBox(width: 8)],
Flexible(child: child),
],
);
final states = <WidgetState>{if (onPressed == null) WidgetState.disabled};
return MaterialExpressiveScope(
child: M3EButton(
onPressed: onPressed,
style: text
? M3EButtonStyle.text
: outlined
? M3EButtonStyle.outlined
: tonal
? M3EButtonStyle.tonal
: M3EButtonStyle.filled,
decoration: M3EButtonDecoration(
backgroundColor: style?.backgroundColor,
foregroundColor: style?.foregroundColor,
overlayColor: style?.overlayColor,
side: style?.side,
minimumSize:
style?.minimumSize?.resolve(states) ?? const Size(48, 48),
maximumSize: style?.maximumSize?.resolve(states),
fixedSize: style?.fixedSize?.resolve(states),
padding: style?.padding?.resolve(states),
textStyle: style?.textStyle?.resolve(states),
iconSize: style?.iconSize?.resolve(states),
),
child: content,
),
);
}
}