summaryrefslogtreecommitdiff
path: root/player-android/lib/providers/api_client_provider.dart
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-22 09:17:31 +0300
committerPaul Buetow <paul@buetow.org>2026-05-22 09:17:31 +0300
commit1824175276fcd29d4b6d4c14277c62e73247b7e2 (patch)
treeb32c9867f24d4ca34bb5a902adb9fb508ddc00d1 /player-android/lib/providers/api_client_provider.dart
parent1b66b5f573c8de883947d712057ff85f5513e8ae (diff)
Implement public ShareViewerScreen with Android deep-link intent-filter (9b)
- New ShareViewerScreen (/share/:token): unauthenticated share-viewer that fetches share metadata via publicApiClientProvider, renders filename, type, duration, thumbnail, and a Play button routing to the video/audio player. - New publicApiClientProvider: bare Dio client (no auth interceptors) for the public share endpoint; shares kPlayerBaseUrl with the authenticated client. - AndroidManifest: http + https deep-link intent-filters for /share/.* so Android routes share URLs directly into the app (App Links / autoVerify). - router.dart: /share/:token bypasses the authentication redirect; guard uses AppRoutes.shareViewerPrefix constant instead of a raw '/share/' string (DIP). - app_routes.dart: shareViewer route constant, shareViewerPrefix, shareViewerPath helper. - error_mappers.dart: shareViewerErrorMessage — 404 invalid/revoked, 410 expired. - player_api_client.dart: baseUrl getter encapsulates rawDio.options.baseUrl so screens never access transport internals directly (ISP, DIP). - Review fixes: OCP icon map in _FallbackThumbnail, LSP explicit baseUrl overrides in test fakes, DIP shareViewerPrefix constant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'player-android/lib/providers/api_client_provider.dart')
-rw-r--r--player-android/lib/providers/api_client_provider.dart18
1 files changed, 12 insertions, 6 deletions
diff --git a/player-android/lib/providers/api_client_provider.dart b/player-android/lib/providers/api_client_provider.dart
index 128b89d..9a3ca8d 100644
--- a/player-android/lib/providers/api_client_provider.dart
+++ b/player-android/lib/providers/api_client_provider.dart
@@ -5,12 +5,18 @@ import '../api/dio_player_api_client.dart';
import '../api/player_api_client.dart';
import '../navigation_key.dart';
-/// Base URL for the player-server API.
+/// Base URL for the player-server API, resolved at compile time via
+/// the PLAYER_BASE_URL environment variable (or the default below).
///
-/// In production this is injected from the environment or a config file.
-/// The default points to a local dev instance so the app is runnable
-/// without extra configuration.
-const _kBaseUrl = String.fromEnvironment(
+/// Declared as a package-level identifier (no underscore) so it can be
+/// shared by [publicApiClientProvider] in [public_api_client_provider.dart].
+/// The value is set once at compile time and never changes at runtime,
+/// making it safe to share across providers.
+///
+/// In production this is injected via `--dart-define=PLAYER_BASE_URL=...`.
+/// The default points to the Android emulator host loopback address so the
+/// app is runnable out-of-the-box without extra configuration.
+const kPlayerBaseUrl = String.fromEnvironment(
'PLAYER_BASE_URL',
defaultValue: 'http://10.0.2.2:8080',
);
@@ -34,7 +40,7 @@ final apiClientProvider = Provider<PlayerApiClient>((ref) {
final storage = ref.watch(tokenStorageProvider);
final dioClient = DioClient(
- baseUrl: Uri.parse(_kBaseUrl),
+ baseUrl: Uri.parse(kPlayerBaseUrl),
storage: storage,
// Share the navigator key with go_router so 401 redirects go through the
// correct router instance rather than the raw Navigator.