- Add formatContentRating utility function to strip country codes (gb/, us/, de/, etc.) - Apply formatter in discover_screen.dart hero section - Apply formatter in media_detail_screen.dart (badge and info row) - Ratings now display as '12', 'PG', 'PG-13' instead of 'gb/12', 'us/PG-13' - Fixes #10
18 lines
584 B
Dart
18 lines
584 B
Dart
/// Utility function to format content ratings by removing country prefixes
|
|
String formatContentRating(String? contentRating) {
|
|
if (contentRating == null || contentRating.isEmpty) {
|
|
return '';
|
|
}
|
|
|
|
// Remove common country prefixes like "gb/", "us/", "de/", etc.
|
|
// The pattern matches: lowercase letters followed by a forward slash
|
|
final regex = RegExp(r'^[a-z]{2,3}/(.+)$', caseSensitive: false);
|
|
final match = regex.firstMatch(contentRating);
|
|
|
|
if (match != null && match.groupCount >= 1) {
|
|
return match.group(1) ?? contentRating;
|
|
}
|
|
|
|
return contentRating;
|
|
}
|