show method
Implementation
void show(BuildContext context) {
double screenHeight = MediaQuery.of(context).size.height - (TodaySpacing.tdsSpace6.spacing * 2);
if (style == TodayModalStyle.card) {
screenHeight -= ((showHeader ? 62 : 0) + (showFooter ? 68 : 0));
} else {
screenHeight -= (showFooter ? 60 : 0);
}
showDialog(
context: context,
builder: (context) => Center(
child: Material(
color: Colors.transparent,
child: Container(
width: width,
height: height,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: TodayRadius.tdsBorderRadius5.radius,
boxShadow: const [
BoxShadow(
color: Color.fromRGBO(39, 39, 42, 0.2),
blurRadius: 32,
offset: Offset(0, 8),
spreadRadius: 0,
)
],
),
child: IntrinsicHeight(
child: Container(
width: width,
height: height,
decoration: BoxDecoration(
gradient: style != TodayModalStyle.alert
? null
: LinearGradient(
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
colors: type == TodayModalType.success
? const [
Color(0x0F22C55E),
Color(0x00F8F8F8),
]
: const [
Color(0x0FEF4444),
Color(0x00F8F8F8),
],
stops: const [0.0, 0.6674],
),
borderRadius: TodayRadius.tdsBorderRadius5.radius,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (style == TodayModalStyle.card) ...[
if (showHeader) ...[
Container(
height: 62,
padding: EdgeInsets.all(
TodaySpacing.tdsSpace5.spacing,
),
decoration: !hideHeaderLine
? const BoxDecoration(
border: Border(
bottom: BorderSide(
style: BorderStyle.solid,
width: 1,
color: Color.fromRGBO(39, 39, 42, 0.06),
),
),
)
: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
if (titleIcon != null) ...[
Transform.translate(offset: const Offset(0, 2), child: titleIcon!,),
SizedBox(width: TodaySpacing.tdsSpace2.spacing)
],
if (title != null) ...[
TodayText(
title!,
style: TodayTextStyle.tdsFontMediumHeavy,
textAlign: TextAlign.center,
rawColor: const Color.fromRGBO(39, 39, 42, 1),
),
],
],
),
if (showClose) ...[
InkWell(
onTap: () => Navigator.of(context).pop(),
canRequestFocus: false,
child: const CircleAvatar(
radius: 10,
backgroundColor: Color.fromRGBO(239, 239, 240, 1),
child: TodayIcon(
TodaySvgIcon.close,
color: Color.fromRGBO(161, 161, 170, 1),
scale: 0.8,
),
),
),
],
],
),
),
],
Container(
constraints: BoxConstraints(
maxHeight: screenHeight,
minWidth: width ?? 0,
),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Padding(
padding: !hideHeaderLine
? EdgeInsets.all(
TodaySpacing.tdsSpace5.spacing,
)
: EdgeInsets.fromLTRB(
TodaySpacing.tdsSpace5.spacing,
TodaySpacing.tdsSpace0.spacing,
TodaySpacing.tdsSpace5.spacing,
TodaySpacing.tdsSpace5.spacing,
),
child: content,
),
),
),
if (showFooter) ...[
Container(
padding: EdgeInsets.all(
TodaySpacing.tdsSpace4.spacing,
),
decoration: const BoxDecoration(
border: Border(
top: BorderSide(
style: BorderStyle.solid,
width: 1,
color: Color.fromRGBO(39, 39, 42, 0.06),
),
),
),
child: Row(
mainAxisAlignment: footerAlignment,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (secondaryAction != null) ...[
secondaryAction!,
],
SizedBox(
width: TodaySpacing.tdsSpace2.spacing,
),
if (primaryAction != null) ...[
primaryAction!,
],
],
),
),
],
] else ...[
Container(
padding: EdgeInsets.only(
left: TodaySpacing.tdsSpace6.spacing,
right: TodaySpacing.tdsSpace6.spacing,
bottom: TodaySpacing.tdsSpace6.spacing,
top: TodaySpacing.tdsSpace7.spacing,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (type == TodayModalType.success) ...[
const TodayIcon(
TodaySvgIcon.statusSuccess,
scale: 36 / 20,
),
] else ...[
const TodayIcon(
TodaySvgIcon.statusErrorAlt,
scale: 36 / 20,
),
],
SizedBox(
height: TodaySpacing.tdsSpace3.spacing,
),
if (title != null) ...[
TodayText(
title!,
style: TodayTextStyle.tdsFontLargeHeavy,
rawColor: const Color.fromRGBO(39, 39, 42, 1),
),
],
if (description != null) ...[
TodayText(
description!,
textAlign: TextAlign.center,
rawColor: const Color.fromRGBO(113, 113, 122, 1),
),
],
],
),
),
],
),
),
if (showFooter) ...[
Container(
padding: EdgeInsets.only(
left: TodaySpacing.tdsSpace6.spacing,
right: TodaySpacing.tdsSpace6.spacing,
bottom: TodaySpacing.tdsSpace6.spacing,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (secondaryAction != null) ...[
Expanded(
flex: 1,
child: secondaryAction!,
),
],
SizedBox(
width: TodaySpacing.tdsSpace3.spacing,
),
if (primaryAction != null) ...[
Expanded(
flex: 1,
child: primaryAction!,
),
],
],
),
),
],
],
],
),
),
),
),
),
),
).then((value) {
if (onClose != null) {
onClose!();
}
});
}