relatica/lib/controls/status_and_refresh_button.dart

47 wiersze
1.3 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class StatusAndRefreshButton extends StatelessWidget {
final ValueListenable<bool> valueListenable;
final Future<void> Function() refreshFunction;
final Color? busyColor;
final Color? buttonColor;
const StatusAndRefreshButton({
super.key,
required this.valueListenable,
required this.refreshFunction,
this.buttonColor,
this.busyColor,
});
@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: valueListenable,
builder: (context2, executing, _) {
if (executing) {
final theme = Theme.of(context);
final size = theme.appBarTheme.actionsIconTheme?.size ??
theme.iconTheme.size ??
24;
return Center(
child: SizedBox(
width: size,
height: size,
child: CircularProgressIndicator(
color: busyColor,
),
),
);
}
return IconButton(
onPressed: refreshFunction,
icon: Icon(
Icons.refresh,
color: buttonColor,
));
});
}
}