Jisho-Study-Tool/lib/components/search/search_results_body/parts/wanikani_badge.dart

29 lines
597 B
Dart
Raw Normal View History

2021-04-11 01:48:43 +02:00
import 'package:flutter/material.dart';
import './badge.dart';
2021-04-11 01:48:43 +02:00
class WKBadge extends StatelessWidget {
2021-12-04 05:22:58 +01:00
final String level;
2021-04-11 01:48:43 +02:00
2021-12-04 05:22:58 +01:00
const WKBadge({
required this.level,
Key? key,
}) : super(key: key);
2021-04-11 01:48:43 +02:00
String _extractWkLevel(String wkRaw) {
2021-12-04 05:22:58 +01:00
return wkRaw.isNotEmpty ? 'W${wkRaw.substring(8)}' : '';
2021-04-11 01:48:43 +02:00
}
@override
Widget build(BuildContext context) {
return Badge(
2021-12-04 05:22:58 +01:00
color: level.isNotEmpty ? Colors.red : Colors.transparent,
2021-12-01 23:09:53 +01:00
child: Text(
2021-12-04 05:22:58 +01:00
_extractWkLevel(level),
style: const TextStyle(
2021-04-11 01:48:43 +02:00
color: Colors.white,
),
),
);
}
2021-12-04 05:22:58 +01:00
}