mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-05 21:27:49 +08:00
feat: accpet/disconnect
Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
parent
dcab45d8ab
commit
a580b98472
@ -106,9 +106,11 @@ class DesktopServerPage extends StatefulWidget implements PageShape {
|
|||||||
State<StatefulWidget> createState() => _DesktopServerPageState();
|
State<StatefulWidget> createState() => _DesktopServerPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DesktopServerPageState extends State<DesktopServerPage> {
|
class _DesktopServerPageState extends State<DesktopServerPage>
|
||||||
|
with AutomaticKeepAliveClientMixin {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
super.build(context);
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: gFFI.serverModel,
|
value: gFFI.serverModel,
|
||||||
child: Consumer<ServerModel>(
|
child: Consumer<ServerModel>(
|
||||||
@ -124,6 +126,9 @@ class _DesktopServerPageState extends State<DesktopServerPage> {
|
|||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get wantKeepAlive => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConnectionManager extends StatelessWidget {
|
class ConnectionManager extends StatelessWidget {
|
||||||
@ -131,20 +136,25 @@ class ConnectionManager extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final serverModel = Provider.of<ServerModel>(context);
|
final serverModel = Provider.of<ServerModel>(context);
|
||||||
// test case:
|
// test case:
|
||||||
// serverModel.clients.clear();
|
serverModel.clients.clear();
|
||||||
// serverModel.clients[0] = Client(false, false, "Readmi-M21sdfsdf", "123123123", true, false, false);
|
serverModel.clients[0] = Client(
|
||||||
return DefaultTabController(
|
false, false, "Readmi-M21sdfsdf", "123123123", true, false, false);
|
||||||
length: serverModel.clients.length,
|
return serverModel.clients.isEmpty
|
||||||
child: Column(
|
? Center(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Text(translate("Waiting")),
|
||||||
children: [
|
)
|
||||||
SizedBox(
|
: DefaultTabController(
|
||||||
height: kTextTabBarHeight,
|
length: serverModel.clients.length,
|
||||||
child: TabBar(
|
child: Column(
|
||||||
isScrollable: true,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
tabs: serverModel.clients.entries
|
children: [
|
||||||
.map((entry) => buildTab(entry))
|
SizedBox(
|
||||||
.toList(growable: false)),
|
height: kTextTabBarHeight,
|
||||||
|
child: TabBar(
|
||||||
|
isScrollable: true,
|
||||||
|
tabs: serverModel.clients.entries
|
||||||
|
.map((entry) => buildTab(entry))
|
||||||
|
.toList(growable: false)),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
@ -321,10 +331,12 @@ class _CmControlPanel extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return client.authorized ? buildAuthorized() : buildUnAuthorized();
|
return client.authorized
|
||||||
|
? buildAuthorized(context)
|
||||||
|
: buildUnAuthorized(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildAuthorized() {
|
buildAuthorized(BuildContext context) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -334,7 +346,7 @@ class _CmControlPanel extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.redAccent, borderRadius: BorderRadius.circular(10)),
|
color: Colors.redAccent, borderRadius: BorderRadius.circular(10)),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: handleDisconnect,
|
onTap: () => handleDisconnect(context),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -349,7 +361,7 @@ class _CmControlPanel extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildUnAuthorized() {
|
buildUnAuthorized(BuildContext context) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -359,7 +371,7 @@ class _CmControlPanel extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: MyTheme.accent, borderRadius: BorderRadius.circular(10)),
|
color: MyTheme.accent, borderRadius: BorderRadius.circular(10)),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: handleAccept,
|
onTap: () => handleAccept(context),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -381,7 +393,7 @@ class _CmControlPanel extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
border: Border.all(color: Colors.grey)),
|
border: Border.all(color: Colors.grey)),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: handleCancel,
|
onTap: () => handleDisconnect(context),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -396,11 +408,14 @@ class _CmControlPanel extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDisconnect() {}
|
void handleDisconnect(BuildContext context) {
|
||||||
|
bind.cmCloseConnection(connId: client.id);
|
||||||
|
}
|
||||||
|
|
||||||
void handleCancel() {}
|
void handleAccept(BuildContext context) {
|
||||||
|
final model = Provider.of<ServerModel>(context, listen: false);
|
||||||
void handleAccept() {}
|
model.sendLoginResponse(client, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PaddingCard extends StatelessWidget {
|
class PaddingCard extends StatelessWidget {
|
||||||
|
@ -97,9 +97,8 @@ class ServerModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
final res = await bind.mainCheckClientsLength(length: _clients.length);
|
final res = await bind.mainCheckClientsLength(length: _clients.length);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
// for test
|
debugPrint("clients not match!");
|
||||||
// debugPrint("clients not match!");
|
updateClientState(res);
|
||||||
// updateClientState(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePasswordModel();
|
updatePasswordModel();
|
||||||
|
Loading…
Reference in New Issue
Block a user