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: TextButton( onPressed: () => onTap(buttonText: text), style: TextButton.styleFrom( padding: const EdgeInsets.all(20), backgroundColor: buildMainColor(), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0), side: BorderSide(color: Colors.black), ), ), child: Text( text, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w700, color: buildTextColor()), ), ))); } 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; } }