From 6cde7748a311462a710f87aa2b562a670d07c4b1 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Fri, 4 Aug 2023 05:54:05 +0200 Subject: [PATCH] fix(neon_news): NewsAppSpecificOptions.articleViewTypeOption persistence Force loading wasn't an option as the generic is not a String --- packages/neon/neon_news/lib/options.dart | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/neon/neon_news/lib/options.dart b/packages/neon/neon_news/lib/options.dart index f8ee290e..03cb1fb0 100644 --- a/packages/neon/neon_news/lib/options.dart +++ b/packages/neon/neon_news/lib/options.dart @@ -1,7 +1,7 @@ part of 'neon_news.dart'; class NewsAppSpecificOptions extends NextcloudAppOptions { - NewsAppSpecificOptions(super.storage, final NeonPlatform platform) { + NewsAppSpecificOptions(super.storage, this._platform) { super.categories = [ generalCategory, articlesCategory, @@ -21,18 +21,10 @@ class NewsAppSpecificOptions extends NextcloudAppOptions { feedsSortPropertyOption, feedsSortBoxOrderOption, ]; - - articleViewTypeOption.values = { - ArticleViewType.direct: (final context) => AppLocalizations.of(context).optionsArticleViewTypeDirect, - if (platform.canUseWebView) ...{ - ArticleViewType.internalBrowser: (final context) => - AppLocalizations.of(context).optionsArticleViewTypeInternalBrowser, - }, - ArticleViewType.externalBrowser: (final context) => - AppLocalizations.of(context).optionsArticleViewTypeExternalBrowser, - }; } + final NeonPlatform _platform; + final generalCategory = OptionsCategory( name: (final context) => AppLocalizations.of(context).general, ); @@ -68,7 +60,14 @@ class NewsAppSpecificOptions extends NextcloudAppOptions { key: 'article-view-type', label: (final context) => AppLocalizations.of(context).optionsArticleViewType, defaultValue: ArticleViewType.direct, - values: {}, + values: { + ArticleViewType.direct: (final context) => AppLocalizations.of(context).optionsArticleViewTypeDirect, + if (_platform.canUseWebView) + ArticleViewType.internalBrowser: (final context) => + AppLocalizations.of(context).optionsArticleViewTypeInternalBrowser, + ArticleViewType.externalBrowser: (final context) => + AppLocalizations.of(context).optionsArticleViewTypeExternalBrowser, + }, ); late final articleDisableMarkAsReadTimeoutOption = ToggleOption(