aman-kassa-flutter/lib/widgets/fields/aman_icon_button_horizontal...

66 lines
1.9 KiB
Dart

import 'package:aman_kassa_flutter/shared/app_colors.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
/// A button that shows a busy indicator in place of title
class AmanIconButtonHorizontal extends StatefulWidget {
final String title;
final Function onPressed;
final Color activeColor;
final Color inactiveColor;
final bool selected;
final IconData icon;
const AmanIconButtonHorizontal(
{required this.title,
required this.onPressed,
this.activeColor = primaryColor,
this.inactiveColor = Colors.black26,
this.selected = false,
required this.icon});
@override
_AmanIconButtonHorizontalState createState() =>
_AmanIconButtonHorizontalState();
}
class _AmanIconButtonHorizontalState extends State<AmanIconButtonHorizontal> {
@override
Widget build(BuildContext context) {
return GestureDetector(
child: InkWell(
borderRadius: BorderRadius.circular(3),
onTap: () => widget.onPressed(),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Flexible(
fit: FlexFit.loose,
flex: 1,
child: Icon(widget.icon,
color: widget.selected
? widget.activeColor
: widget.inactiveColor),
),
SizedBox(
width: 5,
),
Flexible(
fit: FlexFit.loose,
flex: 5,
child: AutoSizeText(widget.title,
maxLines: 1,
// textAlign: TextAlign.center,
style: TextStyle(
color: widget.selected
? widget.activeColor
: widget.inactiveColor,
fontWeight: FontWeight.w800)),
)
],
),
),
);
}
}