From 2c137f9930ecfc1b6c8a1ed7bbaf7e8e1449392c Mon Sep 17 00:00:00 2001 From: Yu Fang Date: Tue, 12 Mar 2024 00:31:35 +0800 Subject: [PATCH] update:UI --- lib/init.dart | 15 +++--- lib/model/custom_theme.dart | 48 ++++++++++++------- .../mdnsService/mdnsServiceListPage.dart | 3 ++ lib/pages/splashPage/splashPage.dart | 15 +++--- lib/pages/user/profilePage.dart | 2 +- 5 files changed, 53 insertions(+), 30 deletions(-) diff --git a/lib/init.dart b/lib/init.dart index b365b68..50c8eec 100644 --- a/lib/init.dart +++ b/lib/init.dart @@ -19,7 +19,7 @@ Future init() async { initBackgroundService(); initHttpAssets(); initWechat(); - initSystemUi(); + // initSystemUi(); loadConfig(); } @@ -47,12 +47,15 @@ Future initWechat() async { } Future initSystemUi() async { + // SystemChrome.setEnabledSystemUIMode([SystemUiOverlay.top] as SystemUiMode); //安卓透明状态栏 - if (Platform.isAndroid) { - SystemUiOverlayStyle systemUiOverlayStyle = - const SystemUiOverlayStyle(statusBarColor: Colors.transparent); - SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); - } + // if (Platform.isAndroid) { + SystemUiOverlayStyle systemUiOverlayStyle = + const SystemUiOverlayStyle(statusBarColor: Colors.transparent, + // 导航栏下面的控制栏的颜色 + systemNavigationBarColor:Colors.transparent); + SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); + // } } Future loadConfig() async { diff --git a/lib/model/custom_theme.dart b/lib/model/custom_theme.dart index e34953d..80bcd63 100644 --- a/lib/model/custom_theme.dart +++ b/lib/model/custom_theme.dart @@ -1,6 +1,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CustomTheme with ChangeNotifier { @@ -40,29 +41,36 @@ class CustomTheme with ChangeNotifier { class CustomThemes { static const Color _lightAccentColor = Colors.orange; + static const Color _darkAccentColor = Colors.black; static final ThemeData light = ThemeData( - brightness: Brightness.light, - primarySwatch: _lightAccentColor as MaterialColor, - primaryColor: _lightAccentColor, - // primaryColorLight: _lightAccentColor, - iconTheme: const IconThemeData(color: _lightAccentColor), - bottomNavigationBarTheme: const BottomNavigationBarThemeData( - selectedItemColor: _lightAccentColor, - unselectedItemColor: Colors.grey, - // backgroundColor: Colors.white, - ), - bottomAppBarTheme: const BottomAppBarTheme( - color: Colors.white, - ), - floatingActionButtonTheme: const FloatingActionButtonThemeData( - backgroundColor: _lightAccentColor, - ), + brightness: Brightness.light, + primarySwatch: _lightAccentColor as MaterialColor, + primaryColor: _lightAccentColor, + // primaryColorLight: _lightAccentColor, + iconTheme: const IconThemeData(color: _lightAccentColor), + bottomNavigationBarTheme: const BottomNavigationBarThemeData( + selectedItemColor: _lightAccentColor, + unselectedItemColor: Colors.grey, + // backgroundColor: Colors.white, + ), + bottomAppBarTheme: const BottomAppBarTheme( + color: Colors.white, + ), + floatingActionButtonTheme: const FloatingActionButtonThemeData( + backgroundColor: _lightAccentColor, + ), + appBarTheme: const AppBarTheme( + backgroundColor: _lightAccentColor, + systemOverlayStyle: SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + systemNavigationBarColor: Colors.white), + ), ); static final ThemeData dark = ThemeData( brightness: Brightness.dark, primarySwatch: _lightAccentColor as MaterialColor, - primaryColor: _lightAccentColor, + primaryColor: _darkAccentColor, // primaryColorLight: _lightAccentColor, iconTheme: const IconThemeData(color: _lightAccentColor), bottomNavigationBarTheme: const BottomNavigationBarThemeData( @@ -70,5 +78,11 @@ class CustomThemes { unselectedItemColor: Colors.grey, // backgroundColor: Colors.white, ), + appBarTheme: const AppBarTheme( + backgroundColor: _darkAccentColor, + systemOverlayStyle: SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + systemNavigationBarColor: Colors.black), + ), ); } diff --git a/lib/pages/mdnsService/mdnsServiceListPage.dart b/lib/pages/mdnsService/mdnsServiceListPage.dart index c3da64a..2346cb6 100644 --- a/lib/pages/mdnsService/mdnsServiceListPage.dart +++ b/lib/pages/mdnsService/mdnsServiceListPage.dart @@ -139,6 +139,9 @@ class _MdnsServiceListPageState extends State { return Scaffold( appBar: AppBar( title: Text(widget.title), + // backgroundColor: Provider.of(context).isLightTheme() + // ? CustomThemes.light.primaryColor + // : CustomThemes.dark.primaryColor, centerTitle: true, actions: _build_actions(), ), diff --git a/lib/pages/splashPage/splashPage.dart b/lib/pages/splashPage/splashPage.dart index 1523d88..6be61bd 100644 --- a/lib/pages/splashPage/splashPage.dart +++ b/lib/pages/splashPage/splashPage.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:openiothub/pages/homePage/homePage.dart'; class SplashPage extends StatefulWidget { @@ -17,6 +18,7 @@ class LaunchState extends State { @override void initState() { + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,overlays:[SystemUiOverlay.top]); super.initState(); _startRecordTime(); print('初始化启动页面'); @@ -25,6 +27,7 @@ class LaunchState extends State { @override void dispose() { super.dispose(); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,overlays:SystemUiOverlay.values); print('启动页面结束'); if (_countdownTimer.isActive) { _countdownTimer.cancel(); @@ -53,13 +56,14 @@ class LaunchState extends State { @override Widget build(BuildContext context) { - return MaterialApp( - theme: ThemeData.dark(), - home: Scaffold( + return Scaffold( + extendBody: true, //底部NavigationBar透明 + extendBodyBehindAppBar: true,//顶部Bar透明 + backgroundColor: Colors.transparent, body: Stack( fit: StackFit.expand, children: [ - Image.asset(launchImage, fit: BoxFit.fill), + Positioned.fill(child: Image.asset(launchImage, fit: BoxFit.fill)), Positioned( top: 30, right: 30, @@ -95,7 +99,6 @@ class LaunchState extends State { ) ], ), - ), - ); + ); } } diff --git a/lib/pages/user/profilePage.dart b/lib/pages/user/profilePage.dart index 1cf8f67..bb913f9 100644 --- a/lib/pages/user/profilePage.dart +++ b/lib/pages/user/profilePage.dart @@ -85,7 +85,7 @@ class _ProfilePageState extends State { return Container( color: Provider.of(context).isLightTheme() ? CustomThemes.light.primaryColor - : CustomThemes.dark.primaryColorLight, + : CustomThemes.dark.primaryColor, height: 150.0, child: Center( child: Column(