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
b4e0101e
Commit
b4e0101e
authored
Sep 07, 2022
by
21pages
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync theme
Signed-off-by:
21pages
<
pages21@163.com
>
parent
17a7cbf7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
84 additions
and
18 deletions
+84
-18
cm_main.dart
flutter/lib/cm_main.dart
+1
-3
common.dart
flutter/lib/common.dart
+22
-8
consts.dart
flutter/lib/consts.dart
+2
-0
main.dart
flutter/lib/main.dart
+16
-5
flutter.rs
src/flutter.rs
+6
-0
flutter_ffi.rs
src/flutter_ffi.rs
+18
-1
ipc.rs
src/ipc.rs
+1
-0
cm.rs
src/ui/cm.rs
+4
-0
ui_cm_interface.rs
src/ui_cm_interface.rs
+5
-0
ui_interface.rs
src/ui_interface.rs
+9
-1
No files found.
flutter/lib/cm_main.dart
View file @
b4e0101e
...
...
@@ -24,7 +24,5 @@ void main(List<String> args) async {
gFFI
.
serverModel
.
clients
.
add
(
Client
(
3
,
false
,
false
,
"UserD"
,
"441123123"
,
true
,
false
,
false
));
runApp
(
GetMaterialApp
(
debugShowCheckedModeBanner:
false
,
theme:
MyTheme
.
initialTheme
(),
home:
DesktopServerPage
()));
debugShowCheckedModeBanner:
false
,
home:
DesktopServerPage
()));
}
flutter/lib/common.dart
View file @
b4e0101e
...
...
@@ -193,25 +193,40 @@ class MyTheme {
);
static
changeTo
(
bool
dark
)
{
Get
.
find
<
SharedPreferences
>().
setString
(
"darkTheme"
,
dark
?
"Y"
:
""
);
Get
.
changeTheme
(
dark
?
MyTheme
.
darkTheme
:
MyTheme
.
lightTheme
);
Get
.
forceAppUpdate
();
if
(
Get
.
isDarkMode
!=
dark
)
{
Get
.
find
<
SharedPreferences
>().
setString
(
"darkTheme"
,
dark
?
"Y"
:
""
);
Get
.
changeThemeMode
(
dark
?
ThemeMode
.
dark
:
ThemeMode
.
light
);
if
(
desktopType
==
DesktopType
.
main
)
{
bind
.
mainChangeTheme
(
dark:
dark
);
}
}
}
static
bool
_themeInitialed
=
false
;
static
Theme
Data
initialThem
e
({
bool
mainPage
=
false
})
{
static
Theme
Mode
initialThemeMod
e
({
bool
mainPage
=
false
})
{
bool
dark
;
// Brightnesss is always light on windows, Flutter 3.0.5
if
(
_themeInitialed
||
!
mainPage
||
Platform
.
isWindows
)
{
dark
=
isDarkTheme
(
);
dark
=
"Y"
==
Get
.
find
<
SharedPreferences
>().
getString
(
"darkTheme"
);
}
else
{
dark
=
WidgetsBinding
.
instance
.
platformDispatcher
.
platformBrightness
==
Brightness
.
dark
;
Get
.
find
<
SharedPreferences
>().
setString
(
"darkTheme"
,
dark
?
"Y"
:
""
);
}
_themeInitialed
=
true
;
return
dark
?
MyTheme
.
darkTheme
:
MyTheme
.
lightTheme
;
return
dark
?
ThemeMode
.
dark
:
ThemeMode
.
light
;
}
static
registerEventHandler
()
{
if
(
desktopType
!=
DesktopType
.
main
)
{
platformFFI
.
registerEventHandler
(
'theme'
,
'theme-
$desktopType
'
,
(
evt
)
{
String
?
dark
=
evt
[
'dark'
];
if
(
dark
!=
null
)
{
changeTo
(
dark
==
'true'
);
}
});
}
}
static
ColorThemeExtension
color
(
BuildContext
context
)
{
...
...
@@ -232,8 +247,7 @@ class ThemeModeNotifier {
}
bool
isDarkTheme
(
)
{
final
isDark
=
"Y"
==
Get
.
find
<
SharedPreferences
>().
getString
(
"darkTheme"
);
return
isDark
;
return
Get
.
isDarkMode
;
}
final
ButtonStyle
flatButtonStyle
=
TextButton
.
styleFrom
(
...
...
flutter/lib/consts.dart
View file @
b4e0101e
...
...
@@ -5,6 +5,8 @@ const String kAppTypeMain = "main";
const
String
kAppTypeDesktopRemote
=
"remote"
;
const
String
kAppTypeDesktopFileTransfer
=
"file transfer"
;
const
String
kAppTypeDesktopPortForward
=
"port forward"
;
const
String
kAppTypeDesktopRDP
=
"rdp"
;
const
String
kTabLabelHomePage
=
"Home"
;
const
String
kTabLabelSettingPage
=
"Settings"
;
...
...
flutter/lib/main.dart
View file @
b4e0101e
...
...
@@ -79,6 +79,7 @@ Future<void> initEnv(String appType) async {
await
initGlobalFFI
();
// await Firebase.initializeApp();
refreshCurrentUser
();
MyTheme
.
registerEventHandler
();
}
void
runMainApp
(
bool
startService
)
async
{
...
...
@@ -113,7 +114,9 @@ void runRemoteScreen(Map<String, dynamic> argument) async {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk - Remote Desktop'
,
theme:
MyTheme
.
initialTheme
(),
theme:
MyTheme
.
lightTheme
,
darkTheme:
MyTheme
.
darkTheme
,
themeMode:
MyTheme
.
initialThemeMode
(),
home:
DesktopRemoteScreen
(
params:
argument
,
),
...
...
@@ -131,7 +134,9 @@ void runFileTransferScreen(Map<String, dynamic> argument) async {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk - File Transfer'
,
theme:
MyTheme
.
initialTheme
(),
theme:
MyTheme
.
lightTheme
,
darkTheme:
MyTheme
.
darkTheme
,
themeMode:
MyTheme
.
initialThemeMode
(),
home:
DesktopFileTransferScreen
(
params:
argument
),
navigatorObservers:
[
// FirebaseAnalyticsObserver(analytics: analytics),
...
...
@@ -148,7 +153,9 @@ void runPortForwardScreen(Map<String, dynamic> argument) async {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk - Port Forward'
,
theme:
MyTheme
.
initialTheme
(),
theme:
MyTheme
.
lightTheme
,
darkTheme:
MyTheme
.
darkTheme
,
themeMode:
MyTheme
.
initialThemeMode
(),
home:
DesktopPortForwardScreen
(
params:
argument
),
navigatorObservers:
[
// FirebaseAnalyticsObserver(analytics: analytics),
...
...
@@ -172,7 +179,9 @@ void runConnectionManagerScreen() async {
]);
runApp
(
GetMaterialApp
(
debugShowCheckedModeBanner:
false
,
theme:
MyTheme
.
initialTheme
(),
theme:
MyTheme
.
lightTheme
,
darkTheme:
MyTheme
.
darkTheme
,
themeMode:
MyTheme
.
initialThemeMode
(),
home:
DesktopServerPage
(),
builder:
_keepScaleBuilder
()));
}
...
...
@@ -225,7 +234,9 @@ class _AppState extends State<App> {
navigatorKey:
globalKey
,
debugShowCheckedModeBanner:
false
,
title:
'RustDesk'
,
theme:
MyTheme
.
initialTheme
(
mainPage:
true
),
theme:
MyTheme
.
lightTheme
,
darkTheme:
MyTheme
.
darkTheme
,
themeMode:
MyTheme
.
initialThemeMode
(
mainPage:
true
),
home:
isDesktop
?
const
DesktopTabPage
()
:
!
isAndroid
...
...
src/flutter.rs
View file @
b4e0101e
...
...
@@ -17,6 +17,8 @@ use crate::{client::*, flutter_ffi::EventToUI};
pub
(
super
)
const
APP_TYPE_MAIN
:
&
str
=
"main"
;
pub
(
super
)
const
APP_TYPE_DESKTOP_REMOTE
:
&
str
=
"remote"
;
pub
(
super
)
const
APP_TYPE_DESKTOP_FILE_TRANSFER
:
&
str
=
"file transfer"
;
pub
(
super
)
const
APP_TYPE_DESKTOP_PORT_FORWARD
:
&
str
=
"port forward"
;
pub
(
super
)
const
APP_TYPE_DESKTOP_RDP
:
&
str
=
"rdp"
;
lazy_static
::
lazy_static!
{
pub
static
ref
SESSIONS
:
RwLock
<
HashMap
<
String
,
Session
<
FlutterHandler
>>>
=
Default
::
default
();
...
...
@@ -376,6 +378,10 @@ pub mod connection_manager {
vec!
[(
"id"
,
&
id
.to_string
()),
(
"text"
,
&
text
)],
);
}
fn
change_theme
(
&
self
,
dark
:
bool
)
{
self
.push_event
(
"theme"
,
vec!
[(
"dark"
,
&
dark
.to_string
())]);
}
}
impl
FlutterHandler
{
...
...
src/flutter_ffi.rs
View file @
b4e0101e
...
...
@@ -23,7 +23,7 @@ use crate::ui_interface::{
get_app_name
,
get_async_job_status
,
get_connect_status
,
get_fav
,
get_id
,
get_lan_peers
,
get_langs
,
get_license
,
get_local_option
,
get_mouse_time
,
get_option
,
get_options
,
get_peer
,
get_peer_option
,
get_socks
,
get_sound_inputs
,
get_uuid
,
get_version
,
has_hwcodec
,
has_rendezvous_service
,
post_request
,
set_local_option
,
set_option
,
set_options
,
has_rendezvous_service
,
post_request
,
se
nd_to_cm
,
se
t_local_option
,
set_option
,
set_options
,
set_peer_option
,
set_permanent_password
,
set_socks
,
store_fav
,
test_if_valid_server
,
update_temporary_password
,
using_public_server
,
};
...
...
@@ -659,6 +659,23 @@ pub fn main_load_lan_peers() {
};
}
pub
fn
main_change_theme
(
dark
:
bool
)
{
let
apps
=
vec!
[
flutter
::
APP_TYPE_DESKTOP_REMOTE
,
flutter
::
APP_TYPE_DESKTOP_FILE_TRANSFER
,
flutter
::
APP_TYPE_DESKTOP_PORT_FORWARD
,
flutter
::
APP_TYPE_DESKTOP_RDP
,
];
for
app
in
apps
{
if
let
Some
(
s
)
=
flutter
::
GLOBAL_EVENT_STREAM
.read
()
.unwrap
()
.get
(
app
)
{
let
data
=
HashMap
::
from
([(
"name"
,
"theme"
.to_owned
()),
(
"dark"
,
dark
.to_string
())]);
s
.add
(
serde_json
::
ser
::
to_string
(
&
data
)
.unwrap_or
(
""
.to_owned
()));
};
}
send_to_cm
(
&
crate
::
ipc
::
Data
::
Theme
(
dark
));
}
pub
fn
session_add_port_forward
(
id
:
String
,
local_port
:
i32
,
...
...
src/ipc.rs
View file @
b4e0101e
...
...
@@ -182,6 +182,7 @@ pub enum Data {
#[cfg(not(any(target_os
=
"android"
,
target_os
=
"ios"
,
feature
=
"cli"
)))]
Mouse
(
DataMouse
),
Control
(
DataControl
),
Theme
(
bool
),
Empty
,
}
...
...
src/ui/cm.rs
View file @
b4e0101e
...
...
@@ -47,6 +47,10 @@ impl InvokeUiCM for SciterHandler {
fn
new_message
(
&
self
,
id
:
i32
,
text
:
String
)
{
self
.call
(
"newMessage"
,
&
make_args!
(
id
,
text
));
}
fn
change_theme
(
&
self
,
_dark
:
bool
)
{
// TODO
}
}
impl
SciterHandler
{
...
...
src/ui_cm_interface.rs
View file @
b4e0101e
...
...
@@ -60,6 +60,8 @@ pub trait InvokeUiCM: Send + Clone + 'static + Sized {
fn
remove_connection
(
&
self
,
id
:
i32
);
fn
new_message
(
&
self
,
id
:
i32
,
text
:
String
);
fn
change_theme
(
&
self
,
dark
:
bool
);
}
impl
<
T
:
InvokeUiCM
>
Deref
for
ConnectionManager
<
T
>
{
...
...
@@ -280,6 +282,9 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
.send
(
ClipboardFileData
::
Enable
((
conn_id
,
enabled
)))
.ok
();
}
Data
::
Theme
(
dark
)
=>
{
cm
.change_theme
(
dark
);
}
_
=>
{
}
...
...
src/ui_interface.rs
View file @
b4e0101e
...
...
@@ -373,7 +373,8 @@ pub fn get_mouse_time() -> f64 {
}
pub
fn
check_mouse_time
()
{
#[cfg(not(any(target_os
=
"android"
,
target_os
=
"ios"
)))]
{
#[cfg(not(any(target_os
=
"android"
,
target_os
=
"ios"
)))]
{
let
sender
=
SENDER
.lock
()
.unwrap
();
allow_err!
(
sender
.send
(
ipc
::
Data
::
MouseMoveTime
(
0
)));
}
...
...
@@ -779,6 +780,13 @@ pub(crate) async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedRe
}
}
#[tokio
::
main(flavor
=
"current_thread"
)]
pub
(
crate
)
async
fn
send_to_cm
(
data
:
&
ipc
::
Data
)
{
if
let
Ok
(
mut
c
)
=
ipc
::
connect
(
1000
,
"_cm"
)
.await
{
c
.send
(
data
)
.await
.ok
();
}
}
const
INVALID_FORMAT
:
&
'static
str
=
"Invalid format"
;
const
UNKNOWN_ERROR
:
&
'static
str
=
"Unknown error"
;
...
...
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