77 lines
2.2 KiB
Dart
77 lines
2.2 KiB
Dart
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:satu/shared/app_colors.dart';
|
|
import 'package:satu/shared/shared_styles.dart';
|
|
|
|
/// A button that shows a busy indicator in place of title
|
|
class AmanIconButton extends StatefulWidget {
|
|
const AmanIconButton({
|
|
required this.title,
|
|
required this.onPressed,
|
|
required this.mainColor,
|
|
required this.icon,
|
|
this.busy = false,
|
|
this.enabled = true,
|
|
});
|
|
|
|
final bool busy;
|
|
final String title;
|
|
final Function onPressed;
|
|
final bool? enabled;
|
|
final Color mainColor;
|
|
final IconData icon;
|
|
|
|
@override
|
|
_AmanIconButtonState createState() => _AmanIconButtonState();
|
|
}
|
|
|
|
class _AmanIconButtonState extends State<AmanIconButton> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
child: InkWell(
|
|
borderRadius: BorderRadius.circular(6),
|
|
onTap: () {
|
|
if (!widget.busy) {
|
|
widget.onPressed();
|
|
}
|
|
},
|
|
child: Container(
|
|
//height: 75,
|
|
width: 120,
|
|
alignment: Alignment.center,
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(6),
|
|
border: Border.all(width: 1.0, color: widget.mainColor)),
|
|
child: Column(
|
|
children: <Widget>[
|
|
(!widget.busy
|
|
? Icon(
|
|
widget.icon,
|
|
color: widget.mainColor,
|
|
size: 36,
|
|
)
|
|
: CircularProgressIndicator(
|
|
strokeWidth: 3,
|
|
valueColor:
|
|
AlwaysStoppedAnimation<Color>(widget.mainColor))),
|
|
AutoSizeText(
|
|
widget.title,
|
|
overflow: TextOverflow.fade,
|
|
maxLines: 2,
|
|
style: TextStyle(
|
|
color: widget.mainColor,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w800,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|