Nathan SOULIER fff5617757 First commit
2025-03-24 10:12:56 +01:00

98 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:sampleapp/widgets/components/reflex_box.dart';
import '../../globals.dart';
class ReflexAlert extends StatefulWidget {
final String? title;
final String text;
final IconData icon;
final bool? bigIcon;
final Color? color;
const ReflexAlert(
{Key? key,
required this.text,
required this.icon,
this.color,
bigIcon,
this.title})
: bigIcon = bigIcon ?? false,
super(key: key);
@override
_ReflexAlertState createState() => _ReflexAlertState();
}
class _ReflexAlertState extends State<ReflexAlert> {
_buildColumnAlert() {
return Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
Icon(
widget.icon,
color: Colors.white,
size: 40,
),
const SizedBox(height: 10),
if (widget.title != null)
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
widget.title ?? "",
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
softWrap: true,
)),
Text(
widget.text,
style: const TextStyle(color: Colors.white),
softWrap: true,
),
]);
}
Widget _buildRowAlert() {
return Row(children: [
Flexible(
flex: 0,
child: Icon(
widget.icon,
color: Colors.white,
)),
Flexible(flex: 0, child: const SizedBox(width: 10)),
Expanded(
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
if (widget.title != null)
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
widget.title ?? "",
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
softWrap: true,
)),
Text(
widget.text,
style: const TextStyle(color: Colors.white),
softWrap: true,
),
]))
]);
}
@override
Widget build(BuildContext context) {
return ReflexBox(
color: widget.color ?? Globals.RP_PRIMARY_COLOR,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: widget.bigIcon == true
? _buildColumnAlert()
: _buildRowAlert()));
}
}