82 lines
2.4 KiB
Dart
82 lines
2.4 KiB
Dart
import 'package:didvan/config/theme_data.dart';
|
|
import 'package:didvan/views/widgets/didvan/button.dart';
|
|
import 'package:didvan/views/widgets/didvan/text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
class EmptyState extends StatelessWidget {
|
|
final String asset;
|
|
final String title;
|
|
final String? subtitle;
|
|
final String? buttonTitle;
|
|
final VoidCallback? action;
|
|
final Color? titleColor;
|
|
final double? height;
|
|
|
|
const EmptyState({
|
|
Key? key,
|
|
required this.asset,
|
|
required this.title,
|
|
this.action,
|
|
this.buttonTitle,
|
|
this.subtitle,
|
|
this.titleColor,
|
|
this.height,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isSvg = asset.toLowerCase().endsWith('.svg');
|
|
|
|
return Column(
|
|
mainAxisAlignment:
|
|
subtitle != null ? MainAxisAlignment.start : MainAxisAlignment.center,
|
|
crossAxisAlignment: subtitle != null
|
|
? CrossAxisAlignment.start
|
|
: CrossAxisAlignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: height ?? 300,
|
|
child: isSvg
|
|
? SvgPicture.asset(asset, fit: BoxFit.contain)
|
|
: Image.asset(asset,
|
|
fit: BoxFit.fitWidth, height: height, width: double.infinity),
|
|
),
|
|
const SizedBox(height: 20),
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 20, left: 20),
|
|
child: DidvanText(
|
|
title,
|
|
style: Theme.of(context).textTheme.displaySmall,
|
|
color: titleColor ?? Theme.of(context).colorScheme.caption,
|
|
textAlign: TextAlign.start,
|
|
),
|
|
),
|
|
if (subtitle != null) const SizedBox(height: 8),
|
|
if (subtitle != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 20, left: 20),
|
|
child: DidvanText(
|
|
subtitle!,
|
|
color: Theme.of(context).colorScheme.caption,
|
|
),
|
|
),
|
|
if (action != null) const SizedBox(height: 16),
|
|
if (action != null)
|
|
Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(25.0),
|
|
child: DidvanButton(
|
|
height: 50,
|
|
onPressed: action,
|
|
title: buttonTitle,
|
|
width: double.infinity,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|