mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
opt password sync, opt ab widgets (#7582)
* Opt sync conctrl with password source, add some comments * For sync from recent, legacy ab remove forceRelay, rdpPort, rdpUsername, because it's not used, personal ab add sync hash * Opt style of add Id dialog Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -87,7 +87,10 @@ class _AddressBookState extends State<AddressBook> {
|
||||
child: Column(
|
||||
children: [
|
||||
_buildAbDropdown(),
|
||||
_buildTagHeader().marginOnly(left: 8.0, right: 0),
|
||||
_buildTagHeader().marginOnly(
|
||||
left: 8.0,
|
||||
right: gFFI.abModel.legacyMode.value ? 8.0 : 0,
|
||||
top: gFFI.abModel.legacyMode.value ? 8.0 : 0),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
@@ -415,6 +418,7 @@ class _AddressBookState extends State<AddressBook> {
|
||||
return;
|
||||
}
|
||||
var isInProgress = false;
|
||||
var passwordVisible = false;
|
||||
IDTextEditingController idController = IDTextEditingController(text: '');
|
||||
TextEditingController aliasController = TextEditingController(text: '');
|
||||
TextEditingController passwordController = TextEditingController(text: '');
|
||||
@@ -460,6 +464,24 @@ class _AddressBookState extends State<AddressBook> {
|
||||
}
|
||||
|
||||
double marginBottom = 4;
|
||||
|
||||
row({required Widget lable, required Widget input}) {
|
||||
return Row(
|
||||
children: [
|
||||
!isMobile
|
||||
? ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 100),
|
||||
child: lable.marginOnly(right: 10))
|
||||
: SizedBox.shrink(),
|
||||
Expanded(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 200),
|
||||
child: input),
|
||||
),
|
||||
],
|
||||
).marginOnly(bottom: !isMobile ? 8 : 0);
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Add ID")),
|
||||
content: Column(
|
||||
@@ -467,75 +489,90 @@ class _AddressBookState extends State<AddressBook> {
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'*',
|
||||
style: TextStyle(color: Colors.red, fontSize: 14),
|
||||
),
|
||||
Text(
|
||||
'ID',
|
||||
style: style,
|
||||
),
|
||||
],
|
||||
),
|
||||
).marginOnly(bottom: marginBottom),
|
||||
TextField(
|
||||
controller: idController,
|
||||
inputFormatters: [IDTextInputFormatter()],
|
||||
decoration:
|
||||
InputDecoration(errorText: errorMsg, errorMaxLines: 5),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
row(
|
||||
lable: Row(
|
||||
children: [
|
||||
Text(
|
||||
'*',
|
||||
style: TextStyle(color: Colors.red, fontSize: 14),
|
||||
),
|
||||
Text(
|
||||
'ID',
|
||||
style: style,
|
||||
),
|
||||
],
|
||||
),
|
||||
input: TextField(
|
||||
controller: idController,
|
||||
inputFormatters: [IDTextInputFormatter()],
|
||||
decoration: InputDecoration(
|
||||
labelText: !isMobile ? null : translate('ID'),
|
||||
errorText: errorMsg,
|
||||
errorMaxLines: 5),
|
||||
)),
|
||||
row(
|
||||
lable: Text(
|
||||
translate('Alias'),
|
||||
style: style,
|
||||
),
|
||||
).marginOnly(top: 8, bottom: marginBottom),
|
||||
TextField(
|
||||
controller: aliasController,
|
||||
input: TextField(
|
||||
controller: aliasController,
|
||||
decoration: InputDecoration(
|
||||
labelText: !isMobile ? null : translate('Alias'),
|
||||
)),
|
||||
),
|
||||
if (isCurrentAbShared)
|
||||
row(
|
||||
lable: Text(
|
||||
translate('Password'),
|
||||
style: style,
|
||||
),
|
||||
input: TextField(
|
||||
controller: passwordController,
|
||||
obscureText: !passwordVisible,
|
||||
decoration: InputDecoration(
|
||||
labelText: !isMobile ? null : translate('Password'),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
passwordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: MyTheme.lightTheme.primaryColor),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
passwordVisible = !passwordVisible;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (gFFI.abModel.currentAbTags.isNotEmpty)
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
translate('Password'),
|
||||
translate('Tags'),
|
||||
style: style,
|
||||
),
|
||||
).marginOnly(top: 8, bottom: marginBottom),
|
||||
if (isCurrentAbShared)
|
||||
TextField(
|
||||
controller: passwordController,
|
||||
obscureText: true,
|
||||
if (gFFI.abModel.currentAbTags.isNotEmpty)
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Wrap(
|
||||
children: tags
|
||||
.map((e) => AddressBookTag(
|
||||
name: e,
|
||||
tags: selectedTag,
|
||||
onTap: () {
|
||||
if (selectedTag.contains(e)) {
|
||||
selectedTag.remove(e);
|
||||
} else {
|
||||
selectedTag.add(e);
|
||||
}
|
||||
},
|
||||
showActionMenu: false))
|
||||
.toList(growable: false),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
translate('Tags'),
|
||||
style: style,
|
||||
),
|
||||
).marginOnly(top: 8, bottom: marginBottom),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Wrap(
|
||||
children: tags
|
||||
.map((e) => AddressBookTag(
|
||||
name: e,
|
||||
tags: selectedTag,
|
||||
onTap: () {
|
||||
if (selectedTag.contains(e)) {
|
||||
selectedTag.remove(e);
|
||||
} else {
|
||||
selectedTag.add(e);
|
||||
}
|
||||
},
|
||||
showActionMenu: false))
|
||||
.toList(growable: false),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
|
||||
@@ -1918,11 +1918,9 @@ void addPeersToAbDialog(
|
||||
Future<bool> addTo(String abname) async {
|
||||
final mapList = peers.map((e) {
|
||||
var json = e.toJson();
|
||||
// remove shared password when add to other address book
|
||||
// remove password when add to another address book to avoid re-share
|
||||
json.remove('password');
|
||||
if (gFFI.abModel.addressbooks[abname]?.isPersonal() != true) {
|
||||
json.remove('hash');
|
||||
}
|
||||
json.remove('hash');
|
||||
return json;
|
||||
}).toList();
|
||||
final errMsg = await gFFI.abModel.addPeersTo(mapList, abname);
|
||||
@@ -1986,6 +1984,7 @@ void addPeersToAbDialog(
|
||||
content: Obx(() => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// https://github.com/flutter/flutter/issues/145081
|
||||
DropdownMenu(
|
||||
initialSelection: currentName.value,
|
||||
onSelected: (value) {
|
||||
@@ -2026,18 +2025,23 @@ void addPeersToAbDialog(
|
||||
}
|
||||
|
||||
void setSharedAbPasswordDialog(String abName, Peer peer) {
|
||||
TextEditingController controller = TextEditingController(text: peer.password);
|
||||
TextEditingController controller = TextEditingController(text: '');
|
||||
RxBool isInProgress = false.obs;
|
||||
RxBool isInputEmpty = true.obs;
|
||||
bool passwordVisible = false;
|
||||
controller.addListener(() {
|
||||
isInputEmpty.value = controller.text.isEmpty;
|
||||
});
|
||||
gFFI.dialogManager.show((setState, close, context) {
|
||||
submit() async {
|
||||
change(String password) async {
|
||||
isInProgress.value = true;
|
||||
bool res = await gFFI.abModel
|
||||
.changeSharedPassword(abName, peer.id, controller.text);
|
||||
close();
|
||||
bool res =
|
||||
await gFFI.abModel.changeSharedPassword(abName, peer.id, password);
|
||||
isInProgress.value = false;
|
||||
if (res) {
|
||||
showToast(translate('Successful'));
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
cancel() {
|
||||
@@ -2049,22 +2053,38 @@ void setSharedAbPasswordDialog(String abName, Peer peer) {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.key, color: MyTheme.accent),
|
||||
Text(translate('Set shared password')).paddingOnly(left: 10),
|
||||
Text(translate(peer.password.isEmpty
|
||||
? 'Set shared password'
|
||||
: 'Change Password'))
|
||||
.paddingOnly(left: 10),
|
||||
],
|
||||
),
|
||||
content: Obx(() => Column(children: [
|
||||
TextField(
|
||||
controller: controller,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
obscureText: !passwordVisible,
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
passwordVisible ? Icons.visibility : Icons.visibility_off,
|
||||
color: MyTheme.lightTheme.primaryColor),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
passwordVisible = !passwordVisible;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(children: [
|
||||
Icon(Icons.info, color: Colors.amber).marginOnly(right: 4),
|
||||
Text(
|
||||
translate('share_warning_tip'),
|
||||
style: TextStyle(fontSize: 12),
|
||||
)
|
||||
]).marginSymmetric(vertical: 10),
|
||||
if (!gFFI.abModel.current.isPersonal())
|
||||
Row(children: [
|
||||
Icon(Icons.info, color: Colors.amber).marginOnly(right: 4),
|
||||
Text(
|
||||
translate('share_warning_tip'),
|
||||
style: TextStyle(fontSize: 12),
|
||||
)
|
||||
]).marginSymmetric(vertical: 10),
|
||||
// NOT use Offstage to wrap LinearProgressIndicator
|
||||
isInProgress.value ? const LinearProgressIndicator() : Offstage()
|
||||
])),
|
||||
@@ -2075,13 +2095,22 @@ void setSharedAbPasswordDialog(String abName, Peer peer) {
|
||||
onPressed: cancel,
|
||||
isOutline: true,
|
||||
),
|
||||
dialogButton(
|
||||
"OK",
|
||||
icon: Icon(Icons.done_rounded),
|
||||
onPressed: submit,
|
||||
),
|
||||
if (peer.password.isNotEmpty)
|
||||
dialogButton(
|
||||
"Remove",
|
||||
icon: Icon(Icons.delete_outline_rounded),
|
||||
onPressed: () => change(''),
|
||||
buttonStyle: ButtonStyle(
|
||||
backgroundColor: MaterialStatePropertyAll(Colors.red)),
|
||||
),
|
||||
Obx(() => dialogButton(
|
||||
"OK",
|
||||
icon: Icon(Icons.done_rounded),
|
||||
onPressed:
|
||||
isInputEmpty.value ? null : () => change(controller.text),
|
||||
)),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onSubmit: isInputEmpty.value ? null : () => change(controller.text),
|
||||
onCancel: cancel,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -139,21 +139,30 @@ class _PeerCardState extends State<_PeerCard>
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: str2color('${peer.id}${peer.platform}', 0x7f),
|
||||
borderRadius: isMobile
|
||||
? BorderRadius.circular(_tileRadius)
|
||||
: BorderRadius.only(
|
||||
topLeft: Radius.circular(_tileRadius),
|
||||
bottomLeft: Radius.circular(_tileRadius),
|
||||
decoration: BoxDecoration(
|
||||
color: str2color('${peer.id}${peer.platform}', 0x7f),
|
||||
borderRadius: isMobile
|
||||
? BorderRadius.circular(_tileRadius)
|
||||
: BorderRadius.only(
|
||||
topLeft: Radius.circular(_tileRadius),
|
||||
bottomLeft: Radius.circular(_tileRadius),
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
width: isMobile ? 50 : 42,
|
||||
height: isMobile ? 50 : null,
|
||||
child: Stack(
|
||||
children: [
|
||||
getPlatformImage(peer.platform, size: isMobile ? 38 : 30)
|
||||
.paddingAll(6),
|
||||
if (_shouldBuildPasswordIcon(peer))
|
||||
Positioned(
|
||||
top: 1,
|
||||
left: 1,
|
||||
child: Icon(Icons.key, size: 6, color: Colors.white),
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
width: isMobile ? 50 : 42,
|
||||
height: isMobile ? 50 : null,
|
||||
child: getPlatformImage(peer.platform, size: isMobile ? 38 : 30)
|
||||
.paddingAll(6),
|
||||
),
|
||||
],
|
||||
)),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -216,12 +225,6 @@ class _PeerCardState extends State<_PeerCard>
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
if (_shouldBuildPasswordIcon(peer))
|
||||
Positioned(
|
||||
top: 2,
|
||||
left: isMobile ? 60 : 50,
|
||||
child: Icon(Icons.key, size: 12),
|
||||
),
|
||||
if (colors.isNotEmpty)
|
||||
Positioned(
|
||||
top: 2,
|
||||
@@ -329,7 +332,7 @@ class _PeerCardState extends State<_PeerCard>
|
||||
Positioned(
|
||||
top: 4,
|
||||
left: 12,
|
||||
child: Icon(Icons.key, size: 12),
|
||||
child: Icon(Icons.key, size: 12, color: Colors.white),
|
||||
),
|
||||
if (colors.isNotEmpty)
|
||||
Positioned(
|
||||
@@ -1102,7 +1105,8 @@ class AddressBookPeerCard extends BasePeerCard {
|
||||
MenuEntryBase<String> _changeSharedAbPassword() {
|
||||
return MenuEntryButton<String>(
|
||||
childBuilder: (TextStyle? style) => Text(
|
||||
translate('Set shared password'),
|
||||
translate(
|
||||
peer.password.isEmpty ? 'Set shared password' : 'Change Password'),
|
||||
style: style,
|
||||
),
|
||||
proc: () {
|
||||
|
||||
Reference in New Issue
Block a user