You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tangheem/lib/ui/dialogs/change_password_dialog.dart

102 lines
3.6 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:tangheem/classes/colors.dart';
import 'package:tangheem/classes/utils.dart';
import 'package:tangheem/widgets/common_textfield_widget.dart';
class ChangePasswordDialog extends StatefulWidget {
final Function(String) onPassword;
ChangePasswordDialog({Key key, this.onPassword}) : super(key: key);
@override
_ChangePasswordDialogState createState() {
return _ChangePasswordDialogState();
}
}
class _ChangePasswordDialogState extends State<ChangePasswordDialog> {
final TextEditingController _passwordController = TextEditingController();
final TextEditingController _confirmPasswordController = TextEditingController();
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Dialog(
insetPadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 24.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 0,
backgroundColor: Colors.transparent,
child: Directionality(
textDirection: TextDirection.rtl,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: ColorConsts.primaryBlue,
borderRadius: BorderRadius.circular(16),
),
padding: EdgeInsets.symmetric(vertical: 32, horizontal: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"تغيير كلمة المرور",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 22),
),
SizedBox(height: 16),
CommonTextFieldWidget(hint: "الايميل المسجل", controller: _passwordController, prefixIcon: "assets/icons/password.svg"),
SizedBox(height: 8),
CommonTextFieldWidget(hint: "تأكيد كلمة المرور", controller: _confirmPasswordController, prefixIcon: "assets/icons/password.svg"),
SizedBox(height: 16),
SizedBox(
width: double.infinity,
height: 40,
child: TextButton(
onPressed: () {
if (_passwordController.text.length < 1) {
Utils.showToast("كلمة المرور فارغة");
return;
}
if (_confirmPasswordController.text.length < 1) {
Utils.showToast("تأكيد كلمة المرور فارغ");
return;
}
if (_passwordController.text != _confirmPasswordController.text) {
Utils.showToast("كلمة المرور خاطئة");
return;
}
widget.onPassword(_passwordController.text);
},
style: TextButton.styleFrom(
primary: Colors.white,
padding: EdgeInsets.all(2),
backgroundColor: ColorConsts.secondaryPink,
textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
child: Text("تحديث"),
),
),
],
),
),
),
);
}
}