Skip to content

Commit

Permalink
fix: android immersive mode issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nini22P committed Dec 11, 2024
1 parent 3f5bffa commit d3b0ed4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:fullBackupContent="false"
android:enableOnBackInvokedCallback="true"
>
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:taskAffinity="" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
Expand Down
20 changes: 20 additions & 0 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:iris/pages/player/iris_player.dart';

Expand All @@ -7,6 +8,25 @@ class HomePage extends HookWidget {

@override
Widget build(BuildContext context) {
useEffect(() {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
));
return null;
}, []);

useEffect(() {
SystemChrome.setSystemUIChangeCallback((value) async {
if (value) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
}
});
return () {
SystemChrome.setSystemUIChangeCallback(null);
};
}, []);

return const Scaffold(
body: IrisPlayer(),
);
Expand Down
17 changes: 0 additions & 17 deletions lib/pages/player/iris_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,6 @@ class IrisPlayer extends HookWidget {
}
}

final appLifecycleState = useAppLifecycleState();

useEffect(() {
if (appLifecycleState == AppLifecycleState.resumed) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
}
return null;
}, [appLifecycleState]);

useEffect(() {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
));
return null;
}, []);

useEffect(() {
if (isDesktop()) {
windowManager
Expand Down

0 comments on commit d3b0ed4

Please sign in to comment.