Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rustdesk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李朝发
rustdesk
Commits
17a7cbf7
Commit
17a7cbf7
authored
Sep 06, 2022
by
21pages
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
follow system theme at startup and changing
Signed-off-by:
21pages
<
pages21@163.com
>
parent
a3c1e5dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
19 deletions
+60
-19
cm_main.dart
flutter/lib/cm_main.dart
+1
-1
common.dart
flutter/lib/common.dart
+30
-0
desktop_setting_page.dart
flutter/lib/desktop/pages/desktop_setting_page.dart
+4
-7
desktop_tab_page.dart
flutter/lib/desktop/pages/desktop_tab_page.dart
+0
-1
main.dart
flutter/lib/main.dart
+25
-10
No files found.
flutter/lib/cm_main.dart
View file @
17a7cbf7
...
...
@@ -25,6 +25,6 @@ void main(List<String> args) async {
.
add
(
Client
(
3
,
false
,
false
,
"UserD"
,
"441123123"
,
true
,
false
,
false
));
runApp
(
GetMaterialApp
(
debugShowCheckedModeBanner:
false
,
theme:
getCurrent
Theme
(),
theme:
MyTheme
.
initial
Theme
(),
home:
DesktopServerPage
()));
}
flutter/lib/common.dart
View file @
17a7cbf7
...
...
@@ -192,6 +192,28 @@ class MyTheme {
],
);
static
changeTo
(
bool
dark
)
{
Get
.
find
<
SharedPreferences
>().
setString
(
"darkTheme"
,
dark
?
"Y"
:
""
);
Get
.
changeTheme
(
dark
?
MyTheme
.
darkTheme
:
MyTheme
.
lightTheme
);
Get
.
forceAppUpdate
();
}
static
bool
_themeInitialed
=
false
;
static
ThemeData
initialTheme
({
bool
mainPage
=
false
})
{
bool
dark
;
// Brightnesss is always light on windows, Flutter 3.0.5
if
(
_themeInitialed
||
!
mainPage
||
Platform
.
isWindows
)
{
dark
=
isDarkTheme
();
}
else
{
dark
=
WidgetsBinding
.
instance
.
platformDispatcher
.
platformBrightness
==
Brightness
.
dark
;
Get
.
find
<
SharedPreferences
>().
setString
(
"darkTheme"
,
dark
?
"Y"
:
""
);
}
_themeInitialed
=
true
;
return
dark
?
MyTheme
.
darkTheme
:
MyTheme
.
lightTheme
;
}
static
ColorThemeExtension
color
(
BuildContext
context
)
{
return
Theme
.
of
(
context
).
extension
<
ColorThemeExtension
>()!;
}
...
...
@@ -201,6 +223,14 @@ class MyTheme {
}
}
class
ThemeModeNotifier
{
final
ValueNotifier
<
Brightness
>
brightness
;
ThemeModeNotifier
(
this
.
brightness
);
changeThemeBrightness
({
required
Brightness
brightness
})
{
this
.
brightness
.
value
=
brightness
;
}
}
bool
isDarkTheme
(
)
{
final
isDark
=
"Y"
==
Get
.
find
<
SharedPreferences
>().
getString
(
"darkTheme"
);
return
isDark
;
...
...
flutter/lib/desktop/pages/desktop_setting_page.dart
View file @
17a7cbf7
...
...
@@ -224,21 +224,18 @@ class _UserInterfaceState extends State<_UserInterface>
}
Widget
theme
()
{
var
change
=
()
{
bool
dark
=
!
isDarkTheme
();
Get
.
changeTheme
(
dark
?
MyTheme
.
darkTheme
:
MyTheme
.
lightTheme
);
Get
.
find
<
SharedPreferences
>().
setString
(
"darkTheme"
,
dark
?
"Y"
:
""
);
Get
.
forceAppUpdate
();
};
change
()
{
MyTheme
.
changeTo
(!
isDarkTheme
());
}
return
GestureDetector
(
onTap:
change
,
child:
Row
(
children:
[
Checkbox
(
value:
isDarkTheme
(),
onChanged:
(
_
)
=>
change
()),
Expanded
(
child:
Text
(
translate
(
'Dark Theme'
))),
],
).
marginOnly
(
left:
_kCheckBoxLeftMargin
),
onTap:
change
,
);
}
}
...
...
flutter/lib/desktop/pages/desktop_tab_page.dart
View file @
17a7cbf7
...
...
@@ -33,7 +33,6 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
@override
Widget
build
(
BuildContext
context
)
{
final
dark
=
isDarkTheme
();
RxBool
fullscreen
=
false
.
obs
;
Get
.
put
(
fullscreen
,
tag:
'fullscreen'
);
return
Obx
(()
=>
DragToResizeArea
(
...
...
flutter/lib/main.dart
View file @
17a7cbf7
...
...
@@ -71,10 +71,6 @@ Future<Null> main(List<String> args) async {
}
}
ThemeData
getCurrentTheme
(
)
{
return
isDarkTheme
()
?
MyTheme
.
darkTheme
:
MyTheme
.
lightTheme
;
}
Future
<
void
>
initEnv
(
String
appType
)
async
{
await
platformFFI
.
init
(
appType
);
// global FFI, use this **ONLY** for global configuration
...
...
@@ -117,7 +113,7 @@ void runRemoteScreen(Map<String, dynamic> argument) async {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk - Remote Desktop'
,
theme:
getCurrent
Theme
(),
theme:
MyTheme
.
initial
Theme
(),
home:
DesktopRemoteScreen
(
params:
argument
,
),
...
...
@@ -135,7 +131,7 @@ void runFileTransferScreen(Map<String, dynamic> argument) async {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk - File Transfer'
,
theme:
getCurrent
Theme
(),
theme:
MyTheme
.
initial
Theme
(),
home:
DesktopFileTransferScreen
(
params:
argument
),
navigatorObservers:
[
// FirebaseAnalyticsObserver(analytics: analytics),
...
...
@@ -152,7 +148,7 @@ void runPortForwardScreen(Map<String, dynamic> argument) async {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk - Port Forward'
,
theme:
getCurrent
Theme
(),
theme:
MyTheme
.
initial
Theme
(),
home:
DesktopPortForwardScreen
(
params:
argument
),
navigatorObservers:
[
// FirebaseAnalyticsObserver(analytics: analytics),
...
...
@@ -176,7 +172,7 @@ void runConnectionManagerScreen() async {
]);
runApp
(
GetMaterialApp
(
debugShowCheckedModeBanner:
false
,
theme:
getCurrent
Theme
(),
theme:
MyTheme
.
initial
Theme
(),
home:
DesktopServerPage
(),
builder:
_keepScaleBuilder
()));
}
...
...
@@ -191,7 +187,26 @@ WindowOptions getHiddenTitleBarWindowOptions(Size size) {
);
}
class
App
extends
StatelessWidget
{
class
App
extends
StatefulWidget
{
@override
State
<
App
>
createState
()
=>
_AppState
();
}
class
_AppState
extends
State
<
App
>
{
@override
void
initState
()
{
super
.
initState
();
WidgetsBinding
.
instance
.
window
.
onPlatformBrightnessChanged
=
()
{
WidgetsBinding
.
instance
.
handlePlatformBrightnessChanged
();
var
system
=
WidgetsBinding
.
instance
.
platformDispatcher
.
platformBrightness
;
var
current
=
isDarkTheme
()
?
Brightness
.
dark
:
Brightness
.
light
;
if
(
current
!=
system
)
{
MyTheme
.
changeTo
(
system
==
Brightness
.
dark
);
}
};
}
@override
Widget
build
(
BuildContext
context
)
{
// final analytics = FirebaseAnalytics.instance;
...
...
@@ -210,7 +225,7 @@ class App extends StatelessWidget {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk'
,
theme:
getCurrentTheme
(
),
theme:
MyTheme
.
initialTheme
(
mainPage:
true
),
home:
isDesktop
?
const
DesktopTabPage
()
:
!
isAndroid
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment