myhomie_app/lib/Components/custom_dialog.dart

138 lines
4.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:myhomie_app/Components/Buttons/rounded_button.dart';
import 'package:myhomie_app/constants.dart';
class Consts {
Consts._();
static const double padding = 16.0;
static const double avatarRadius = 70.0;
}
class CustomDialog extends StatelessWidget {
String title, description, buttonText;
String? iconSvg;
Function onPress;
CustomDialog({
required this.title,
required this.description,
required this.buttonText,
this.iconSvg,
required this.onPress
});
@override
Widget build(BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(Consts.padding),
),
elevation: 0.0,
backgroundColor: Colors.transparent,
child: dialogContent(context),
);
}
dialogContent(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: Consts.avatarRadius + Consts.padding,
bottom: Consts.padding,
left: Consts.padding,
right: Consts.padding,
),
margin: EdgeInsets.only(top: Consts.avatarRadius),
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(Consts.padding),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 10.0,
offset: const Offset(0.0, 10.0),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min, // To make the card compact
children: <Widget>[
SizedBox(height: 16.0),
Text(
description,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
),
),
SizedBox(height: 22.0),
Align(
alignment: Alignment.bottomRight,
child: RoundedButton(
press: () {
onPress();
Navigator.of(context).pop(); // To close the dialog
},
text: buttonText,
),
),
],
),
),
Positioned(
left: Consts.padding,
right: Consts.padding,
child: Container(
width: size.width *0.18,
height: size.height *0.18,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color(0xFFDD79C2),
Color(0xFFB65FBE),
Color(0xFF9146BA),
Color(0xFF7633B8),
Color(0xFF6528B6),
Color(0xFF6025B6)
],
),
//borderRadius: BorderRadius.circular(10.0),
),
child: Center(
child: Stack(
children: [
if (iconSvg != null)
SvgPicture.asset(
iconSvg!,
height: 65,
color: Colors.white,
)
else
Container(
width: size.width*0.3,
height: size.width*0.23,
child: Center(
child: Text(
title,
style: kHeadingTextStyle,
textAlign: TextAlign.center,
overflow: TextOverflow.clip
),
),
)
]))
),
),
],
);
}
}