Skip to content

Commit

Permalink
chore: handler argument names
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Jan 25, 2025
1 parent 1c72498 commit 6469fc8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
15 changes: 8 additions & 7 deletions lib/app/connectivity_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:watch_it/watch_it.dart';
import '../common/data/audio_type.dart';
import '../common/view/snackbars.dart';
import '../extensions/connectivity_x.dart';
import '../l10n/l10n.dart';
import '../player/player_model.dart';
import '../player/player_service.dart';
import '../settings/settings_model.dart';
Expand Down Expand Up @@ -62,7 +63,11 @@ class ConnectivityModel extends SafeChangeNotifier {
}
}

void onConnectivityChangedHandler(context, res, cancel) {
void onConnectivityChangedHandler(
BuildContext context,
AsyncSnapshot<List<ConnectivityResult>?> res,
void Function() cancel,
) {
final l10n = context.l10n;
final dataSafeMode = di<PlayerModel>().dataSafeMode;
final notifyDataSafeMode = di<SettingsModel>().notifyDataSafeMode;
Expand All @@ -74,18 +79,14 @@ void onConnectivityChangedHandler(context, res, cancel) {
di<PlayerModel>().setDataSafeMode(true);
showSnackBar(
context: context,
snackBar: SnackBar(
content: Text(l10n.dataSafeModeEnabled),
),
content: Text(l10n.dataSafeModeEnabled),
);
} else if (dataSafeMode &&
!di<Connectivity>().isNotWifiNorEthernet(res.data)) {
di<PlayerModel>().setDataSafeMode(false);
showSnackBar(
context: context,
snackBar: SnackBar(
content: Text(l10n.dataSafeModeDisabled),
),
content: Text(l10n.dataSafeModeDisabled),
);
}
}
2 changes: 0 additions & 2 deletions lib/app/view/desktop_home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ class _DesktopHomePageState extends State<DesktopHomePage> {

registerStreamHandler(
select: (DownloadModel m) => m.messageStream,
initialValue: null,
handler: downloadMessageStreamHandler,
);

registerStreamHandler(
select: (PodcastModel m) => m.stateStream,
initialValue: null,
handler: podcastStateStreamHandler,
);

Expand Down
2 changes: 0 additions & 2 deletions lib/app/view/mobile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ class MobilePage extends StatelessWidget with WatchItMixin {

registerStreamHandler(
select: (DownloadModel m) => m.messageStream,
initialValue: null,
handler: downloadMessageStreamHandler,
);

registerStreamHandler(
select: (PodcastModel m) => m.stateStream,
initialValue: null,
handler: podcastStateStreamHandler,
);

Expand Down
2 changes: 2 additions & 0 deletions lib/common/view/snackbars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
ScaffoldFeatureController<SnackBar, SnackBarClosedReason>? showSnackBar({
required BuildContext? context,
Widget? content,
SnackBarAction? action,
SnackBar? snackBar,
Duration? duration,
bool clear = true,
Expand All @@ -16,6 +17,7 @@ ScaffoldFeatureController<SnackBar, SnackBarClosedReason>? showSnackBar({
SnackBar(
content: content ?? const SizedBox.shrink(),
duration: duration ?? const Duration(seconds: 10),
action: action,
),
);
}
6 changes: 5 additions & 1 deletion lib/podcasts/download_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ class DownloadModel extends SafeChangeNotifier {
}
}

void downloadMessageStreamHandler(context, snapshot, cancel) {
void downloadMessageStreamHandler(
BuildContext context,
AsyncSnapshot<String?> snapshot,
void Function() cancel,
) {
if (snapshot.hasData) {
showSnackBar(context: context, content: Text(snapshot.data ?? ''));
}
Expand Down

0 comments on commit 6469fc8

Please sign in to comment.