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.

210 lines
7.1 KiB

part of 'neon_news.dart';
3 years ago
class NewsAppSpecificOptions extends NextcloudAppOptions {
NewsAppSpecificOptions(super.storage, final NeonPlatform platform) {
3 years ago
super.categories = [
generalCategory,
articlesCategory,
foldersCategory,
feedsCategory,
];
super.options = [
defaultCategoryOption,
articleViewTypeOption,
articleDisableMarkAsReadTimeoutOption,
3 years ago
defaultArticlesFilterOption,
articlesSortPropertyOption,
articlesSortBoxOrderOption,
foldersSortPropertyOption,
foldersSortBoxOrderOption,
defaultFolderViewTypeOption,
feedsSortPropertyOption,
feedsSortBoxOrderOption,
];
articleViewTypeOption.values = {
ArticleViewType.direct: (final context) => AppLocalizations.of(context).optionsArticleViewTypeDirect,
3 years ago
if (platform.canUseWebView) ...{
ArticleViewType.internalBrowser: (final context) =>
AppLocalizations.of(context).optionsArticleViewTypeInternalBrowser,
3 years ago
},
ArticleViewType.externalBrowser: (final context) =>
AppLocalizations.of(context).optionsArticleViewTypeExternalBrowser,
};
3 years ago
}
final generalCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).general,
3 years ago
);
final articlesCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).articles,
3 years ago
);
final foldersCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).folders,
3 years ago
);
final feedsCategory = OptionsCategory(
name: (final context) => AppLocalizations.of(context).feeds,
3 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,
values: {
DefaultCategory.articles: (final context) => AppLocalizations.of(context).articles,
DefaultCategory.folders: (final context) => AppLocalizations.of(context).folders,
DefaultCategory.feeds: (final context) => AppLocalizations.of(context).feeds,
},
3 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,
values: {},
3 years ago
);
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,
);
3 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,
values: {
FilterType.all: (final context) => AppLocalizations.of(context).articlesFilterAll,
FilterType.unread: (final context) => AppLocalizations.of(context).articlesFilterUnread,
FilterType.starred: (final context) => AppLocalizations.of(context).articlesFilterStarred,
},
3 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,
values: {
3 years ago
ArticlesSortProperty.publishDate: (final context) =>
AppLocalizations.of(context).optionsArticlesSortPropertyPublishDate,
3 years ago
ArticlesSortProperty.alphabetical: (final context) =>
AppLocalizations.of(context).optionsArticlesSortPropertyAlphabetical,
ArticlesSortProperty.byFeed: (final context) => AppLocalizations.of(context).optionsArticlesSortPropertyFeed,
},
3 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,
values: sortBoxOrderOptionValues,
3 years ago
);
late final foldersSortPropertyOption = SelectOption<FoldersSortProperty>(
storage: super.storage,
category: foldersCategory,
key: 'folders-sort-property',
label: (final context) => AppLocalizations.of(context).optionsFoldersSortProperty,
defaultValue: FoldersSortProperty.alphabetical,
values: {
3 years ago
FoldersSortProperty.alphabetical: (final context) =>
AppLocalizations.of(context).optionsFoldersSortPropertyAlphabetical,
3 years ago
FoldersSortProperty.unreadCount: (final context) =>
AppLocalizations.of(context).optionsFoldersSortPropertyUnreadCount,
},
3 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,
values: sortBoxOrderOptionValues,
3 years ago
);
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,
values: {
DefaultFolderViewType.articles: (final context) => AppLocalizations.of(context).articles,
DefaultFolderViewType.feeds: (final context) => AppLocalizations.of(context).feeds,
},
3 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,
values: {
3 years ago
FeedsSortProperty.alphabetical: (final context) =>
AppLocalizations.of(context).optionsFeedsSortPropertyAlphabetical,
3 years ago
FeedsSortProperty.unreadCount: (final context) =>
AppLocalizations.of(context).optionsFeedsSortPropertyUnreadCount,
},
3 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,
values: sortBoxOrderOptionValues,
3 years ago
);
}
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,
}