Files
minstrel/flutter_client/lib/app.dart
T
bvandeusen 5114a8118c feat(flutter): CachedIndicator + Download buttons + app startup wiring
CachedIndicator (lib/library/widgets/cached_indicator.dart) — small
download glyph rendered next to a track row when AudioCacheManager
reports the track as cached. FutureBuilder one-shot.

Wiring:
  - track_row.dart: render CachedIndicator before the duration label
  - playlist_detail: 'Download' OutlinedButton next to Play; pins all
    playable tracks with source: autoPlaylist + SnackBar feedback
  - album_detail: 'Download' IconButton in the header; same pin pattern
  - app.dart: now ConsumerStatefulWidget — initState fires the initial
    sync + activates the prefetcher provider

Together these complete the operator-facing surfaces of the offline
slice: visible cache state, explicit download trigger, automatic
sync + queue-ahead prefetch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 23:23:26 -04:00

46 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'cache/prefetcher.dart';
import 'cache/sync_controller.dart';
import 'shared/routing.dart';
import 'theme/theme_data.dart';
import 'theme/theme_mode_provider.dart';
class MinstrelApp extends ConsumerStatefulWidget {
const MinstrelApp({super.key});
@override
ConsumerState<MinstrelApp> createState() => _MinstrelAppState();
}
class _MinstrelAppState extends ConsumerState<MinstrelApp> {
@override
void initState() {
super.initState();
// Activate offline-mode infrastructure once the first frame ships.
// SyncController.sync() is connectivity-aware (no-ops on no auth /
// no server URL), so calling it unconditionally is safe.
// Reading prefetcherProvider runs its constructor, which wires the
// queue + settings listeners.
WidgetsBinding.instance.addPostFrameCallback((_) {
// ignore: unawaited_futures
ref.read(syncControllerProvider.notifier).sync();
ref.read(prefetcherProvider);
});
}
@override
Widget build(BuildContext context) {
final router = ref.watch(routerProvider);
final mode = ref.watch(themeModeProvider).value ?? AppThemeMode.system;
return MaterialApp.router(
title: 'Minstrel',
theme: buildLightTheme(),
darkTheme: buildDarkTheme(),
themeMode: mode.materialMode,
routerConfig: router,
);
}
}