stack_wallet/lib/widgets/rounded_container.dart

88 lines
2.3 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:flutter/material.dart';
import '../utilities/constants.dart';
import 'conditional_parent.dart';
2022-08-26 08:11:35 +00:00
class RoundedContainer extends StatelessWidget {
const RoundedContainer({
2024-05-27 23:56:22 +00:00
super.key,
2022-08-26 08:11:35 +00:00
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,
2024-05-27 23:56:22 +00:00
});
2022-08-26 08:11:35 +00:00
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
);
}
}