mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 16:41:19 +00:00
80 lines
2.3 KiB
Dart
80 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:tablet_app/Models/tabletContext.dart';
|
|
import 'package:tablet_app/app_context.dart';
|
|
import 'package:tablet_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 = kTestSecondColor,
|
|
this.textColor = Colors.white,
|
|
this.fontSize,
|
|
this.vertical,
|
|
this.horizontal
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final appContext = Provider.of<AppContext>(context);
|
|
TabletAppContext tabletAppContext = appContext.getContext();
|
|
|
|
//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(tabletAppContext.configuration?.roundedValue?.toDouble() ?? 20.0),
|
|
)
|
|
)
|
|
),
|
|
|
|
onPressed: () => {
|
|
press!()
|
|
},
|
|
child: getValue(icon)
|
|
);
|
|
}
|
|
|
|
getValue(icon) {
|
|
if (icon != null) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Center(
|
|
child: Text(
|
|
text!,
|
|
style: new TextStyle(color: textColor, fontSize: fontSize, fontWeight: FontWeight.w400),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 10
|
|
),
|
|
Icon(
|
|
icon,
|
|
color: textColor,
|
|
size: fontSize! + 8,
|
|
)
|
|
],
|
|
);
|
|
} else {
|
|
return Text(
|
|
text!,
|
|
style: new TextStyle(color: textColor, fontSize: fontSize, fontWeight: FontWeight.w400),
|
|
);
|
|
}
|
|
}
|
|
} |