feature:适配深色模式,现仅支持跟随系统

This commit is contained in:
hackycy
2020-07-01 16:29:17 +08:00
parent b3a96e8b1c
commit 4c11f6ed40
3 changed files with 75 additions and 21 deletions

View File

@@ -63,7 +63,9 @@ class _LoadingDialog extends State<NetLoadingDialog> {
height: 120.0,
child: new Container(
decoration: ShapeDecoration(
color: Colors.white,
color: Theme.of(context).brightness == Brightness.dark
? Colors.black
: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter_picgo/resources/theme_colors.dart';
import 'package:flutter_picgo/routers/application.dart';
import 'package:flutter_picgo/routers/routers.dart';
import 'package:flutter_picgo/utils/db_provider.dart';
@@ -12,7 +13,6 @@ void main() async {
}
class App extends StatelessWidget {
App() {
final router = new Router();
Routes.configureRoutes(router);
@@ -24,22 +24,8 @@ class App extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
theme: lightThemeData,
darkTheme: darkThemeData,
initialRoute: '/',
onGenerateRoute: Application.router.generator,
);

View File

@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
// Light Theme Color
const MaterialColor light = MaterialColor(lightPrimaryValue, <int, Color>{
50: Color(0xFFE9F2FD),
100: Color(0xFFC7E0F9),
200: Color(0xFFA2CBF5),
300: Color(0xFF7DB6F1),
400: Color(0xFF61A6EE),
500: Color(lightPrimaryValue),
600: Color(0xFF3E8EE9),
700: Color(0xFF3683E5),
800: Color(0xFF2E79E2),
900: Color(0xFF1F68DD),
});
const int lightPrimaryValue = 0xFF4596EB;
// Dark
const MaterialColor dark = MaterialColor(_darkPrimaryValue, <int, Color>{
50: Color(0xFFE2E3E3),
100: Color(0xFFB8B8B8),
200: Color(0xFF888989),
300: Color(0xFF58595A),
400: Color(0xFF353636),
500: Color(_darkPrimaryValue),
600: Color(0xFF0F1011),
700: Color(0xFF0C0D0E),
800: Color(0xFF0A0A0B),
900: Color(0xFF050506),
});
const int _darkPrimaryValue = 0xFF111213;
// accent
const MaterialColor accent = MaterialColor(_accentValue, <int, Color>{
50: Color(0xFFFCE9EC),
100: Color(0xFFF9C9D0),
200: Color(0xFFF5A5B1),
300: Color(0xFFF08192),
400: Color(0xFFED667A),
500: Color(_accentValue),
600: Color(0xFFE7445B),
700: Color(0xFFE43B51),
800: Color(0xFFE13347),
900: Color(0xFFDB2335),
});
const int _accentValue = 0xFFEA4B63;
// 主题
final ThemeData lightThemeData = ThemeData(
brightness: Brightness.light,
primarySwatch: light,
primaryColor: light,
accentColor: light,
);
final ThemeData darkThemeData = ThemeData(
brightness: Brightness.dark,
primarySwatch: dark,
primaryColor: dark,
accentColor: accent,
);