mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 19:22:22 +01:00
10.0.5
This commit is contained in:
90
gui/lib/src/widget/message/profile.dart
Normal file
90
gui/lib/src/widget/message/profile.dart
Normal file
@@ -0,0 +1,90 @@
|
||||
import 'package:email_validator/email_validator.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/material.dart' show Icons;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_launcher/src/messenger/dialog.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
|
||||
Future<bool> showProfileForm(BuildContext context, TextEditingController username, TextEditingController password) async{
|
||||
final showPassword = RxBool(false);
|
||||
final oldUsername = username.text;
|
||||
final showPasswordTrailing = RxBool(oldUsername.isNotEmpty);
|
||||
final oldPassword = password.text;
|
||||
final result = await showRebootDialog<bool?>(
|
||||
builder: (context) => Obx(() => FormDialog(
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InfoLabel(
|
||||
label: translations.usernameOrEmail,
|
||||
child: TextFormBox(
|
||||
placeholder: translations.usernameOrEmailPlaceholder,
|
||||
validator: (text) {
|
||||
if(password.text.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(EmailValidator.validate(username.text)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return translations.invalidEmail;
|
||||
},
|
||||
controller: username,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
enableSuggestions: true,
|
||||
autofocus: true,
|
||||
autocorrect: false,
|
||||
)
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
InfoLabel(
|
||||
label: translations.password,
|
||||
child: TextFormBox(
|
||||
placeholder: translations.passwordPlaceholder,
|
||||
controller: password,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
obscureText: !showPassword.value,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
onChanged: (text) => showPasswordTrailing.value = text.isNotEmpty,
|
||||
suffix: Button(
|
||||
onPressed: () => showPassword.value = !showPassword.value,
|
||||
style: ButtonStyle(
|
||||
shape: WidgetStateProperty.all(const CircleBorder()),
|
||||
backgroundColor: WidgetStateProperty.all(Colors.transparent)
|
||||
),
|
||||
child: Icon(
|
||||
showPassword.value ? Icons.visibility_off : Icons.visibility,
|
||||
color: showPasswordTrailing.value ? null : Colors.transparent
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
const SizedBox(height: 8.0)
|
||||
],
|
||||
),
|
||||
buttons: [
|
||||
DialogButton(
|
||||
text: translations.cancelProfileChanges,
|
||||
type: ButtonType.secondary
|
||||
),
|
||||
|
||||
DialogButton(
|
||||
text: translations.saveProfileChanges,
|
||||
type: ButtonType.primary,
|
||||
onTap: () => Navigator.of(context).pop(true)
|
||||
)
|
||||
]
|
||||
))
|
||||
) ?? false;
|
||||
if(result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
username.text = oldUsername;
|
||||
password.text = oldPassword;
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user