Skip to content

Commit 02d92e9

Browse files
authored
feat: improved patch notes dialog and single podcast refreshing (ubuntu-flutter-community#864)
* feat: improved patch notes dialog and single podcast refreshing * fix: regen mocks
1 parent 3754781 commit 02d92e9

22 files changed

+310
-523
lines changed

lib/app/app_model.dart

+14-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ class AppModel extends SafeChangeNotifier {
1616
.instance.platformDispatcher.locale.countryCode
1717
?.toLowerCase(),
1818
_gitHub = gitHub,
19-
_allowManualUpdates = allowManualUpdates;
19+
_allowManualUpdates = allowManualUpdates,
20+
_settingsService = settingsService;
2021

2122
final GitHub _gitHub;
22-
23+
final SettingsService _settingsService;
2324
final bool _allowManualUpdates;
2425
bool get allowManualUpdate => _allowManualUpdates;
2526

@@ -50,6 +51,17 @@ class AppModel extends SafeChangeNotifier {
5051
String? _buildNumber;
5152
String? get buildNumber => _buildNumber;
5253

54+
Future<void> disposePatchNotes() async {
55+
if (_version != null) {
56+
return _settingsService.disposePatchNotes(_version!);
57+
} else {
58+
return Future.error('unknown version');
59+
}
60+
}
61+
62+
bool recentPatchNotesDisposed() => _version == null
63+
? false
64+
: _settingsService.recentPatchNotesDisposed(_version!);
5365
bool? _updateAvailable;
5466
bool? get updateAvailable => _updateAvailable;
5567
String? _onlineVersion;

lib/app/view/master_detail_page.dart

-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ List<MasterItem> createMasterItems({required LibraryModel libraryModel}) {
268268
title: podcast.value.firstOrNull?.album ??
269269
podcast.value.firstOrNull?.title ??
270270
podcast.value.firstOrNull.toString(),
271-
audios: podcast.value,
272271
imageUrl: podcast.value.firstOrNull?.albumArtUrl ??
273272
podcast.value.firstOrNull?.imageUrl,
274273
),

lib/app/view/scaffold.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import '../../l10n/l10n.dart';
99
import '../../library/library_model.dart';
1010
import '../../patch_notes/patch_notes_dialog.dart';
1111
import '../../player/view/player_view.dart';
12-
import '../../settings/settings_model.dart';
1312
import '../app_model.dart';
1413
import '../connectivity_model.dart';
1514
import 'master_detail_page.dart';
@@ -25,14 +24,15 @@ class _MusicPodScaffoldState extends State<MusicPodScaffold> {
2524
@override
2625
void initState() {
2726
super.initState();
28-
final settingsModel = di<SettingsModel>();
2927
final appModel = di<AppModel>();
3028
appModel
3129
.checkForUpdate(di<ConnectivityModel>().isOnline, context)
3230
.then((_) {
33-
if (!mounted) return;
34-
if (settingsModel.recentPatchNotesDisposed == false) {
35-
showPatchNotes(context);
31+
if (!appModel.recentPatchNotesDisposed() && mounted) {
32+
showDialog(
33+
context: context,
34+
builder: (_) => const PatchNotesDialog(),
35+
);
3636
}
3737
});
3838
}

lib/common/view/audio_page_header_html_description.dart

+24-24
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,31 @@ class AudioPageHeaderHtmlDescription extends StatelessWidget {
6464
],
6565
),
6666
),
67-
child: SizedBox(
68-
child: Html(
69-
data: description,
70-
onAnchorTap: (url, attributes, element) {
71-
if (url == null) return;
72-
launchUrl(Uri.parse(url));
73-
},
74-
style: {
75-
'img': Style(display: Display.none),
76-
'body': Style(
77-
height: Height.auto(),
78-
margin: Margins.zero,
79-
padding: HtmlPaddings.zero,
80-
textOverflow: TextOverflow.ellipsis,
81-
maxLines: 4,
82-
textAlign: TextAlign.center,
83-
fontSize: FontSize(
84-
descriptionStyle?.fontSize ?? 10,
85-
),
86-
fontWeight: descriptionStyle?.fontWeight,
87-
fontFamily: descriptionStyle?.fontFamily,
67+
child: description == null
68+
? const SizedBox.shrink()
69+
: Html(
70+
data: description,
71+
onAnchorTap: (url, attributes, element) {
72+
if (url == null) return;
73+
launchUrl(Uri.parse(url));
74+
},
75+
style: {
76+
'img': Style(display: Display.none),
77+
'body': Style(
78+
height: Height.auto(),
79+
margin: Margins.zero,
80+
padding: HtmlPaddings.zero,
81+
textOverflow: TextOverflow.ellipsis,
82+
maxLines: 4,
83+
textAlign: TextAlign.center,
84+
fontSize: FontSize(
85+
descriptionStyle?.fontSize ?? 10,
86+
),
87+
fontWeight: descriptionStyle?.fontWeight,
88+
fontFamily: descriptionStyle?.fontFamily,
89+
),
90+
},
8891
),
89-
},
90-
),
91-
),
9292
),
9393
),
9494
);

lib/common/view/sliver_audio_page_control_panel.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ import 'package:yaru/constants.dart';
44
import '../../extensions/build_context_x.dart';
55

66
class SliverAudioPageControlPanel extends StatelessWidget {
7-
const SliverAudioPageControlPanel({super.key, required this.controlPanel});
7+
const SliverAudioPageControlPanel({
8+
super.key,
9+
required this.controlPanel,
10+
this.onStretchTrigger,
11+
});
812

913
final Widget controlPanel;
14+
final Future<void> Function()? onStretchTrigger;
1015

1116
@override
1217
Widget build(BuildContext context) {
@@ -25,6 +30,7 @@ class SliverAudioPageControlPanel extends StatelessWidget {
2530
child: controlPanel,
2631
),
2732
bottom: const _Space(),
33+
onStretchTrigger: onStretchTrigger,
2834
),
2935
);
3036
}

