mirror of
https://github.com/foss42/apidash.git
synced 2025-05-21 00:09:55 +08:00
Migrate to ADFilledButton & ADTextButton
This commit is contained in:
@ -10,6 +10,10 @@ enum WindowWidth {
|
||||
final double value;
|
||||
}
|
||||
|
||||
const kButtonIconSizeSmall = 14.0;
|
||||
const kButtonIconSizeMedium = 16.0;
|
||||
const kButtonIconSizeLarge = 18.0;
|
||||
|
||||
const kBorderRadius4 = BorderRadius.all(Radius.circular(4));
|
||||
const kBorderRadius6 = BorderRadius.all(Radius.circular(6));
|
||||
const kBorderRadius8 = BorderRadius.all(Radius.circular(8));
|
||||
|
@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../tokens/tokens.dart';
|
||||
|
||||
class ADFilledButton extends StatelessWidget {
|
||||
const ADFilledButton({
|
||||
super.key,
|
||||
this.icon,
|
||||
this.iconSize,
|
||||
this.label,
|
||||
this.items,
|
||||
this.isTonal = false,
|
||||
this.visualDensity,
|
||||
this.onPressed,
|
||||
});
|
||||
|
||||
final IconData? icon;
|
||||
final double? iconSize;
|
||||
final String? label;
|
||||
final List<Widget>? items;
|
||||
final bool isTonal;
|
||||
final VisualDensity? visualDensity;
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget child = Text(
|
||||
label ?? "",
|
||||
style: kTextStyleButton,
|
||||
);
|
||||
if (items != null) {
|
||||
child = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: items ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
return (icon != null && items == null)
|
||||
? (isTonal
|
||||
? FilledButton.tonalIcon(
|
||||
icon: Icon(
|
||||
icon,
|
||||
size: iconSize ?? kButtonIconSizeMedium,
|
||||
),
|
||||
label: child,
|
||||
onPressed: onPressed,
|
||||
)
|
||||
: FilledButton.icon(
|
||||
icon: Icon(
|
||||
icon,
|
||||
size: iconSize ?? kButtonIconSizeMedium,
|
||||
),
|
||||
label: child,
|
||||
onPressed: onPressed,
|
||||
))
|
||||
: (isTonal
|
||||
? FilledButton.tonal(
|
||||
onPressed: onPressed,
|
||||
child: child,
|
||||
)
|
||||
: FilledButton(
|
||||
onPressed: onPressed,
|
||||
child: child,
|
||||
));
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../tokens/tokens.dart';
|
||||
|
||||
class ADIconButton extends StatelessWidget {
|
||||
const ADIconButton({
|
||||
@ -24,7 +25,7 @@ class ADIconButton extends StatelessWidget {
|
||||
tooltip: tooltip,
|
||||
icon: Icon(
|
||||
icon,
|
||||
size: iconSize ?? 16,
|
||||
size: iconSize ?? kButtonIconSizeMedium,
|
||||
),
|
||||
color: color,
|
||||
visualDensity: visualDensity,
|
||||
|
38
packages/apidash_design_system/lib/widgets/button_text.dart
Normal file
38
packages/apidash_design_system/lib/widgets/button_text.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../tokens/tokens.dart';
|
||||
|
||||
class ADTextButton extends StatelessWidget {
|
||||
const ADTextButton({
|
||||
super.key,
|
||||
this.icon,
|
||||
this.iconSize,
|
||||
this.label,
|
||||
this.onPressed,
|
||||
});
|
||||
|
||||
final IconData? icon;
|
||||
final double? iconSize;
|
||||
final String? label;
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var child = Text(
|
||||
label ?? "",
|
||||
style: kTextStyleButton,
|
||||
);
|
||||
return icon != null
|
||||
? TextButton.icon(
|
||||
icon: Icon(
|
||||
icon,
|
||||
size: iconSize ?? kButtonIconSizeMedium,
|
||||
),
|
||||
label: child,
|
||||
onPressed: onPressed,
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: onPressed,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
export 'button_filled.dart';
|
||||
export 'button_icon.dart';
|
||||
export 'button_text.dart';
|
||||
export 'checkbox.dart';
|
||||
export 'dropdown.dart';
|
||||
export 'popup_menu.dart';
|
||||
|
Reference in New Issue
Block a user