Skip to content

Commit

Permalink
update:UI
Browse files Browse the repository at this point in the history
  • Loading branch information
IoTServ committed Mar 11, 2024
1 parent 33854a3 commit 2c137f9
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 30 deletions.
15 changes: 9 additions & 6 deletions lib/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Future<void> init() async {
initBackgroundService();
initHttpAssets();
initWechat();
initSystemUi();
// initSystemUi();
loadConfig();
}

Expand Down Expand Up @@ -47,12 +47,15 @@ Future<void> initWechat() async {
}

Future<void> 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<void> loadConfig() async {
Expand Down
48 changes: 31 additions & 17 deletions lib/model/custom_theme.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -40,35 +41,48 @@ 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(
selectedItemColor: _lightAccentColor,
unselectedItemColor: Colors.grey,
// backgroundColor: Colors.white,
),
appBarTheme: const AppBarTheme(
backgroundColor: _darkAccentColor,
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
systemNavigationBarColor: Colors.black),
),
);
}
3 changes: 3 additions & 0 deletions lib/pages/mdnsService/mdnsServiceListPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ class _MdnsServiceListPageState extends State<MdnsServiceListPage> {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
// backgroundColor: Provider.of<CustomTheme>(context).isLightTheme()
// ? CustomThemes.light.primaryColor
// : CustomThemes.dark.primaryColor,
centerTitle: true,
actions: _build_actions(),
),
Expand Down
15 changes: 9 additions & 6 deletions lib/pages/splashPage/splashPage.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -17,6 +18,7 @@ class LaunchState extends State<SplashPage> {

@override
void initState() {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,overlays:[SystemUiOverlay.top]);
super.initState();
_startRecordTime();
print('初始化启动页面');
Expand All @@ -25,6 +27,7 @@ class LaunchState extends State<SplashPage> {
@override
void dispose() {
super.dispose();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,overlays:SystemUiOverlay.values);
print('启动页面结束');
if (_countdownTimer.isActive) {
_countdownTimer.cancel();
Expand Down Expand Up @@ -53,13 +56,14 @@ class LaunchState extends State<SplashPage> {

@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: <Widget>[
Image.asset(launchImage, fit: BoxFit.fill),
Positioned.fill(child: Image.asset(launchImage, fit: BoxFit.fill)),
Positioned(
top: 30,
right: 30,
Expand Down Expand Up @@ -95,7 +99,6 @@ class LaunchState extends State<SplashPage> {
)
],
),
),
);
);
}
}
2 changes: 1 addition & 1 deletion lib/pages/user/profilePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _ProfilePageState extends State<ProfilePage> {
return Container(
color: Provider.of<CustomTheme>(context).isLightTheme()
? CustomThemes.light.primaryColor
: CustomThemes.dark.primaryColorLight,
: CustomThemes.dark.primaryColor,
height: 150.0,
child: Center(
child: Column(
Expand Down

0 comments on commit 2c137f9

Please sign in to comment.