lib/constants.dart

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ const kFavRadioTags = 'favRadioTags';
160160
const kFavCountryCodes = 'favCountryCodes';
161161
const kFavLanguageCodes = 'favLanguageCodes';
162162
const kAscendingFeeds = 'ascendingfeed:::';
163+
const kPatchNotesDisposed = 'kPatchNotesDisposed';
163164

164165
const shops = <String, String>{
165166
'https://us.7digital.com/': '7digital',

lib/l10n/app_de.arb

+3-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
"weatherXXXPodcastIndexOnly": "Wetter",
298298
"wildernessXXXPodcastIndexOnly": "Wildnis",
299299
"wrestlingXXXPodcastIndexOnly": "Ringen",
300-
"updateAvailable": "Update available",
300+
"updateAvailable": "Aktualisierung verfügbar",
301301
"showMetaData": "Zeige Metadaten",
302302
"metadata": "Metadaten",
303303
"writeMetadata": "Write metadata",
@@ -329,5 +329,6 @@
329329
"restartEpisode": "Episode von Anfang spielen",
330330
"restartAllEpisodes": "Alle Episoden von Anfang spielen",
331331
"checkForUpdates": "Auf Aktualisierung überprüfen",
332-
"playbackWillStopIn": "Wiedergabe wird gestoppt in: {duration} ({timeOfDay})"
332+
"playbackWillStopIn": "Wiedergabe wird gestoppt in: {duration} ({timeOfDay})",
333+
"schedulePlaybackStopTimer": "Schedule a time to stop playback"
333334
}

lib/l10n/app_en.arb

+2-1
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,6 @@
330330
"replayEpisode": "Replay episode",
331331
"replayAllEpisodes": "Replay all episodes",
332332
"checkForUpdates": "Check for updates",
333-
"playbackWillStopIn": "Playback will stop in: {duration} ({timeOfDay})"
333+
"playbackWillStopIn": "Playback will stop in: {duration} ({timeOfDay})",
334+
"schedulePlaybackStopTimer": "Schedule a time to stop playback"
334335
}

lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Future<void> main(List<String> args) async {
5353
}
5454

5555
// Register services
56-
// TODO: when the app is in appstore/windowsstore enable/disable this only via args
5756
final SharedPreferences sharedPreferences =
5857
await SharedPreferences.getInstance();
5958
final settingsService = SettingsService(
@@ -152,6 +151,7 @@ Future<void> main(List<String> args) async {
152151
dispose: (s) => s.dispose(),
153152
);
154153

154+
// TODO: when the app is in appstore/windowsstore enable/disable this only via args
155155
final appModel = AppModel(
156156
gitHub: gitHub,
157157
settingsService: settingsService,

0 commit comments

Comments
 (0)