refresh icon not visible when not using one-time password (#9791)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-10-31 10:11:42 +08:00 committed by GitHub
parent 697dd87383
commit f86c88b3d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 24 deletions

View File

@ -272,10 +272,21 @@ class _DesktopHomePageState extends State<DesktopHomePage>
} }
buildPasswordBoard(BuildContext context) { 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 refreshHover = false.obs;
RxBool editHover = false.obs; RxBool editHover = false.obs;
final textColor = Theme.of(context).textTheme.titleLarge?.color; final textColor = Theme.of(context).textTheme.titleLarge?.color;
final showOneTime = model.approveMode != 'click' &&
model.verificationMethod != kUsePermanentPassword;
return Container( return Container(
margin: EdgeInsets.only(left: 20.0, right: 16, top: 13, bottom: 13), margin: EdgeInsets.only(left: 20.0, right: 16, top: 13, bottom: 13),
child: Row( child: Row(
@ -304,8 +315,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onDoubleTap: () { onDoubleTap: () {
if (model.verificationMethod != if (showOneTime) {
kUsePermanentPassword) {
Clipboard.setData( Clipboard.setData(
ClipboardData(text: model.serverPasswd.text)); ClipboardData(text: model.serverPasswd.text));
showToast(translate("Copied")); showToast(translate("Copied"));
@ -323,6 +333,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
), ),
), ),
), ),
if (showOneTime)
AnimatedRotationWidget( AnimatedRotationWidget(
onPressed: () => bind.mainUpdateTemporaryPassword(), onPressed: () => bind.mainUpdateTemporaryPassword(),
child: Tooltip( child: Tooltip(

View File

@ -446,7 +446,6 @@ class ServerInfo extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isPermanent = model.verificationMethod == kUsePermanentPassword;
final serverModel = Provider.of<ServerModel>(context); final serverModel = Provider.of<ServerModel>(context);
const Color colorPositive = Colors.green; const Color colorPositive = Colors.green;
@ -486,6 +485,8 @@ class ServerInfo extends StatelessWidget {
} }
} }
final showOneTime = serverModel.approveMode != 'click' &&
serverModel.verificationMethod != kUsePermanentPassword;
return PaddingCard( return PaddingCard(
title: translate('Your Device'), title: translate('Your Device'),
child: Column( child: Column(
@ -523,10 +524,10 @@ class ServerInfo extends StatelessWidget {
]), ]),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text( Text(
isPermanent ? '-' : model.serverPasswd.value.text, !showOneTime ? '-' : model.serverPasswd.value.text,
style: textStyleValue, style: textStyleValue,
), ),
isPermanent !showOneTime
? SizedBox.shrink() ? SizedBox.shrink()
: Row(children: [ : Row(children: [
IconButton( IconButton(

View File

@ -831,11 +831,12 @@ class PasswordEyeArea : Reactor.Component {
render() { render() {
var method = handler.get_option('verification-method'); var method = handler.get_option('verification-method');
var mode= handler.get_option('approve-mode'); 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 return
<div .eye-area style="width: *"> <div .eye-area style="width: *">
<input|text @{this.input} readonly value={value} /> <input|text @{this.input} readonly value={value} />
{svg_refresh_password} {hide_one_time ? "" : svg_refresh_password}
</div>; </div>;
} }