2026-02-25 10:52:18 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2026-02-25 18:00:02 +08:00
|
|
|
import '../../../core/theme/design_tokens.dart';
|
|
|
|
|
import '../toast/toast_type.dart';
|
|
|
|
|
import '../toast/toast_type_config.dart' show ToastTypeConfig;
|
2026-02-25 10:52:18 +08:00
|
|
|
|
2026-02-25 18:00:02 +08:00
|
|
|
class AppBanner extends StatelessWidget {
|
2026-02-25 10:52:18 +08:00
|
|
|
final String message;
|
2026-02-25 18:00:02 +08:00
|
|
|
final ToastType type;
|
2026-02-25 10:52:18 +08:00
|
|
|
final bool visible;
|
2026-03-13 14:10:13 +08:00
|
|
|
final String? title;
|
2026-02-25 10:52:18 +08:00
|
|
|
|
2026-02-25 18:00:02 +08:00
|
|
|
const AppBanner({
|
|
|
|
|
super.key,
|
|
|
|
|
required this.message,
|
|
|
|
|
this.type = ToastType.warning,
|
|
|
|
|
this.visible = true,
|
2026-03-13 14:10:13 +08:00
|
|
|
this.title,
|
2026-02-25 18:00:02 +08:00
|
|
|
});
|
2026-02-25 10:52:18 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
if (!visible) return const SizedBox.shrink();
|
|
|
|
|
|
2026-03-27 14:05:03 +08:00
|
|
|
final config = ToastTypeConfig.fromType(context, type);
|
2026-02-25 18:00:02 +08:00
|
|
|
|
2026-02-25 10:52:18 +08:00
|
|
|
return Container(
|
|
|
|
|
width: double.infinity,
|
2026-03-13 14:10:13 +08:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
2026-02-25 10:52:18 +08:00
|
|
|
decoration: BoxDecoration(
|
2026-03-13 14:10:13 +08:00
|
|
|
color: config.surfaceColor,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
border: Border.all(color: config.borderColor),
|
2026-02-25 10:52:18 +08:00
|
|
|
),
|
|
|
|
|
child: Row(
|
2026-03-13 14:10:13 +08:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2026-02-25 10:52:18 +08:00
|
|
|
children: [
|
2026-03-13 14:10:13 +08:00
|
|
|
Container(
|
|
|
|
|
width: 28,
|
|
|
|
|
height: 28,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: config.iconColor.withValues(alpha: 0.12),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.full),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(config.icon, size: 16, color: config.iconColor),
|
|
|
|
|
),
|
2026-02-25 10:52:18 +08:00
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Expanded(
|
2026-03-13 14:10:13 +08:00
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
title ?? config.label,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
color: config.textColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 2),
|
|
|
|
|
Text(
|
|
|
|
|
message,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
height: 1.35,
|
|
|
|
|
color: config.textColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-02-25 10:52:18 +08:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|