CH-J SM Mobileإدارة الخوادم عبر SSH
القائمة
المصدر المنشور

CH-J SM Mobile

تصفّح الأدلة والملفات الخاصة بإصدار محدد من التطبيق.

تنزيل الشيفرة المصدرية بصيغة ZIP
CH-J / SM Mobile 175 ملفات
sm-mobile-20261016T185235Z-8e93ecc1b59a تاريخ الإضافة: · تاريخ البناء:
change_password.dart تاريخ الإضافة: لم يُسجَّل التاريخ ٤٫٢ KB · 132 أسطر
الشيفرة تنزيل الملف
1import 'package:flutter/material.dart';
2import '../core/app_controller.dart';
3import '../core/failure.dart';
4import '../l10n/strings.dart';
5import '../services/ssh_service.dart';
6import 'password_fields.dart';
8/// Asks for the current password, then the new one twice, and changes the
9/// master password. The Vault stays open and unchanged on any failure.
10class ChangePasswordPage extends StatefulWidget {
11 final AppController controller;
12 const ChangePasswordPage(this.controller, {super.key});
13 @override
14 State<ChangePasswordPage> createState() => _ChangePasswordPageState();
17class _ChangePasswordPageState extends State<ChangePasswordPage> {
18 final current = TextEditingController();
19 final next = TextEditingController();
20 final repeated = TextEditingController();
21 bool busy = false;
22 String? error;
24 @override
25 void dispose() {
26 for (final c in [current, next, repeated]) {
27 c.clear();
28 c.dispose();
29 }
30 super.dispose();
31 }
33 Future<void> submit() async {
34 FocusManager.instance.primaryFocus?.unfocus();
35 setState(() {
36 busy = true;
37 error = null;
38 });
39 try {
40 if (next.text != repeated.text) throw const Failure('passwordMismatch');
41 if (next.text == current.text) throw const Failure('samePassword');
42 await widget.controller.changePassword(
43 current.text,
44 next.text,
45 context.tr('biometricReason'),
46 );
47 if (!mounted) return;
48 ScaffoldMessenger.of(
49 context,
50 ).showSnackBar(SnackBar(content: Text(context.tr('passwordChanged'))));
51 Navigator.pop(context, true);
52 } catch (e) {
53 if (!mounted) return;
54 final code = failureCode(e);
55 if (code == 'passwordChangedBiometricOff') {
56 // The password itself was changed.
57 ScaffoldMessenger.of(context).showSnackBar(
58 SnackBar(
59 content: Text(context.tr(code)),
60 duration: const Duration(seconds: 10),
61 ),
62 );
63 Navigator.pop(context, true);
64 return;
65 }
66 setState(
67 () => error = code == 'unlockFailed' ? 'wrongCurrentPassword' : code,
68 );
69 } finally {
70 if (mounted) setState(() => busy = false);
71 }
72 }
74 @override
75 Widget build(BuildContext context) => Scaffold(
76 appBar: AppBar(title: Text(context.tr('changePassword'))),
77 body: SafeArea(
78 child: Center(
79 child: SingleChildScrollView(
80 padding: const EdgeInsets.all(24),
81 child: ConstrainedBox(
82 constraints: const BoxConstraints(maxWidth: 450),
83 child: Column(
84 crossAxisAlignment: CrossAxisAlignment.stretch,
85 children: [
86 PasswordField(
87 controller: current,
88 label: context.tr('currentPassword'),
89 autofocus: true,
90 action: TextInputAction.next,
91 ),
92 const SizedBox(height: 16),
93 PasswordField(
94 controller: next,
95 label: context.tr('newPassword'),
96 action: TextInputAction.next,
97 onChanged: (_) => setState(() {}),
98 ),
99 const SizedBox(height: 8),
100 PasswordAdvice(next.text),
101 const SizedBox(height: 16),
102 PasswordField(
103 controller: repeated,
104 label: context.tr('confirmNewPassword'),
105 action: TextInputAction.done,
106 onSubmitted: (_) {
107 if (!busy) submit();
108 },
109 ),
110 if (error != null) ...[
111 const SizedBox(height: 12),
112 Text(
113 context.tr(error!),
114 style: TextStyle(
115 color: Theme.of(context).colorScheme.error,
116 ),
117 ),
118 ],
119 const SizedBox(height: 20),
120 FilledButton(
121 onPressed: busy ? null : submit,
122 child: Text(context.tr('changePassword')),
123 ),
124 if (busy) const LinearProgressIndicator(),
125 ],
126 ),
127 ),
128 ),
129 ),
130 ),
131 );
SHA-2560694c844bbaccf988713979a239e49feb9ed2ee29835bdabfe7fa9a979d6693b

CH-J Proprietary Software License 1.14 · تُتاح الشيفرة المصدرية بموجب CH-J Proprietary Software License 1.14. وإتاحتها لا تغيّر شروط الترخيص ولا تمنح حقوقًا إضافية.

SHA-256 للأرشيف46e427a43e87af091004f36145590bda8fe90086dfb0f631afeb5029fb0b5655
الملفات