Finish KeyToken operations
This commit is contained in:
51
flutter/lib/components/badge_display/badge_display.dart
Normal file
51
flutter/lib/components/badge_display/badge_display.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum BadgeMode { error, warn, info }
|
||||
|
||||
class BadgeDisplay extends StatelessWidget {
|
||||
final String text;
|
||||
final BadgeMode mode;
|
||||
final IconData? icon;
|
||||
|
||||
const BadgeDisplay({
|
||||
Key? key,
|
||||
required this.text,
|
||||
required this.mode,
|
||||
required this.icon,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var col = Colors.grey;
|
||||
var colFG = Colors.black;
|
||||
|
||||
if (mode == BadgeMode.error) col = Colors.red;
|
||||
if (mode == BadgeMode.warn) col = Colors.orange;
|
||||
if (mode == BadgeMode.info) col = Colors.blue;
|
||||
|
||||
if (mode == BadgeMode.error) colFG = Colors.red[900]!;
|
||||
if (mode == BadgeMode.warn) colFG = Colors.black;
|
||||
if (mode == BadgeMode.info) colFG = Colors.black;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(8, 2, 8, 2),
|
||||
decoration: BoxDecoration(
|
||||
color: col[100],
|
||||
border: Border.all(color: col[300]!),
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
if (icon != null) Icon(icon!, color: colFG, size: 16.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: colFG, fontSize: 14.0),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user