From 6db31e2b240842c7284bfb5d13e875a0e6aec0e8 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 19 Mar 2023 12:52:34 -0400 Subject: [PATCH] Support for normal text changelogs (by Source) --- lib/pages/apps.dart | 68 +++++++++++++++++------------- lib/providers/source_provider.dart | 1 + 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/lib/pages/apps.dart b/lib/pages/apps.dart index 412d8f1..a0beb61 100644 --- a/lib/pages/apps.dart +++ b/lib/pages/apps.dart @@ -231,8 +231,9 @@ class AppsPageState extends State { SliverList( delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - String? changesUrl = SourceProvider() - .getSource(listedApps[index].app.url) + AppSource appSource = + SourceProvider().getSource(listedApps[index].app.url); + String? changesUrl = appSource .changeLogPageFromStandardUrl(listedApps[index].app.url); String? changeLog = listedApps[index].app.changeLog; var showChanges = (changeLog == null && changesUrl == null) @@ -267,35 +268,42 @@ class AppsPageState extends State { height: 16, ) : const SizedBox.shrink(), - SizedBox( - width: MediaQuery.of(context).size.width, - height: - MediaQuery.of(context).size.height - + appSource.changeLogIfAnyIsMarkDown + ? SizedBox( + width: + MediaQuery.of(context).size.width, + height: MediaQuery.of(context) + .size + .height - 350, - child: Markdown( - data: changeLog, - onTapLink: (text, href, title) { - if (href != null) { - launchUrlString( - href.startsWith('http://') || - href.startsWith( - 'https://') - ? href - : '${Uri.parse(listedApps[index].app.url).origin}/$href', - mode: LaunchMode - .externalApplication); - } - }, - extensionSet: md.ExtensionSet( - md.ExtensionSet.gitHubFlavored - .blockSyntaxes, - [ - md.EmojiSyntax(), - ...md.ExtensionSet.gitHubFlavored - .inlineSyntaxes - ], - ), - )), + child: Markdown( + data: changeLog, + onTapLink: (text, href, title) { + if (href != null) { + launchUrlString( + href.startsWith( + 'http://') || + href.startsWith( + 'https://') + ? href + : '${Uri.parse(listedApps[index].app.url).origin}/$href', + mode: LaunchMode + .externalApplication); + } + }, + extensionSet: md.ExtensionSet( + md.ExtensionSet.gitHubFlavored + .blockSyntaxes, + [ + md.EmojiSyntax(), + ...md + .ExtensionSet + .gitHubFlavored + .inlineSyntaxes + ], + ), + )) + : Text(changeLog), ], singleNullReturnButton: tr('ok'), ); diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 270b4c4..fd4254d 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -228,6 +228,7 @@ class AppSource { String? host; late String name; bool enforceTrackOnly = false; + bool changeLogIfAnyIsMarkDown = true; AppSource() { name = runtimeType.toString();