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
5625a061
Commit
5625a061
authored
Sep 21, 2022
by
csf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge master peer_tab_page.dart peer_widget.dart
parent
9284850d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
101 deletions
+115
-101
peer_tab_page.dart
flutter/lib/common/widgets/peer_tab_page.dart
+46
-42
peer_widget.dart
flutter/lib/common/widgets/peer_widget.dart
+69
-59
No files found.
flutter/lib/common/widgets/peer_tab_page.dart
View file @
5625a061
...
...
@@ -23,15 +23,31 @@ class _PeerTabPageState extends State<PeerTabPage>
@override
void
initState
()
{
()
async
{
await
bind
.
mainGetLocalOption
(
key:
'peer-tab-index'
).
then
((
value
)
{
if
(
value
==
''
)
return
;
final
tab
=
int
.
parse
(
value
);
_tabIndex
.
value
=
tab
;
_pageController
.
jumpToPage
(
tab
);
});
await
bind
.
mainGetLocalOption
(
key:
'peer-card-ui-type'
).
then
((
value
)
{
if
(
value
==
''
)
return
;
final
tab
=
int
.
parse
(
value
);
peerCardUiType
.
value
=
tab
==
PeerUiType
.
list
.
index
?
PeerUiType
.
list
:
PeerUiType
.
grid
;
});
}();
super
.
initState
();
}
// hard code for now
void
_handleTabSelection
(
int
index
)
{
Future
<
void
>
_handleTabSelection
(
int
index
)
async
{
// reset search text
peerSearchText
.
value
=
""
;
peerSearchTextController
.
clear
();
_tabIndex
.
value
=
index
;
await
bind
.
mainSetLocalOption
(
key:
'peer-tab-index'
,
value:
index
.
toString
());
_pageController
.
jumpToPage
(
index
);
switch
(
index
)
{
case
0
:
...
...
@@ -89,7 +105,7 @@ class _PeerTabPageState extends State<PeerTabPage>
shrinkWrap:
true
,
controller:
ScrollController
(),
children:
super
.
widget
.
tabs
.
asMap
().
entries
.
map
((
t
)
{
return
Obx
(()
=>
GestureDetector
(
return
Obx
(()
=>
InkWell
(
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
8
),
decoration:
BoxDecoration
(
...
...
@@ -111,7 +127,7 @@ class _PeerTabPageState extends State<PeerTabPage>
:
MyTheme
.
color
(
context
).
lightText
),
),
)),
onTap:
()
=>
_handleTabSelection
(
t
.
key
),
onTap:
()
async
=>
await
_handleTabSelection
(
t
.
key
),
));
}).
toList
());
}
...
...
@@ -120,7 +136,9 @@ class _PeerTabPageState extends State<PeerTabPage>
final
verticalMargin
=
isDesktop
?
12.0
:
6.0
;
return
Expanded
(
child:
PageView
(
physics:
const
BouncingScrollPhysics
(),
physics:
isDesktop
?
NeverScrollableScrollPhysics
()
:
BouncingScrollPhysics
(),
controller:
_pageController
,
children:
super
.
widget
.
children
,
onPageChanged:
(
to
)
=>
_tabIndex
.
value
=
to
)
...
...
@@ -130,44 +148,30 @@ class _PeerTabPageState extends State<PeerTabPage>
Widget
_createPeerViewTypeSwitch
(
BuildContext
context
)
{
final
activeDeco
=
BoxDecoration
(
color:
MyTheme
.
color
(
context
).
bg
);
return
Row
(
children:
[
Obx
(
()
=>
Container
(
padding:
const
EdgeInsets
.
all
(
4.0
),
decoration:
peerCardUiType
.
value
==
PeerUiType
.
grid
?
activeDeco
:
null
,
child:
InkWell
(
onTap:
()
{
peerCardUiType
.
value
=
PeerUiType
.
grid
;
},
child:
Icon
(
Icons
.
grid_view_rounded
,
size:
18
,
color:
peerCardUiType
.
value
==
PeerUiType
.
grid
?
MyTheme
.
color
(
context
).
text
:
MyTheme
.
color
(
context
).
lightText
,
)),
),
),
Obx
(
()
=>
Container
(
padding:
const
EdgeInsets
.
all
(
4.0
),
decoration:
peerCardUiType
.
value
==
PeerUiType
.
list
?
activeDeco
:
null
,
child:
InkWell
(
onTap:
()
{
peerCardUiType
.
value
=
PeerUiType
.
list
;
},
child:
Icon
(
Icons
.
list
,
size:
18
,
color:
peerCardUiType
.
value
==
PeerUiType
.
list
?
MyTheme
.
color
(
context
).
text
:
MyTheme
.
color
(
context
).
lightText
,
)),
),
),
],
children:
[
PeerUiType
.
grid
,
PeerUiType
.
list
]
.
map
((
type
)
=>
Obx
(
()
=>
Container
(
padding:
EdgeInsets
.
all
(
4.0
),
decoration:
peerCardUiType
.
value
==
type
?
activeDeco
:
null
,
child:
InkWell
(
onTap:
()
async
{
await
bind
.
mainSetLocalOption
(
key:
'peer-card-ui-type'
,
value:
type
.
index
.
toString
());
peerCardUiType
.
value
=
type
;
},
child:
Icon
(
type
==
PeerUiType
.
grid
?
Icons
.
grid_view_rounded
:
Icons
.
list
,
size:
18
,
color:
peerCardUiType
.
value
==
type
?
MyTheme
.
color
(
context
).
text
:
MyTheme
.
color
(
context
).
lightText
,
)),
),
))
.
toList
(),
);
}
}
...
...
flutter/lib/common/widgets/peer_widget.dart
View file @
5625a061
...
...
@@ -92,68 +92,78 @@ class _PeerWidgetState extends State<_PeerWidget> with WindowListener {
return
ChangeNotifierProvider
<
Peers
>(
create:
(
context
)
=>
widget
.
peers
,
child:
Consumer
<
Peers
>(
builder:
(
context
,
peers
,
child
)
=>
peers
.
peers
.
isEmpty
?
Center
(
child:
Text
(
translate
(
"Empty"
)),
)
:
DesktopScrollWrapper
(
scrollController:
_scrollController
,
child:
SingleChildScrollView
(
physics:
NeverScrollableScrollPhysics
(),
controller:
_scrollController
,
child:
ObxValue
<
RxString
>((
searchText
)
{
return
FutureBuilder
<
List
<
Peer
>>(
builder:
(
context
,
snapshot
)
{
if
(
snapshot
.
hasData
)
{
final
peers
=
snapshot
.
data
!;
final
cards
=
<
Widget
>[];
for
(
final
peer
in
peers
)
{
cards
.
add
(
Offstage
(
key:
ValueKey
(
"off
${peer.id}
"
),
offstage:
widget
.
offstageFunc
(
peer
),
child:
Obx
(
()
=>
SizedBox
(
width:
220
,
height:
peerCardUiType
.
value
==
PeerUiType
.
grid
?
140
:
42
,
child:
VisibilityDetector
(
key:
ValueKey
(
peer
.
id
),
onVisibilityChanged:
(
info
)
{
final
peerId
=
(
info
.
key
as
ValueKey
).
value
;
if
(
info
.
visibleFraction
>
0.00001
)
{
_curPeers
.
add
(
peerId
);
}
else
{
_curPeers
.
remove
(
peerId
);
}
_lastChangeTime
=
DateTime
.
now
();
},
child:
widget
.
peerCardWidgetFunc
(
peer
),
),
),
)));
}
return
Wrap
(
spacing:
space
,
runSpacing:
space
,
children:
cards
);
}
else
{
return
const
Center
(
child:
CircularProgressIndicator
(),
);
}
},
future:
matchPeers
(
searchText
.
value
,
peers
.
peers
),
);
},
peerSearchText
),
),
),
),
builder:
(
context
,
peers
,
child
)
=>
peers
.
peers
.
isEmpty
?
Center
(
child:
Text
(
translate
(
"Empty"
)),
)
:
_buildPeersView
(
peers
)),
);
}
Widget
_buildPeersView
(
Peers
peers
)
{
final
body
=
ObxValue
<
RxString
>((
searchText
)
{
return
FutureBuilder
<
List
<
Peer
>>(
builder:
(
context
,
snapshot
)
{
if
(
snapshot
.
hasData
)
{
final
peers
=
snapshot
.
data
!;
final
cards
=
<
Widget
>[];
for
(
final
peer
in
peers
)
{
final
visibilityChild
=
VisibilityDetector
(
key:
ValueKey
(
peer
.
id
),
onVisibilityChanged:
(
info
)
{
final
peerId
=
(
info
.
key
as
ValueKey
).
value
;
if
(
info
.
visibleFraction
>
0.00001
)
{
_curPeers
.
add
(
peerId
);
}
else
{
_curPeers
.
remove
(
peerId
);
}
_lastChangeTime
=
DateTime
.
now
();
},
child:
widget
.
peerCardWidgetFunc
(
peer
),
);
cards
.
add
(
Offstage
(
key:
ValueKey
(
"off
${peer.id}
"
),
offstage:
widget
.
offstageFunc
(
peer
),
child:
isDesktop
?
Obx
(
()
=>
SizedBox
(
width:
220
,
height:
peerCardUiType
.
value
==
PeerUiType
.
grid
?
140
:
42
,
child:
visibilityChild
,
),
)
:
SizedBox
(
width:
mobileWidth
,
child:
visibilityChild
)));
}
return
Wrap
(
spacing:
space
,
runSpacing:
space
,
children:
cards
);
}
else
{
return
const
Center
(
child:
CircularProgressIndicator
(),
);
}
},
future:
matchPeers
(
searchText
.
value
,
peers
.
peers
),
);
},
peerSearchText
);
if
(
isDesktop
)
{
return
DesktopScrollWrapper
(
scrollController:
_scrollController
,
child:
SingleChildScrollView
(
physics:
NeverScrollableScrollPhysics
(),
controller:
_scrollController
,
child:
body
),
);
}
else
{
return
SingleChildScrollView
(
physics:
BouncingScrollPhysics
(),
controller:
_scrollController
,
child:
body
,
);
}
}
// ignore: todo
// TODO: variables walk through async tasks?
void
_startCheckOnlines
()
{
...
...
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