diff --git a/lib/src/widgets/states/empty_state.dart b/lib/src/widgets/states/empty_state.dart new file mode 100644 index 0000000..86fd911 --- /dev/null +++ b/lib/src/widgets/states/empty_state.dart @@ -0,0 +1,78 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mom_kitchen/src/standards/page_standards.dart'; +import 'package:mom_kitchen/src/widgets/base/standard_button.dart'; + +class EmptyState extends StatelessWidget { + final String? title; + final String? message; + final IconData? icon; + final String? emoji; + final String? buttonText; + final VoidCallback? onButtonPressed; + + const EmptyState({ + super.key, + this.title, + this.message, + this.icon, + this.emoji, + this.buttonText, + this.onButtonPressed, + }); + + @override + Widget build(BuildContext context) { + final standards = PageStandards.of(context); + final l10n = standards.l10n; + + return Center( + child: Padding( + padding: standards.scaledPadding(EdgeInsets.all(32)), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (emoji != null) + Text( + emoji!, + style: TextStyle(fontSize: standards.scaledFontSize(64)), + ) + else + Icon( + icon ?? CupertinoIcons.cube_box, + size: standards.scaledFontSize(64), + color: standards.textColor.withOpacity(0.4), + ), + SizedBox(height: standards.scaledHeight(16)), + Text( + title ?? l10n.noData, + style: standards.textStyle.copyWith( + fontSize: standards.fontSize + 4, + fontWeight: FontWeight.w600, + ), + textAlign: TextAlign.center, + ), + if (message != null) ...[ + SizedBox(height: standards.scaledHeight(8)), + Text( + message!, + style: standards.textStyle.copyWith( + color: standards.textColor.withOpacity(0.6), + ), + textAlign: TextAlign.center, + ), + ], + if (buttonText != null && onButtonPressed != null) ...[ + SizedBox(height: standards.scaledHeight(24)), + StandardButton( + text: buttonText!, + onPressed: onButtonPressed, + type: StandardButtonType.primary, + ), + ], + ], + ), + ), + ); + } +} diff --git a/lib/src/widgets/states/error_state.dart b/lib/src/widgets/states/error_state.dart new file mode 100644 index 0000000..3d34214 --- /dev/null +++ b/lib/src/widgets/states/error_state.dart @@ -0,0 +1,52 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mom_kitchen/src/standards/page_standards.dart'; +import 'package:mom_kitchen/src/widgets/base/standard_button.dart'; + +class ErrorState extends StatelessWidget { + final String message; + final VoidCallback? onRetry; + final String? retryText; + + const ErrorState({ + super.key, + required this.message, + this.onRetry, + this.retryText, + }); + + @override + Widget build(BuildContext context) { + final standards = PageStandards.of(context); + final l10n = standards.l10n; + + return Center( + child: Padding( + padding: standards.scaledPadding(EdgeInsets.all(32)), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '⚠️', + style: TextStyle(fontSize: standards.scaledFontSize(64)), + ), + SizedBox(height: standards.scaledHeight(16)), + Text( + message, + style: standards.textStyle, + textAlign: TextAlign.center, + ), + if (onRetry != null) ...[ + SizedBox(height: standards.scaledHeight(24)), + StandardButton( + text: retryText ?? l10n.retry, + onPressed: onRetry, + type: StandardButtonType.outline, + ), + ], + ], + ), + ), + ); + } +}