feat(app): a pipeline's Run and Runs are floating action buttons
This commit is contained in:
@@ -24,8 +24,12 @@ class RunPipelineAction extends StatefulWidget {
|
||||
required this.detail,
|
||||
required this.gateway,
|
||||
this.onRunStarted,
|
||||
this.fab = false,
|
||||
});
|
||||
|
||||
/// A floating action button instead of an inline button.
|
||||
final bool fab;
|
||||
|
||||
final PipelinesController controller;
|
||||
final PipelineDetail detail;
|
||||
final ApiGateway gateway;
|
||||
@@ -165,6 +169,17 @@ class _RunPipelineActionState extends State<RunPipelineAction> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final label = const Text(runPipelineActionLabel);
|
||||
if (widget.fab) {
|
||||
return pipelineFab(
|
||||
context,
|
||||
key: runPipelineActionKey,
|
||||
primary: true,
|
||||
materialIcon: Icons.play_arrow,
|
||||
cupertinoIcon: CupertinoIcons.play_fill,
|
||||
label: runPipelineActionLabel,
|
||||
onPressed: _open,
|
||||
);
|
||||
}
|
||||
if (useCupertinoControls(context)) {
|
||||
return CupertinoButton.filled(
|
||||
key: runPipelineActionKey,
|
||||
@@ -179,3 +194,63 @@ class _RunPipelineActionState extends State<RunPipelineAction> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A floating action for a pipeline: Material's extended FAB, or on Cupertino
|
||||
/// a filled pill with the same icon and word and a soft shadow.
|
||||
Widget pipelineFab(
|
||||
BuildContext context, {
|
||||
required Key key,
|
||||
required bool primary,
|
||||
required IconData materialIcon,
|
||||
required IconData cupertinoIcon,
|
||||
required String label,
|
||||
required VoidCallback? onPressed,
|
||||
}) {
|
||||
if (useCupertinoControls(context)) {
|
||||
final content = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(cupertinoIcon, size: 18),
|
||||
const SizedBox(width: 6),
|
||||
Text(label),
|
||||
],
|
||||
);
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x33000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: primary
|
||||
? CupertinoButton.filled(
|
||||
key: key,
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||
onPressed: onPressed,
|
||||
child: content,
|
||||
)
|
||||
: CupertinoButton.tinted(
|
||||
key: key,
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||
onPressed: onPressed,
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
}
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return FloatingActionButton.extended(
|
||||
key: key,
|
||||
heroTag: key,
|
||||
backgroundColor: primary ? null : scheme.secondaryContainer,
|
||||
foregroundColor: primary ? null : scheme.onSecondaryContainer,
|
||||
onPressed: onPressed,
|
||||
icon: Icon(materialIcon),
|
||||
label: Text(label),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user