Browse Source

refactor(neon,neon_news,neon_notes): refine function types in interfaces

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/742/head
Nikolas Rimikis 1 year ago
parent
commit
a7925540e7
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 4
      packages/neon/neon/lib/src/bloc/bloc.dart
  2. 2
      packages/neon/neon/lib/src/settings/widgets/account_settings_tile.dart
  3. 2
      packages/neon/neon/lib/src/settings/widgets/custom_settings_tile.dart
  4. 3
      packages/neon/neon/lib/src/utils/global_options.dart
  5. 27
      packages/neon/neon/lib/src/utils/request_manager.dart
  6. 2
      packages/neon/neon/lib/src/widgets/account_tile.dart
  7. 2
      packages/neon/neon/lib/src/widgets/exception.dart
  8. 2
      packages/neon/neon/lib/src/widgets/list_view.dart
  9. 2
      packages/neon/neon_files/lib/options.dart
  10. 2
      packages/neon/neon_news/lib/blocs/article.dart
  11. 1
      packages/neon/neon_news/lib/neon_news.dart
  12. 2
      packages/neon/neon_news/lib/widgets/folder_select.dart
  13. 2
      packages/neon/neon_notes/lib/widgets/category_select.dart

4
packages/neon/neon/lib/src/bloc/bloc.dart

