Skip to content

Commit

Permalink
refresh icon not visible when not using one-time password (rustdesk#9791
Browse files Browse the repository at this point in the history
)

Signed-off-by: 21pages <[email protected]>
  • Loading branch information
21pages authored Oct 31, 2024
1 parent 697dd87 commit f86c88b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
49 changes: 30 additions & 19 deletions flutter/lib/desktop/pages/desktop_home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,21 @@ class _DesktopHomePageState extends State<DesktopHomePage>
}

buildPasswordBoard(BuildContext context) {
final model = gFFI.serverModel;
return ChangeNotifierProvider.value(
value: gFFI.serverModel,
child: Consumer<ServerModel>(
builder: (context, model, child) {
return buildPasswordBoard2(context, model);
},
));
}

buildPasswordBoard2(BuildContext context, ServerModel model) {
RxBool refreshHover = false.obs;
RxBool editHover = false.obs;
final textColor = Theme.of(context).textTheme.titleLarge?.color;
final showOneTime = model.approveMode != 'click' &&
model.verificationMethod != kUsePermanentPassword;
return Container(
margin: EdgeInsets.only(left: 20.0, right: 16, top: 13, bottom: 13),
child: Row(
Expand Down Expand Up @@ -304,8 +315,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
Expanded(
child: GestureDetector(
onDoubleTap: () {
if (model.verificationMethod !=
kUsePermanentPassword) {
if (showOneTime) {
Clipboard.setData(
ClipboardData(text: model.serverPasswd.text));
showToast(translate("Copied"));
Expand All @@ -323,22 +333,23 @@ class _DesktopHomePageState extends State<DesktopHomePage>
),
),
),
AnimatedRotationWidget(
onPressed: () => bind.mainUpdateTemporaryPassword(),
child: Tooltip(
message: translate('Refresh Password'),
child: Obx(() => RotatedBox(
quarterTurns: 2,
child: Icon(
Icons.refresh,
color: refreshHover.value
? textColor
: Color(0xFFDDDDDD),
size: 22,
))),
),
onHover: (value) => refreshHover.value = value,
).marginOnly(right: 8, top: 4),
if (showOneTime)
AnimatedRotationWidget(
onPressed: () => bind.mainUpdateTemporaryPassword(),
child: Tooltip(
message: translate('Refresh Password'),
child: Obx(() => RotatedBox(
quarterTurns: 2,
child: Icon(
Icons.refresh,
color: refreshHover.value
? textColor
: Color(0xFFDDDDDD),
size: 22,
))),
),
onHover: (value) => refreshHover.value = value,
).marginOnly(right: 8, top: 4),
if (!bind.isDisableSettings())
InkWell(
child: Tooltip(
Expand Down
7 changes: 4 additions & 3 deletions flutter/lib/mobile/pages/server_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ class ServerInfo extends StatelessWidget {

@override
Widget build(BuildContext context) {
final isPermanent = model.verificationMethod == kUsePermanentPassword;
final serverModel = Provider.of<ServerModel>(context);

const Color colorPositive = Colors.green;
Expand Down Expand Up @@ -486,6 +485,8 @@ class ServerInfo extends StatelessWidget {
}
}

final showOneTime = serverModel.approveMode != 'click' &&
serverModel.verificationMethod != kUsePermanentPassword;
return PaddingCard(
title: translate('Your Device'),
child: Column(
Expand Down Expand Up @@ -523,10 +524,10 @@ class ServerInfo extends StatelessWidget {
]),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(
isPermanent ? '-' : model.serverPasswd.value.text,
!showOneTime ? '-' : model.serverPasswd.value.text,
style: textStyleValue,
),
isPermanent
!showOneTime
? SizedBox.shrink()
: Row(children: [
IconButton(
Expand Down
5 changes: 3 additions & 2 deletions src/ui/index.tis
Original file line number Diff line number Diff line change
Expand Up @@ -831,11 +831,12 @@ class PasswordEyeArea : Reactor.Component {
render() {
var method = handler.get_option('verification-method');
var mode= handler.get_option('approve-mode');
var value = mode == 'click' || method == 'use-permanent-password' ? "-" : password_cache[0];
var hide_one_time = mode == 'click' || method == 'use-permanent-password';
var value = hide_one_time ? "-" : password_cache[0];
return
<div .eye-area style="width: *">
<input|text @{this.input} readonly value={value} />
{svg_refresh_password}
{hide_one_time ? "" : svg_refresh_password}
</div>;
}

Expand Down

0 comments on commit f86c88b

Please sign in to comment.