mirror of
https://github.com/krawieck/lemmur/
synced 2024-12-25 23:53:27 +01:00
cb47bc5f72
* Add initial rewrite * Progress * Create AsyncStore * Fix typo * Remove outdated lint ignores * Simplify comment layout * Reorganize pubspec deps * Small fixes * Move all comment state to store * Document async store * Move marking as read to AsyncStore * Add network_error l10n todo * Rename comment_more_menu * Hide popup after actions * Observe changes in consumer
46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../hooks/delayed_loading.dart';
|
|
|
|
/// [IconButton], usually at the bottom of some tile, that performs an async
|
|
/// action that uses [DelayedLoading], has reduced size to be more compact,
|
|
/// and has built in spinner
|
|
class TileAction extends StatelessWidget {
|
|
final IconData icon;
|
|
final VoidCallback onPressed;
|
|
final String tooltip;
|
|
final DelayedLoading? delayedLoading;
|
|
final bool loading;
|
|
final Color? iconColor;
|
|
|
|
const TileAction({
|
|
Key? key,
|
|
this.delayedLoading,
|
|
this.iconColor,
|
|
required this.icon,
|
|
required this.onPressed,
|
|
required this.tooltip,
|
|
this.loading = false,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) => IconButton(
|
|
constraints: BoxConstraints.tight(const Size(36, 30)),
|
|
padding: EdgeInsets.zero,
|
|
splashRadius: 25,
|
|
iconSize: 25,
|
|
tooltip: tooltip,
|
|
onPressed: delayedLoading?.pending ?? loading ? () {} : onPressed,
|
|
icon: delayedLoading?.loading ?? loading
|
|
? SizedBox.fromSize(
|
|
size: const Size.square(22),
|
|
child: const CircularProgressIndicator(),
|
|
)
|
|
: Icon(
|
|
icon,
|
|
color: iconColor ??
|
|
Theme.of(context).iconTheme.color?.withAlpha(190),
|
|
),
|
|
);
|
|
}
|