Skip to content

Commit

Permalink
Add podcast website link to podcast details menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
amugofjava committed Apr 6, 2024
1 parent 2167ade commit 5cd9c59
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/entities/podcast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class Podcast {
'copyright': copyright ?? '',
'description': description ?? '',
'url': url,
'link': link ?? '',
'imageUrl': imageUrl ?? '',
'thumbImageUrl': thumbImageUrl ?? '',
'subscribedDate': subscribedDate?.millisecondsSinceEpoch.toString() ?? '',
Expand Down
10 changes: 10 additions & 0 deletions lib/l10n/L.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,16 @@ class L {
locale: localeName,
);
}

String get open_show_website_label {
return message('open_show_website_label') ??
Intl.message(
'Open show website',
name: 'open_show_website_label',
desc: 'Open show website in browser',
locale: localeName,
);
}
}

class AnytimeLocalisationsDelegate extends LocalizationsDelegate<L> {
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -962,5 +962,11 @@
"description": "Episode alphabetical descending",
"type": "text",
"placeholders": {}
},
"open_show_website_label": "Show-Website öffnen",
"@open_show_website_label": {
"description": "Open show website in browser",
"type": "text",
"placeholders": {}
}
}
6 changes: 6 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -962,5 +962,11 @@
"description": "Episode alphabetical descending",
"type": "text",
"placeholders": {}
},
"open_show_website_label": "Open show website",
"@open_show_website_label": {
"description": "Open show website in browser",
"type": "text",
"placeholders": {}
}
}
12 changes: 9 additions & 3 deletions lib/l10n/intl_messages.arb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@@last_modified": "2024-03-26T13:16:56.837934",
"@@last_modified": "2024-04-04T16:54:01.419283",
"app_title": "Anytime Podcast Player",
"@app_title": {
"description": "Full title for the application",
Expand Down Expand Up @@ -866,13 +866,13 @@
"type": "text",
"placeholders": {}
},
"episode_filter_semantic_label": "Filter episodes",
"episode_filter_semantic_label": "Episode filter",
"@episode_filter_semantic_label": {
"description": "Episode filter semantic label",
"type": "text",
"placeholders": {}
},
"episode_sort_semantic_label": "Sort episodes",
"episode_sort_semantic_label": "Episode sort",
"@episode_sort_semantic_label": {
"description": "Episode sort semantic label",
"type": "text",
Expand Down Expand Up @@ -907,5 +907,11 @@
"description": "Episode alphabetical descending",
"type": "text",
"placeholders": {}
},
"open_show_website_label": "Open show website",
"@open_show_website_label": {
"description": "Open show website in browser",
"type": "text",
"placeholders": {}
}
}
1 change: 1 addition & 0 deletions lib/l10n/messages_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class MessageLookup extends MessageLookupByLibrary {
'notes_label': MessageLookupByLibrary.simpleMessage('Notizen'),
'now_playing_queue_label': MessageLookupByLibrary.simpleMessage('Jetzt Spielen'),
'ok_button_label': MessageLookupByLibrary.simpleMessage('OK'),
'open_show_website_label': MessageLookupByLibrary.simpleMessage('Show-Website öffnen'),
'opml_export_button_label': MessageLookupByLibrary.simpleMessage('Export'),
'opml_import_button_label': MessageLookupByLibrary.simpleMessage('Importieren'),
'opml_import_export_label': MessageLookupByLibrary.simpleMessage('OPML Importieren/Export'),
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class MessageLookup extends MessageLookupByLibrary {
'notes_label': MessageLookupByLibrary.simpleMessage('Notes'),
'now_playing_queue_label': MessageLookupByLibrary.simpleMessage('Now Playing'),
'ok_button_label': MessageLookupByLibrary.simpleMessage('OK'),
'open_show_website_label': MessageLookupByLibrary.simpleMessage('Open show website'),
'opml_export_button_label': MessageLookupByLibrary.simpleMessage('Export'),
'opml_import_button_label': MessageLookupByLibrary.simpleMessage('Import'),
'opml_import_export_label': MessageLookupByLibrary.simpleMessage('OPML Import/Export'),
Expand Down
5 changes: 3 additions & 2 deletions lib/l10n/messages_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MessageLookup extends MessageLookupByLibrary {
'episode_filter_no_episodes_title_label': MessageLookupByLibrary.simpleMessage('No Episodes Found'),
'episode_filter_none_label': MessageLookupByLibrary.simpleMessage('None'),
'episode_filter_played_label': MessageLookupByLibrary.simpleMessage('Played'),
'episode_filter_semantic_label': MessageLookupByLibrary.simpleMessage('Filter episodes'),
'episode_filter_semantic_label': MessageLookupByLibrary.simpleMessage('Episode filter'),
'episode_filter_started_label': MessageLookupByLibrary.simpleMessage('Started'),
'episode_filter_unplayed_label': MessageLookupByLibrary.simpleMessage('Unplayed'),
'episode_label': MessageLookupByLibrary.simpleMessage('Episode'),
Expand All @@ -68,7 +68,7 @@ class MessageLookup extends MessageLookupByLibrary {
'episode_sort_earliest_first_label': MessageLookupByLibrary.simpleMessage('Earliest first'),
'episode_sort_latest_first_label': MessageLookupByLibrary.simpleMessage('Latest first'),
'episode_sort_none_label': MessageLookupByLibrary.simpleMessage('Default'),
'episode_sort_semantic_label': MessageLookupByLibrary.simpleMessage('Sort episodes'),
'episode_sort_semantic_label': MessageLookupByLibrary.simpleMessage('Episode sort'),
'error_no_connection': MessageLookupByLibrary.simpleMessage('Unable to play episode. Please check your connection and try again.'),
'error_playback_fail': MessageLookupByLibrary.simpleMessage('An unexpected error occurred during playback. Please check your connection and try again.'),
'fast_forward_button_label': MessageLookupByLibrary.simpleMessage('Fast-forward episode 30 seconds'),
Expand All @@ -93,6 +93,7 @@ class MessageLookup extends MessageLookupByLibrary {
'notes_label': MessageLookupByLibrary.simpleMessage('Notes'),
'now_playing_queue_label': MessageLookupByLibrary.simpleMessage('Now Playing'),
'ok_button_label': MessageLookupByLibrary.simpleMessage('OK'),
'open_show_website_label': MessageLookupByLibrary.simpleMessage('Open show website'),
'opml_export_button_label': MessageLookupByLibrary.simpleMessage('Export'),
'opml_import_button_label': MessageLookupByLibrary.simpleMessage('Import'),
'opml_import_export_label': MessageLookupByLibrary.simpleMessage('OPML Import/Export'),
Expand Down
36 changes: 35 additions & 1 deletion lib/ui/podcast/podcast_context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:anytime/state/bloc_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

/// This class is responsible for rendering the context menu on the podcast details
/// page.
Expand Down Expand Up @@ -74,6 +75,12 @@ class _MaterialPodcastMenu extends StatelessWidget {
enabled: podcast.subscribed,
child: Text(L.of(context)!.mark_episodes_not_played_label),
),
const PopupMenuDivider(),
PopupMenuItem<String>(
value: 'web',
enabled: podcast.link?.isNotEmpty ?? false,
child: Text(L.of(context)!.open_show_website_label),
),
];
},
);
Expand All @@ -83,11 +90,20 @@ class _MaterialPodcastMenu extends StatelessWidget {
void togglePlayed({
required String value,
required PodcastBloc bloc,
}) {
}) async {
if (value == 'ma') {
bloc.podcastEvent(PodcastEvent.markAllPlayed);
} else if (value == 'ua') {
bloc.podcastEvent(PodcastEvent.clearAllPlayed);
} else if (value == 'web') {
final uri = Uri.parse(podcast.link!);

if (!await launchUrl(
uri,
mode: LaunchMode.externalApplication,
)) {
throw Exception('Could not launch $uri');
}
}
}
}
Expand Down Expand Up @@ -130,6 +146,24 @@ class _CupertinoContextMenu extends StatelessWidget {
},
child: Text(L.of(context)!.mark_episodes_not_played_label),
),
CupertinoActionSheetAction(
isDefaultAction: true,
onPressed: () async {
final uri = Uri.parse(podcast.link!);

if (!await launchUrl(
uri,
mode: LaunchMode.externalApplication,
)) {
throw Exception('Could not launch $uri');
}

if (context.mounted) {
Navigator.pop(context, 'Cancel');
}
},
child: Text(L.of(context)!.open_show_website_label),
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,
Expand Down

0 comments on commit 5cd9c59

Please sign in to comment.