fix(apps): consolidate FormzInput validators and fix login screen
- Move FormzInput validators to core/form_inputs/form_inputs.dart - Fix login_screen.dart syntax error (missing 'class' keyword) - Remove unused _isLoading field - Fix unnecessary const keywords - Update login_cubit and register_cubit imports - Remove duplicate FormzInput definitions from register_cubit - Add Toast and Banner UI feedback system - Remove legacy login/register screens (login_code, login_email, login_password, register_step2) - Remove unused warning_banner widget - Update tests for new error messages and DI setup
This commit is contained in:
@@ -4,7 +4,6 @@ import '../../core/theme/design_tokens.dart';
|
||||
class AppButton extends StatelessWidget {
|
||||
final String text;
|
||||
final VoidCallback? onPressed;
|
||||
final bool isPrimary;
|
||||
final bool isOutlined;
|
||||
final double height;
|
||||
final bool isLoading;
|
||||
@@ -13,7 +12,6 @@ class AppButton extends StatelessWidget {
|
||||
super.key,
|
||||
required this.text,
|
||||
this.onPressed,
|
||||
this.isPrimary = true,
|
||||
this.isOutlined = false,
|
||||
this.height = 44,
|
||||
this.isLoading = false,
|
||||
|
||||
+16
-13
@@ -1,38 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../core/theme/design_tokens.dart';
|
||||
import '../../../core/theme/design_tokens.dart';
|
||||
import '../toast/toast_type.dart';
|
||||
import '../toast/toast_type_config.dart' show ToastTypeConfig;
|
||||
|
||||
class WarningBanner extends StatelessWidget {
|
||||
class AppBanner extends StatelessWidget {
|
||||
final String message;
|
||||
final ToastType type;
|
||||
final bool visible;
|
||||
|
||||
const WarningBanner({super.key, required this.message, this.visible = true});
|
||||
const AppBanner({
|
||||
super.key,
|
||||
required this.message,
|
||||
this.type = ToastType.warning,
|
||||
this.visible = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!visible) return const SizedBox.shrink();
|
||||
|
||||
final config = ToastTypeConfig.fromType(type);
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.warningBackground,
|
||||
color: config.backgroundColor,
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: 16,
|
||||
color: AppColors.warningText,
|
||||
),
|
||||
Icon(config.icon, size: 16, color: config.iconColor),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
message,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.warningText,
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: config.textColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -0,0 +1,3 @@
|
||||
export 'toast.dart';
|
||||
export 'toast_type.dart';
|
||||
export 'toast_type_config.dart';
|
||||
@@ -0,0 +1,128 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/theme/design_tokens.dart';
|
||||
import 'toast_type.dart';
|
||||
import 'toast_type_config.dart';
|
||||
|
||||
class Toast {
|
||||
static void show(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
ToastType type = ToastType.info,
|
||||
Duration duration = const Duration(seconds: 2),
|
||||
}) {
|
||||
final overlay = Overlay.of(context);
|
||||
late OverlayEntry entry;
|
||||
|
||||
entry = OverlayEntry(
|
||||
builder: (context) => _ToastWidget(
|
||||
message: message,
|
||||
type: type,
|
||||
duration: duration,
|
||||
onDismiss: () => entry.remove(),
|
||||
),
|
||||
);
|
||||
|
||||
overlay.insert(entry);
|
||||
}
|
||||
}
|
||||
|
||||
class _ToastWidget extends StatefulWidget {
|
||||
final String message;
|
||||
final ToastType type;
|
||||
final Duration duration;
|
||||
final VoidCallback onDismiss;
|
||||
|
||||
const _ToastWidget({
|
||||
required this.message,
|
||||
required this.type,
|
||||
required this.duration,
|
||||
required this.onDismiss,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_ToastWidget> createState() => _ToastWidgetState();
|
||||
}
|
||||
|
||||
class _ToastWidgetState extends State<_ToastWidget>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<Offset> _slideAnimation;
|
||||
late Animation<double> _fadeAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
_slideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0, -1),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeOut));
|
||||
|
||||
_fadeAnimation = Tween<double>(begin: 0, end: 1).animate(_controller);
|
||||
|
||||
_controller.forward();
|
||||
|
||||
Future.delayed(widget.duration, _dismiss);
|
||||
}
|
||||
|
||||
void _dismiss() {
|
||||
if (!mounted) return;
|
||||
_controller.reverse().then((_) => widget.onDismiss());
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final config = ToastTypeConfig.fromType(widget.type);
|
||||
|
||||
return Positioned(
|
||||
top: MediaQuery.of(context).padding.top + 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
child: SlideTransition(
|
||||
position: _slideAnimation,
|
||||
child: FadeTransition(
|
||||
opacity: _fadeAnimation,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: config.backgroundColor,
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.1),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(config.icon, size: 20, color: config.iconColor),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.message,
|
||||
style: TextStyle(fontSize: 14, color: config.textColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
enum ToastType { info, success, warning, error }
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'toast_type.dart';
|
||||
|
||||
class ToastTypeConfig {
|
||||
final Color backgroundColor;
|
||||
final Color iconColor;
|
||||
final Color textColor;
|
||||
final IconData icon;
|
||||
|
||||
const ToastTypeConfig({
|
||||
required this.backgroundColor,
|
||||
required this.iconColor,
|
||||
required this.textColor,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
static ToastTypeConfig fromType(ToastType type) => switch (type) {
|
||||
ToastType.success => const ToastTypeConfig(
|
||||
backgroundColor: Color(0xFFECFDF5),
|
||||
iconColor: Color(0xFF10B981),
|
||||
textColor: Color(0xFF065F46),
|
||||
icon: Icons.check_circle_outline,
|
||||
),
|
||||
ToastType.warning => const ToastTypeConfig(
|
||||
backgroundColor: Color(0xFFFFFBEB),
|
||||
iconColor: Color(0xFFF59E0B),
|
||||
textColor: Color(0xFF92400E),
|
||||
icon: Icons.warning_amber_rounded,
|
||||
),
|
||||
ToastType.error => const ToastTypeConfig(
|
||||
backgroundColor: Color(0xFFFEF2F2),
|
||||
iconColor: Color(0xFFEF4444),
|
||||
textColor: Color(0xFF991B1B),
|
||||
icon: Icons.error_outline,
|
||||
),
|
||||
ToastType.info => const ToastTypeConfig(
|
||||
backgroundColor: Color(0xFFEFF6FF),
|
||||
iconColor: Color(0xFF3B82F6),
|
||||
textColor: Color(0xFF1E40AF),
|
||||
icon: Icons.info_outline,
|
||||
),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user