chore: prepare yanting monorepo handoff
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/wise_tokens.dart';
|
||||
|
||||
class AppButton extends StatelessWidget {
|
||||
const AppButton({
|
||||
required this.label,
|
||||
required this.onPressed,
|
||||
this.icon,
|
||||
this.kind = AppButtonKind.primary,
|
||||
this.expand = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
final IconData? icon;
|
||||
final AppButtonKind kind;
|
||||
final bool expand;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = switch (kind) {
|
||||
AppButtonKind.primary => (WiseColors.secondary, WiseColors.primary),
|
||||
AppButtonKind.dark => (WiseColors.primary, Colors.white),
|
||||
AppButtonKind.accent => (WiseColors.accent, Colors.white),
|
||||
AppButtonKind.ghost => (WiseColors.surface, WiseColors.primary),
|
||||
};
|
||||
final child = FilledButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: icon == null ? const SizedBox.shrink() : Icon(icon, size: 18),
|
||||
label: Text(label),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: colors.$1,
|
||||
foregroundColor: colors.$2,
|
||||
disabledBackgroundColor: WiseColors.border,
|
||||
disabledForegroundColor: WiseColors.textTertiary,
|
||||
minimumSize: Size(expand ? double.infinity : 0, 44),
|
||||
shape: const StadiumBorder(),
|
||||
),
|
||||
);
|
||||
return expand ? SizedBox(width: double.infinity, child: child) : child;
|
||||
}
|
||||
}
|
||||
|
||||
enum AppButtonKind { primary, dark, accent, ghost }
|
||||
Reference in New Issue
Block a user