Merge pull request #11 from TheLidlMan/fix/content-rating-display
Fix content rating display to remove country prefixes
This commit is contained in:
@@ -19,6 +19,7 @@ import '../mixins/item_updatable.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../utils/video_player_navigation.dart';
|
||||
import '../utils/content_rating_formatter.dart';
|
||||
import 'auth_screen.dart';
|
||||
|
||||
class DiscoverScreen extends StatefulWidget {
|
||||
@@ -798,7 +799,7 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
if (heroItem.rating != null)
|
||||
'★ ${heroItem.rating!.toStringAsFixed(1)}',
|
||||
if (heroItem.contentRating != null)
|
||||
heroItem.contentRating!,
|
||||
formatContentRating(heroItem.contentRating!),
|
||||
if (heroItem.year != null)
|
||||
heroItem.year.toString(),
|
||||
].join(' • '),
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../widgets/media_context_menu.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../utils/video_player_navigation.dart';
|
||||
import '../utils/content_rating_formatter.dart';
|
||||
import '../theme/theme_helper.dart';
|
||||
import 'season_detail_screen.dart';
|
||||
|
||||
@@ -461,7 +462,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> {
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
metadata.contentRating!,
|
||||
formatContentRating(metadata.contentRating!),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
@@ -715,7 +716,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> {
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
if (metadata.contentRating != null) ...[
|
||||
_buildInfoRow('Rating', metadata.contentRating!),
|
||||
_buildInfoRow('Rating', formatContentRating(metadata.contentRating!)),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user