@ -25,9 +25,9 @@ abstract class InteractiveBloc extends Bloc {
// ignore: avoid_void_async // ignore: avoid_void_async
void wrapAction( void wrapAction(
final Future<void> Function() call, { final AsyncCallback call, {
final bool disableTimeout = false, final bool disableTimeout = false,
final Future<void> Function()? refresh, final AsyncCallback? refresh,
}) async { }) async {
try { try {
if (disableTimeout) { if (disableTimeout) {

2
packages/neon/neon/lib/src/settings/widgets/account_settings_tile.dart

@ -17,7 +17,7 @@ class AccountSettingsTile extends SettingsTile {
final Account account; final Account account;
final Color? color; final Color? color;
final Widget? trailing; final Widget? trailing;
final VoidCallback? onTap; final GestureTapCallback? onTap;
@override @override
Widget build(final BuildContext context) => NeonAccountTile( Widget build(final BuildContext context) => NeonAccountTile(

2
packages/neon/neon/lib/src/settings/widgets/custom_settings_tile.dart

@ -17,7 +17,7 @@ class CustomSettingsTile extends SettingsTile {
final Widget? subtitle; final Widget? subtitle;
final Widget? leading; final Widget? leading;
final Widget? trailing; final Widget? trailing;
final Function()? onTap; final GestureTapCallback? onTap;
@override @override
Widget build(final BuildContext context) => ListTile( Widget build(final BuildContext context) => ListTile(

3
packages/neon/neon/lib/src/utils/global_options.dart

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:neon/l10n/localizations.dart'; import 'package:neon/l10n/localizations.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
import 'package:neon/src/models/label_builder.dart';
import 'package:neon/src/settings/models/option.dart'; import 'package:neon/src/settings/models/option.dart';
import 'package:neon/src/settings/models/options_collection.dart'; import 'package:neon/src/settings/models/options_collection.dart';
import 'package:neon/src/settings/models/select_option.dart'; import 'package:neon/src/settings/models/select_option.dart';
@ -51,7 +52,7 @@ class GlobalOptions extends OptionsCollection {
final PackageInfo _packageInfo; final PackageInfo _packageInfo;
late final _distributorsMap = <String, String Function(BuildContext)>{ late final _distributorsMap = <String, LabelBuilder>{
_packageInfo.packageName: (final context) => _packageInfo.packageName: (final context) =>
AppLocalizations.of(context).globalOptionsPushNotificationsDistributorFirebaseEmbedded, AppLocalizations.of(context).globalOptionsPushNotificationsDistributorFirebaseEmbedded,
'com.github.gotify.up': (final context) => 'com.github.gotify.up': (final context) =>

27
packages/neon/neon/lib/src/utils/request_manager.dart

@ -10,6 +10,11 @@ import 'package:rxdart/rxdart.dart';
import 'package:sqflite/sqflite.dart'; import 'package:sqflite/sqflite.dart';
import 'package:xml/xml.dart' as xml; import 'package:xml/xml.dart' as xml;
typedef UnwrapCallback<T, R> = T Function(R);
typedef SerializeCallback<T> = String Function(T);
typedef DeserializeCallback<T> = T Function(String);
typedef NextcloudApiCallback<T> = Future<T> Function();
class RequestManager { class RequestManager {
RequestManager(); RequestManager();
@ -33,8 +38,8 @@ class RequestManager {
final String clientID, final String clientID,
final String k, final String k,
final BehaviorSubject<Result<T>> subject, final BehaviorSubject<Result<T>> subject,
final Future<R> Function() call, final NextcloudApiCallback<R> call,
final T Function(R) unwrap, { final UnwrapCallback<T, R> unwrap, {
final bool disableTimeout = false, final bool disableTimeout = false,
final bool emitEmptyCache = false, final bool emitEmptyCache = false,
}) async => }) async =>
@ -55,8 +60,8 @@ class RequestManager {
final String clientID, final String clientID,
final String k, final String k,
final BehaviorSubject<Result<T>> subject, final BehaviorSubject<Result<T>> subject,
final Future<WebDavMultistatus> Function() call, final NextcloudApiCallback<WebDavMultistatus> call,
final T Function(WebDavMultistatus) unwrap, { final UnwrapCallback<T, WebDavMultistatus> unwrap, {
final bool disableTimeout = false, final bool disableTimeout = false,
final bool emitEmptyCache = false, final bool emitEmptyCache = false,
}) async => }) async =>
@ -77,10 +82,10 @@ class RequestManager {
final String clientID, final String clientID,
final String k, final String k,
final BehaviorSubject<Result<T>> subject, final BehaviorSubject<Result<T>> subject,
final Future<R> Function() call, final NextcloudApiCallback<R> call,
final T Function(R) unwrap, final UnwrapCallback<T, R> unwrap,
final String Function(R) serialize, final SerializeCallback<R> serialize,
final R Function(String) deserialize, final DeserializeCallback<R> deserialize,
final bool disableTimeout, final bool disableTimeout,
final bool emitEmptyCache, final bool emitEmptyCache,
final int retries, final int retries,
@ -150,8 +155,8 @@ class RequestManager {
Future<bool> _emitCached<T, R>( Future<bool> _emitCached<T, R>(
final String key, final String key,
final BehaviorSubject<Result<T>> subject, final BehaviorSubject<Result<T>> subject,
final T Function(R) unwrap, final UnwrapCallback<T, R> unwrap,
final R Function(String) deserialize, final DeserializeCallback<R> deserialize,
final bool emitEmptyCache, final bool emitEmptyCache,
final bool loading, final bool loading,
final Object? error, final Object? error,
@ -180,7 +185,7 @@ class RequestManager {
} }
Future<T> timeout<T>( Future<T> timeout<T>(
final Future<T> Function() call, final NextcloudApiCallback<T> call,
) => ) =>
call().timeout(const Duration(seconds: 30)); call().timeout(const Duration(seconds: 30));
} }

2
packages/neon/neon/lib/src/widgets/account_tile.dart

@ -25,7 +25,7 @@ class NeonAccountTile extends StatelessWidget {
final Account account; final Account account;
final Color? color; final Color? color;
final Widget? trailing; final Widget? trailing;
final VoidCallback? onTap; final GestureTapCallback? onTap;
final Color? textColor; final Color? textColor;
final bool dense; final bool dense;
final bool showStatus; final bool showStatus;

2
packages/neon/neon/lib/src/widgets/exception.dart

@ -22,7 +22,7 @@ class NeonException extends StatelessWidget {
}); });
final dynamic exception; final dynamic exception;
final Function() onRetry; final VoidCallback onRetry;
final bool onlyIcon; final bool onlyIcon;
final double? iconSize; final double? iconSize;
final Color? color; final Color? color;

2
packages/neon/neon/lib/src/widgets/list_view.dart

@ -19,7 +19,7 @@ class NeonListView<T> extends StatelessWidget {
final Iterable<T>? items; final Iterable<T>? items;
final bool isLoading; final bool isLoading;
final dynamic error; final dynamic error;
final Future<void> Function() onRefresh; final RefreshCallback onRefresh;
final Widget Function(BuildContext, T data) builder; final Widget Function(BuildContext, T data) builder;
final String? scrollKey; final String? scrollKey;
final bool withFloatingActionButton; final bool withFloatingActionButton;

2
packages/neon/neon_files/lib/options.dart

@ -86,7 +86,7 @@ class FilesAppSpecificOptions extends NextcloudAppOptions {
}, },
); );
late final _sizeWarningValues = <int?, String Function(BuildContext)>{ late final _sizeWarningValues = <int?, LabelBuilder>{
null: (final context) => AppLocalizations.of(context).optionsSizeWarningDisabled, null: (final context) => AppLocalizations.of(context).optionsSizeWarningDisabled,
for (final i in [ for (final i in [
1, 1,

2
packages/neon/neon_news/lib/blocs/article.dart

@ -78,7 +78,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents,
}); });
} }
void _wrapArticleAction(final Future<void> Function() call) => wrapAction( void _wrapArticleAction(final AsyncCallback call) => wrapAction(
call, call,
refresh: () async { refresh: () async {
await _newsArticlesBloc.refresh(); await _newsArticlesBloc.refresh();

1
packages/neon/neon_news/lib/neon_news.dart

@ -2,6 +2,7 @@ library neon_news;
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart';

2
packages/neon/neon_news/lib/widgets/folder_select.dart

@ -9,7 +9,7 @@ class NewsFolderSelect extends StatelessWidget {
}); });
final List<NewsFolder> folders; final List<NewsFolder> folders;
final void Function(NewsFolder?) onChanged; final ValueChanged<NewsFolder?> onChanged;
final NewsFolder? value; final NewsFolder? value;
@override @override

2
packages/neon/neon_notes/lib/widgets/category_select.dart

@ -22,7 +22,7 @@ class NotesCategorySelect extends StatelessWidget {
final List<String> categories; final List<String> categories;
final String? initialValue; final String? initialValue;
final Function(String category) onChanged; final Function(String category) onChanged;
final Function() onSubmitted; final VoidCallback onSubmitted;
@override @override
Widget build(final BuildContext context) => Autocomplete<String>( Widget build(final BuildContext context) => Autocomplete<String>(

Loading…
Cancel
Save