mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 06:19:35 +00:00
修复ios端无活动用户时黑屏
This commit is contained in:
parent
f3caafc5e9
commit
e7ad8d67f6
11 changed files with 564 additions and 264 deletions
|
|
@ -98,7 +98,7 @@ class OnboardingBody extends HookConsumerWidget {
|
|||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
)
|
||||
: Text(
|
||||
'Please enter the URL of your AudiobookShelf Server',
|
||||
S.of(context).loginServerNoConnected,
|
||||
key: const ValueKey('not_connected'),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||
import 'package:shelfsdk/audiobookshelf_api.dart';
|
||||
import 'package:vaani/api/api_provider.dart';
|
||||
import 'package:vaani/api/authenticated_users_provider.dart';
|
||||
import 'package:vaani/generated/l10n.dart';
|
||||
import 'package:vaani/models/error_response.dart';
|
||||
import 'package:vaani/router/router.dart';
|
||||
import 'package:vaani/settings/models/models.dart' as model;
|
||||
|
|
@ -109,7 +110,7 @@ class UserLoginWithToken extends HookConsumerWidget {
|
|||
const SizedBox(height: 10),
|
||||
ElevatedButton(
|
||||
onPressed: loginAndSave,
|
||||
child: const Text('Login'),
|
||||
child: Text(S.of(context).loginLogin),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -15,13 +15,17 @@ import 'package:vaani/features/player/providers/player_status_provider.dart';
|
|||
import 'package:vaani/globals.dart';
|
||||
import 'package:vaani/settings/app_settings_provider.dart';
|
||||
import 'package:vaani/shared/extensions/obfuscation.dart';
|
||||
import 'package:vaani/shared/utils/utils.dart';
|
||||
|
||||
part 'session_provider.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
Future<AbsAudioHandler> audioHandlerInit(Ref ref) async {
|
||||
// JustAudioMediaKit.ensureInitialized(windows: false);
|
||||
JustAudioMediaKit.ensureInitialized();
|
||||
if (Utils.isWindows() || Utils.isLinux()) {
|
||||
// JustAudioMediaKit.ensureInitialized(windows: false);
|
||||
JustAudioMediaKit.ensureInitialized();
|
||||
}
|
||||
|
||||
final audioService = await AudioService.init(
|
||||
builder: () => AbsAudioHandler(ref),
|
||||
config: const AudioServiceConfig(
|
||||
|
|
|
|||
|
|
@ -87,25 +87,16 @@ class _FrameworkState extends ConsumerState<Framework>
|
|||
// Eagerly initialize providers by watching them.
|
||||
// By using "watch", the provider will stay alive and not be disposed.
|
||||
try {
|
||||
final audioService = ref.watch(audioHandlerInitProvider);
|
||||
ref.watch(playbackReporterProvider);
|
||||
// ref.watch(simpleAudiobookPlayerProvider);
|
||||
ref.watch(sleepTimerProvider);
|
||||
// ref.watch(playbackReporterProvider);
|
||||
ref.watch(simpleDownloadManagerProvider);
|
||||
if (Utils.isAndroid()) ref.watch(shakeDetectorProvider);
|
||||
ref.watch(sleepTimerProvider);
|
||||
ref.watch(skipStartEndProvider);
|
||||
return audioService.maybeWhen(
|
||||
data: (_) {
|
||||
return widget.child;
|
||||
},
|
||||
orElse: () => SizedBox.shrink(),
|
||||
);
|
||||
ref.watch(playbackReporterProvider);
|
||||
} catch (e) {
|
||||
debugPrintStack(stackTrace: StackTrace.current, label: e.toString());
|
||||
appLogger.severe(e.toString());
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return widget.child;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import 'package:logging/logging.dart';
|
|||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:vaani/router/router.dart';
|
||||
|
||||
late String appName;
|
||||
const String appScheme = "vaani";
|
||||
|
|
@ -45,6 +46,8 @@ late String deviceManufacturer;
|
|||
late Logger appLogger;
|
||||
late Directory appStorageDir;
|
||||
|
||||
var routerConfig = const MyAppRouter().config;
|
||||
|
||||
String getDeviceName(data) {
|
||||
// try different keys to get the device name
|
||||
return // android
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import 'package:vaani/api/server_provider.dart';
|
|||
import 'package:vaani/db/storage.dart';
|
||||
import 'package:vaani/features/logging/core/logger.dart';
|
||||
import 'package:vaani/features/player/providers/audiobook_player.dart';
|
||||
import 'package:vaani/features/player/providers/session_provider.dart';
|
||||
import 'package:vaani/framework.dart';
|
||||
import 'package:vaani/generated/l10n.dart';
|
||||
import 'package:vaani/globals.dart';
|
||||
|
|
@ -23,6 +24,7 @@ import 'package:window_manager/window_manager.dart';
|
|||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
final container = ProviderContainer();
|
||||
_runPlatformSpecificCode();
|
||||
|
||||
// Configure the App Metadata
|
||||
|
|
@ -36,11 +38,12 @@ void main() async {
|
|||
|
||||
// initialize audio player
|
||||
// await configurePlayer();
|
||||
|
||||
await container.read(audioHandlerInitProvider.future);
|
||||
// run the app
|
||||
runApp(
|
||||
const ProviderScope(
|
||||
child: Framework(
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: const Framework(
|
||||
// audioHandler: ,
|
||||
child: AbsApp(),
|
||||
),
|
||||
|
|
@ -76,8 +79,6 @@ Future<void> _runPlatformSpecificCode() async {
|
|||
}
|
||||
}
|
||||
|
||||
var routerConfig = const MyAppRouter().config;
|
||||
|
||||
class AbsApp extends ConsumerWidget {
|
||||
const AbsApp({super.key});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue