inou/design/flutter/widgets/inou_message.dart

70 lines
1.7 KiB
Dart

// AUTO-GENERATED widget — matches web .error/.info/.success
import 'package:flutter/material.dart';
import '../inou_theme.dart';
enum MessageType { error, info, success }
class InouMessage extends StatelessWidget {
final String message;
final MessageType type;
const InouMessage({
super.key,
required this.message,
this.type = MessageType.info,
});
@override
Widget build(BuildContext context) {
final style = _getStyle();
return Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration(
color: style.background,
border: Border.all(color: style.border),
borderRadius: BorderRadius.circular(InouTheme.radiusMd),
),
child: Text(
message,
style: InouTheme.bodyMedium.copyWith(color: style.foreground),
),
);
}
_MessageStyle _getStyle() {
switch (type) {
case MessageType.error:
return _MessageStyle(
background: InouTheme.dangerLight,
foreground: InouTheme.danger,
border: const Color(0xFFFECACA),
);
case MessageType.info:
return _MessageStyle(
background: InouTheme.accentLight,
foreground: InouTheme.accent,
border: const Color(0xFFFDE68A),
);
case MessageType.success:
return _MessageStyle(
background: InouTheme.successLight,
foreground: InouTheme.success,
border: const Color(0xFFA7F3D0),
);
}
}
}
class _MessageStyle {
final Color background;
final Color foreground;
final Color border;
_MessageStyle({
required this.background,
required this.foreground,
required this.border,
});
}