Skip to content

Commit

Permalink
feat(voltron): fix navigation bar color error after modal show
Browse files Browse the repository at this point in the history
  • Loading branch information
henryjin0511 committed Aug 6, 2023
1 parent f35f899 commit f78c3c9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 122 deletions.
13 changes: 8 additions & 5 deletions framework/voltron/example/lib/base_voltron_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CustomExceptionHandler extends VoltronExceptionHandlerAdapter {
void handleJsException(JsError exception) {
LogUtils.e('Voltron3Page', exception.toString());
var currentRootContext = key.currentContext;

/// 只有开发模式下把js异常抛出来
if (currentRootContext == null || !isDebugMode) return;
showDialog(
Expand Down Expand Up @@ -94,13 +95,15 @@ class CustomExceptionHandler extends VoltronExceptionHandlerAdapter {
}

class BaseVoltronPage extends StatefulWidget {
final String title;
final bool isHome;
final bool debugMode;
final String coreBundle;
final String indexBundle;
final String remoteServerUrl;

BaseVoltronPage({
this.title = '',
this.isHome = false,
this.debugMode = false,
this.coreBundle = '',
Expand Down Expand Up @@ -229,6 +232,11 @@ class _BaseVoltronPageState extends State<BaseVoltronPage> {
Widget child;
if (engineStatus == PageStatus.success) {
child = Scaffold(
appBar: AppBar(
title: Text(
widget.title,
),
),
body: VoltronWidget(
loader: _jsLoader,
loadingBuilder: _debugMode ? null : (context) => Container(),
Expand All @@ -241,11 +249,6 @@ class _BaseVoltronPageState extends State<BaseVoltronPage> {
} else {
child = Container();
}
child = SafeArea(
key: dialogRootKey,
bottom: false,
child: child,
);
return WillPopScope(
onWillPop: () async {
return !(_jsLoader.back(() {
Expand Down
12 changes: 9 additions & 3 deletions framework/voltron/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ void main() {
// debugPrintRebuildDirtyWidgets = true; // 记录每帧重建的 widget
// debugProfilePaintsEnabled = true;
if (Platform.isAndroid) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith(
statusBarColor: Colors.black,
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
systemNavigationBarColor: Color(0XFFE5E5E5),
));
}
runApp(MyApp());
}

class _MyWidgetInspector with WidgetInspectorService {
static void init() {
WidgetInspectorService.instance = _MyWidgetInspector();
Expand Down Expand Up @@ -93,7 +94,9 @@ class _MyHomePageState extends State<MyHomePage> {
return Scaffold(
backgroundColor: const Color(0XFFE5E5E5),
appBar: AppBar(
title: const Text('Demo'),
title: const Text(
'Demo',
),
),
body: Center(
child: Column(
Expand Down Expand Up @@ -168,6 +171,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
MaterialPageRoute(
builder: (context) => BaseVoltronPage(
title: 'Vue 2.0',
coreBundle: "assets/jsbundle/vue2/vendor.android.js",
indexBundle: "assets/jsbundle/vue2/index.android.js",
),
Expand All @@ -183,6 +187,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
MaterialPageRoute(
builder: (context) => BaseVoltronPage(
title: 'Vue 3.0',
coreBundle: "assets/jsbundle/vue3/vendor.android.js",
indexBundle: "assets/jsbundle/vue3/index.android.js",
),
Expand All @@ -198,6 +203,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
MaterialPageRoute(
builder: (context) => BaseVoltronPage(
title: 'React',
coreBundle: "assets/jsbundle/react/vendor.android.js",
indexBundle: "assets/jsbundle/react/index.android.js",
),
Expand Down
100 changes: 0 additions & 100 deletions framework/voltron/example/lib/voltron_demo_page.dart

This file was deleted.

35 changes: 21 additions & 14 deletions renderer/voltron/lib/viewmodel/modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,29 @@ class ModalRenderViewModel extends GroupViewModel implements InstanceLifecycleEv
} else {
content = SafeArea(child: child);
}
content = Scaffold(
backgroundColor: const Color(0x01ffffff),
resizeToAvoidBottomInset: true,
body: WillPopScope(
onWillPop: () async {
onRequestClose();
return false;
},
child: content,
),
);
if (statusBarTextDarkColor) {
content = AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light,
),
child: content,
);
}
return Material(
type: MaterialType.transparency,
child: Scaffold(
backgroundColor: const Color(0x01ffffff),
resizeToAvoidBottomInset: true,
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: statusBarTextDarkColor ? SystemUiOverlayStyle.dark : SystemUiOverlayStyle.light,
child: WillPopScope(
onWillPop: () async {
onRequestClose();
return false;
},
child: content,
),
),
),
child: content,
);
}

Expand Down

0 comments on commit f78c3c9

Please sign in to comment.