mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-19 16:23:37 +00:00
46 lines
1.3 KiB
Dart
46 lines
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,
|
|
));
|
|
});
|
|
}
|
|
}
|