A framework for building convergent cross-platform Nextcloud clients using Flutter.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
7.4 KiB

part of 'neon_news.dart';
2 years ago
class NewsAppSpecificOptions extends NextcloudAppOptions {
NewsAppSpecificOptions(super.storage, final NeonPlatform platform) {
2 years ago
super.categories = [
generalCategory,
articlesCategory,
foldersCategory,
feedsCategory,
];
super.options = [
defaultCategoryOption,
articleViewTypeOption,
articleDisableMarkAsReadTimeoutOption,
2 years ago
defaultArticlesFilterOption,
articlesSortPropertyOption,
articlesSortBoxOrderOption,
foldersSortPropertyOption,
foldersSortBoxOrderOption,
defaultFolderViewTypeOption,
feedsSortPropertyOption,
feedsSortBoxOrderOption,
];
_articleViewTypeValuesSubject.add({
ArticleViewType.direct: (final context) => AppLocalizations.of(context).optionsArticleViewTypeDirect,
2 years ago
if (platform.canUseWebView) ...{
ArticleViewType.internalBrowser: (final context) =>
AppLocalizations.of(context).optionsArticleViewTypeInternalBrowser,
2 years ago
},
ArticleViewType.externalBrowser: (final context) =>
AppLocalizations.of(context).optionsArticleViewTypeExternalBrowser,
2 years ago
});
}
final _articleViewTypeValuesSubject = BehaviorSubject<Map<ArticleViewType, String Function(BuildContext)>>();
final generalCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).general,
2 years ago
);
final articlesCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).articles,
2 years ago
);
final foldersCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).folders,
2 years ago
);
final feedsCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).feeds,
2 years ago
);
late final defaultCategoryOption = SelectOption<DefaultCategory>(
storage: super.storage,
category: generalCategory,
key: 'default-category',
label: (final context) => AppLocalizations.of(context).optionsDefaultCategory,
defaultValue: DefaultCategory.articles,
2 years ago
values: BehaviorSubject.seeded({
DefaultCategory.articles: (final context) => AppLocalizations.of(context).articles,
DefaultCategory.folders: (final context) => AppLocalizations.of(context).folders,
DefaultCategory.feeds: (final context) => AppLocalizations.of(context).feeds,
2 years ago
}),
);
late final articleViewTypeOption = SelectOption<ArticleViewType>(
storage: super.storage,
category: articlesCategory,
key: 'article-view-type',
label: (final context) => AppLocalizations.of(context).optionsArticleViewType,
defaultValue: ArticleViewType.direct,
2 years ago
values: _articleViewTypeValuesSubject,
);
late final articleDisableMarkAsReadTimeoutOption = ToggleOption(
storage: super.storage,
category: articlesCategory,
key: 'article-disable-mark-as-read-timeout',
label: (final context) => AppLocalizations.of(context).optionsArticleDisableMarkAsReadTimeout,
defaultValue: false,
);
2 years ago
late final defaultArticlesFilterOption = SelectOption<FilterType>(
storage: super.storage,
category: articlesCategory,
key: 'default-articles-filter',
label: (final context) => AppLocalizations.of(context).optionsDefaultArticlesFilter,
defaultValue: FilterType.unread,
2 years ago
values: BehaviorSubject.seeded({
FilterType.all: (final context) => AppLocalizations.of(context).articlesFilterAll,
FilterType.unread: (final context) => AppLocalizations.of(context).articlesFilterUnread,
FilterType.starred: (final context) => AppLocalizations.of(context).articlesFilterStarred,
2 years ago
}),
);
late final articlesSortPropertyOption = SelectOption<ArticlesSortProperty>(
storage: super.storage,
category: articlesCategory,
key: 'articles-sort-property',
label: (final context) => AppLocalizations.of(context).optionsArticlesSortProperty,
defaultValue: ArticlesSortProperty.publishDate,
2 years ago
values: BehaviorSubject.seeded({
ArticlesSortProperty.publishDate: (final context) =>
AppLocalizations.of(context).optionsArticlesSortPropertyPublishDate,
2 years ago
ArticlesSortProperty.alphabetical: (final context) =>
AppLocalizations.of(context).optionsArticlesSortPropertyAlphabetical,
ArticlesSortProperty.byFeed: (final context) => AppLocalizations.of(context).optionsArticlesSortPropertyFeed,
2 years ago
}),
);
late final articlesSortBoxOrderOption = SelectOption<SortBoxOrder>(
storage: super.storage,
category: articlesCategory,
key: 'articles-sort-box-order',
label: (final context) => AppLocalizations.of(context).optionsArticlesSortOrder,
defaultValue: SortBoxOrder.descending,
2 years ago
values: BehaviorSubject.seeded(sortBoxOrderOptionValues),
);
late final foldersSortPropertyOption = SelectOption<FoldersSortProperty>(
storage: super.storage,
category: foldersCategory,
key: 'folders-sort-property',
label: (final context) => AppLocalizations.of(context).optionsFoldersSortProperty,
defaultValue: FoldersSortProperty.alphabetical,
2 years ago
values: BehaviorSubject.seeded({
FoldersSortProperty.alphabetical: (final context) =>
AppLocalizations.of(context).optionsFoldersSortPropertyAlphabetical,
2 years ago
FoldersSortProperty.unreadCount: (final context) =>
AppLocalizations.of(context).optionsFoldersSortPropertyUnreadCount,
2 years ago
}),
);
late final foldersSortBoxOrderOption = SelectOption<SortBoxOrder>(
storage: super.storage,
category: foldersCategory,
key: 'folders-sort-box-order',
label: (final context) => AppLocalizations.of(context).optionsFoldersSortOrder,
defaultValue: SortBoxOrder.ascending,
2 years ago
values: BehaviorSubject.seeded(sortBoxOrderOptionValues),
);
late final defaultFolderViewTypeOption = SelectOption<DefaultFolderViewType>(
storage: super.storage,
category: foldersCategory,
key: 'default-folder-view-type',
label: (final context) => AppLocalizations.of(context).optionsDefaultFolderViewType,
defaultValue: DefaultFolderViewType.articles,
2 years ago
values: BehaviorSubject.seeded({
DefaultFolderViewType.articles: (final context) => AppLocalizations.of(context).articles,
DefaultFolderViewType.feeds: (final context) => AppLocalizations.of(context).feeds,
2 years ago
}),
);
late final feedsSortPropertyOption = SelectOption<FeedsSortProperty>(
storage: super.storage,
category: feedsCategory,
key: 'feeds-sort-property',
label: (final context) => AppLocalizations.of(context).optionsFeedsSortProperty,
defaultValue: FeedsSortProperty.alphabetical,
2 years ago
values: BehaviorSubject.seeded({
FeedsSortProperty.alphabetical: (final context) =>
AppLocalizations.of(context).optionsFeedsSortPropertyAlphabetical,
2 years ago
FeedsSortProperty.unreadCount: (final context) =>
AppLocalizations.of(context).optionsFeedsSortPropertyUnreadCount,
2 years ago
}),
);
late final feedsSortBoxOrderOption = SelectOption<SortBoxOrder>(
storage: super.storage,
category: feedsCategory,
key: 'feeds-sort-box-order',
label: (final context) => AppLocalizations.of(context).optionsFeedsSortOrder,
defaultValue: SortBoxOrder.ascending,
2 years ago
values: BehaviorSubject.seeded(sortBoxOrderOptionValues),
);
}
enum DefaultCategory {
articles,
folders,
feeds,
}
enum ArticleViewType {
direct,
internalBrowser,
externalBrowser,
}
enum ArticlesSortProperty {
publishDate,
alphabetical,
byFeed,
}
enum FoldersSortProperty {
alphabetical,
unreadCount,
}
enum DefaultFolderViewType {
articles,
feeds,
}
enum FeedsSortProperty {
alphabetical,
unreadCount,
}