network addition

This commit is contained in:
Forrest 2026-08-04 16:39:18 -04:00
parent 3bd713d667
commit 2099d3d64d
27 changed files with 2237 additions and 40 deletions

View file

@ -14,6 +14,7 @@ import '../subsonic/subsonic_client.dart';
import '../theme/accent.dart';
import '../theme/accent_extract.dart';
import 'favorites.dart';
import 'remote_providers.dart';
// `BrowseMode`/`SearchMode` are defined in the settings store (so they can be
// persisted) but historically lived here — re-export so existing importers of
@ -582,3 +583,26 @@ final playbackProvider =
controller.restoreForServer();
return controller;
});
/// The playback state the UI should render: the mirrored state of the device
/// we're controlling as a remote when attached (updates-features.md #3), else
/// the local engine's state. Widgets watch this (with `.select`) instead of
/// [playbackProvider] so the local/remote source is a single swappable seam.
final activePlaybackProvider = Provider<PlaybackState>((ref) {
final remote = ref.watch(
remoteControlProvider.select((s) => s.isAttached ? s.remoteState : null),
);
return remote ?? ref.watch(playbackProvider);
});
/// The command sink the UI should drive — a proxy that serializes commands over
/// the LAN to the attached device when acting as a remote, else the local
/// [PlaybackController]. Widgets read this instead of `playbackProvider.notifier`.
final playbackCommandsProvider = Provider<PlaybackCommands>((ref) {
final attached = ref.watch(remoteControlProvider.select((s) => s.isAttached));
if (attached) {
final remote = ref.read(remoteControlProvider.notifier).remoteCommands;
if (remote != null) return remote;
}
return ref.watch(playbackProvider.notifier);
});