feat: dark theme

Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
Kingtous
2022-07-29 16:47:24 +08:00
parent 6b99d4d82e
commit 608f02ea21
7 changed files with 97 additions and 49 deletions

View File

@@ -16,7 +16,6 @@ import '../../mobile/pages/home_page.dart';
import '../../mobile/pages/scan_page.dart';
import '../../mobile/pages/settings_page.dart';
import '../../models/model.dart';
import '../../models/peer_model.dart';
enum RemoteType { recently, favorite, discovered, addressBook }
@@ -60,7 +59,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
Widget build(BuildContext context) {
if (_idController.text.isEmpty) _idController.text = gFFI.getId();
return Container(
decoration: BoxDecoration(color: MyTheme.grayBg),
decoration: BoxDecoration(color: isDarkTheme() ? null : MyTheme.grayBg),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
@@ -83,7 +82,6 @@ class _ConnectionPageState extends State<ConnectionPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TabBar(
labelColor: Colors.black87,
isScrollable: true,
indicatorSize: TabBarIndicatorSize.label,
tabs: [
@@ -205,7 +203,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
width: 500,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 24),
decoration: BoxDecoration(
color: MyTheme.white,
color: isDarkTheme() ? null : MyTheme.white,
borderRadius: const BorderRadius.all(Radius.circular(13)),
),
child: Ink(
@@ -235,13 +233,11 @@ class _ConnectionPageState extends State<ConnectionPage> {
helperStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
color: MyTheme.dark,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 26,
letterSpacing: 0.2,
color: MyTheme.dark,
),
),
controller: _idController,
@@ -269,7 +265,6 @@ class _ConnectionPageState extends State<ConnectionPage> {
translate(
"Transfer File",
),
style: TextStyle(color: MyTheme.dark),
),
),
),
@@ -528,7 +523,6 @@ class _ConnectionPageState extends State<ConnectionPage> {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
side: BorderSide(color: MyTheme.grayBg)),
color: Colors.white,
child: Container(
width: 200,
height: double.infinity,

View File

@@ -10,6 +10,7 @@ import 'package:flutter_hbb/desktop/widgets/titlebar_widget.dart';
import 'package:flutter_hbb/models/model.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:url_launcher/url_launcher_string.dart';
@@ -64,7 +65,6 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
return ChangeNotifierProvider.value(
value: gFFI.serverModel,
child: Container(
decoration: BoxDecoration(color: MyTheme.white),
child: Column(
children: [
buildTip(context),
@@ -339,13 +339,24 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
super.dispose();
}
void changeTheme(String choice) async {
if (choice == "Y") {
Get.changeTheme(MyTheme.darkTheme);
} else {
Get.changeTheme(MyTheme.lightTheme);
}
Get.find<SharedPreferences>().setString("darkTheme", choice);
}
void onSelectMenu(String value) {
if (value.startsWith('enable-')) {
final option = gFFI.getOption(value);
gFFI.setOption(value, option == "N" ? "" : "N");
} else if (value.startsWith('allow-')) {
final option = gFFI.getOption(value);
gFFI.setOption(value, option == "Y" ? "" : "Y");
final choice = option == "Y" ? "" : "Y";
gFFI.setOption(value, choice);
changeTheme(choice);
} else if (value == "stop-service") {
final option = gFFI.getOption(value);
gFFI.setOption(value, option == "Y" ? "" : "Y");
@@ -367,9 +378,8 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
}
PopupMenuItem<String> genEnablePopupMenuItem(String label, String value) {
final isEnable = label.startsWith('enable-')
? gFFI.getOption(value) != "N"
: gFFI.getOption(value) != "Y";
final v = gFFI.getOption(value);
final isEnable = value.startsWith('enable-') ? v != "N" : v == "Y";
return PopupMenuItem(
child: Row(
children: [

View File

@@ -72,7 +72,7 @@ class _FileManagerPageState extends State<FileManagerPage>
return false;
},
child: Scaffold(
backgroundColor: MyTheme.grayBg,
backgroundColor: isDarkTheme() ? MyTheme.dark : MyTheme.grayBg,
body: Row(
children: [
Flexible(flex: 3, child: body(isLocal: true)),