myhomie_app/lib/Components/Buttons/rounded_button.dart

47 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:myhomie_app/constants.dart';
class RoundedButton extends StatelessWidget {
final String? text;
final Function? press;
final IconData? icon;
final Color color, textColor;
final double? fontSize;
final double? vertical;
final double? horizontal;
const RoundedButton({
Key? key,
this.text,
this.press,
this.icon,
this.color = kBodyTextColor, // TODO
this.textColor = Colors.white,
this.fontSize,
this.vertical,
this.horizontal
}) : super(key: key);
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.resolveWith((states) => EdgeInsets.symmetric(vertical: this.vertical != null ? this.vertical! : 25, horizontal: this.horizontal != null ? this.horizontal! : (icon == null ? 85 : 30))),
backgroundColor: MaterialStateColor.resolveWith((states) => color),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
)
)
),
onPressed: () => {
press!()
},
child: Text(
text!,
style: new TextStyle(color: textColor, fontSize: fontSize, fontWeight: FontWeight.w400),
),
);
}
}