portable service

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-11-10 10:27:13 +08:00
parent eb60ab0b79
commit 8e1545b432
46 changed files with 1217 additions and 72 deletions

View File

@@ -501,11 +501,46 @@ class _CmControlPanel extends StatelessWidget {
}
buildAuthorized(BuildContext context) {
final bool canElevate = bind.cmCanElevate();
final model = Provider.of<ServerModel>(context);
final offstage = !(canElevate && model.showElevation);
final width = offstage ? 200.0 : 100.0;
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Offstage(
offstage: offstage,
child: Ink(
width: width,
height: 40,
decoration: BoxDecoration(
color: Colors.green[700],
borderRadius: BorderRadius.circular(10)),
child: InkWell(
onTap: () =>
checkClickTime(client.id, () => handleElevate(context)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.security_sharp,
color: Colors.white,
),
Text(
translate("Elevate"),
style: TextStyle(color: Colors.white),
),
],
)),
),
),
Offstage(
offstage: offstage,
child: SizedBox(
width: 30,
)),
Ink(
width: 200,
width: width,
height: 40,
decoration: BoxDecoration(
color: Colors.redAccent, borderRadius: BorderRadius.circular(10)),
@@ -552,11 +587,50 @@ class _CmControlPanel extends StatelessWidget {
}
buildUnAuthorized(BuildContext context) {
final bool canElevate = bind.cmCanElevate();
final model = Provider.of<ServerModel>(context);
final offstage = !(canElevate && model.showElevation);
final width = offstage ? 100.0 : 85.0;
final spacerWidth = offstage ? 30.0 : 5.0;
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Offstage(
offstage: offstage,
child: Ink(
height: 40,
width: width,
decoration: BoxDecoration(
color: Colors.green[700],
borderRadius: BorderRadius.circular(10)),
child: InkWell(
onTap: () => checkClickTime(client.id, () {
handleAccept(context);
handleElevate(context);
windowManager.minimize();
}),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.security_sharp,
color: Colors.white,
),
Text(
translate("Accept"),
style: TextStyle(color: Colors.white),
),
],
)),
),
),
Offstage(
offstage: offstage,
child: SizedBox(
width: spacerWidth,
)),
Ink(
width: 100,
width: width,
height: 40,
decoration: BoxDecoration(
color: MyTheme.accent, borderRadius: BorderRadius.circular(10)),
@@ -576,10 +650,10 @@ class _CmControlPanel extends StatelessWidget {
)),
),
SizedBox(
width: 30,
width: spacerWidth,
),
Ink(
width: 100,
width: width,
height: 40,
decoration: BoxDecoration(
color: Colors.transparent,
@@ -611,6 +685,12 @@ class _CmControlPanel extends StatelessWidget {
model.sendLoginResponse(client, true);
}
void handleElevate(BuildContext context) {
final model = Provider.of<ServerModel>(context, listen: false);
model.setShowElevation(false);
bind.cmElevatePortable(connId: client.id);
}
void handleClose(BuildContext context) async {
await bind.cmRemoveDisconnectedConnection(connId: client.id);
if (await bind.cmGetClientsLength() == 0) {

View File

@@ -192,6 +192,9 @@ class FfiModel with ChangeNotifier {
}
} else if (name == 'alias') {
handleAliasChanged(evt);
} else if (name == 'show_elevation') {
final show = evt['show'].toString() == 'true';
parent.target?.serverModel.setShowElevation(show);
}
};
}

View File

@@ -27,6 +27,7 @@ class ServerModel with ChangeNotifier {
bool _inputOk = false;
bool _audioOk = false;
bool _fileOk = false;
bool _showElevation = true;
int _connectStatus = 0; // Rendezvous Server status
String _verificationMethod = "";
String _temporaryPasswordLength = "";
@@ -51,6 +52,8 @@ class ServerModel with ChangeNotifier {
bool get fileOk => _fileOk;
bool get showElevation => _showElevation;
int get connectStatus => _connectStatus;
String get verificationMethod {
@@ -530,6 +533,13 @@ class ServerModel with ChangeNotifier {
final index = _clients.indexWhere((client) => client.id == id);
tabController.jumpTo(index);
}
void setShowElevation(bool show) {
if (_showElevation != show) {
_showElevation = show;
notifyListeners();
}
}
}
class Client {