stack_wallet/lib/widgets/rounded_container.dart

78 lines
2.2 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
2022-08-26 08:11:35 +00:00
class RoundedContainer extends StatelessWidget {
const RoundedContainer({
Key? key,
this.child,
required this.color,
this.padding = const EdgeInsets.all(12),
2022-09-16 23:54:46 +00:00
this.radiusMultiplier = 1.0,
2022-09-18 17:27:38 +00:00
this.width,
this.height,
this.borderColor,
this.hoverColor,
2023-02-02 21:37:59 +00:00
this.boxShadow,
this.onPressed,
2022-08-26 08:11:35 +00:00
}) : super(key: key);
final Widget? child;
final Color color;
final EdgeInsets padding;
2022-09-16 23:54:46 +00:00
final double radiusMultiplier;
2022-09-18 17:27:38 +00:00
final double? width;
final double? height;
final Color? borderColor;
final Color? hoverColor;
2023-02-02 21:37:59 +00:00
final List<BoxShadow>? boxShadow;
final VoidCallback? onPressed;
2022-08-26 08:11:35 +00:00
@override
Widget build(BuildContext context) {
return ConditionalParent(
condition: onPressed != null,
builder: (child) => RawMaterialButton(
2023-04-02 19:48:14 +00:00
fillColor: color,
hoverColor: hoverColor,
2023-04-02 19:48:14 +00:00
elevation: 0,
highlightElevation: 0,
disabledElevation: 0,
hoverElevation: 0,
focusElevation: 0,
padding: const EdgeInsets.all(0),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius * radiusMultiplier,
),
2023-05-15 21:33:32 +00:00
side: borderColor == null
? BorderSide.none
: BorderSide(
color: borderColor!,
width: 1.2,
),
2022-08-26 08:11:35 +00:00
),
onPressed: onPressed,
2022-08-26 08:11:35 +00:00
child: child,
),
child: Container(
width: width,
height: height,
decoration: BoxDecoration(
2023-04-02 19:48:14 +00:00
color: onPressed != null ? Colors.transparent : color,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius * radiusMultiplier,
),
border: borderColor == null ? null : Border.all(color: borderColor!),
boxShadow: boxShadow,
),
child: Padding(
padding: padding,
child: child,
),
),
2022-08-26 08:11:35 +00:00
);
}
}