aman-kassa-flutter/lib/widgets/components/calculator/calculator-button.dart

60 lines
1.8 KiB
Dart

import 'package:aman_kassa_flutter/shared/app_colors.dart';
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart';
import 'package:flutter/material.dart';
typedef void CalculatorButtonTapCallback({required String buttonText});
List operationsBlue = [Calculations.ADD,Calculations.MULTIPLY,Calculations.EQUAL,Calculations.ERASE];
List operationsRed = [Calculations.CLEAR];
class CalculatorButton extends StatelessWidget {
CalculatorButton({required this.text, required this.onTap});
final String text;
final CalculatorButtonTapCallback onTap;
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
// decoration: BoxDecoration(
// border: Border.all(
// color: Colors.black,
// width: 1.2,
// ),
// ),
child: FlatButton(
onPressed: () => onTap(buttonText: text),
child: Text(
text,
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w700, color: buildTextColor()),
),
padding: const EdgeInsets.all(20),
highlightColor: Colors.blueGrey[100],
splashColor: Colors.blueAccent[100],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
side: BorderSide(color: Colors.black)
),
color: buildMainColor(),
)));
}
buildMainColor() {
if(operationsBlue.indexOf(text)>-1){
return primaryColor;
} else if(operationsRed.indexOf(text)>-1){
return redColor;
}
return fillColor;
}
buildTextColor() {
if(operationsBlue.indexOf(text)>-1){
return whiteColor;
} else if(operationsRed.indexOf(text)>-1){
return whiteColor;
}
return Colors.black;
}
}