Skip to content

Commit

Permalink
Revert "change login & register UI"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kouhakouu committed Nov 24, 2024
1 parent ccca650 commit cc52ace
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 168 deletions.
106 changes: 72 additions & 34 deletions lib/features/.authentication/presentation/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ class _LoginPageState extends State<LoginPage> {

bool isLoading = false;
String? message;
bool _submitted = false; // Add this line

// Hàm xử lý đăng nhập
Future<void> handleLogin() async {
setState(() {
_submitted = true; // Update the submitted flag
});

if (!_formKey.currentState!.validate()) {
return;
}
Expand Down Expand Up @@ -179,13 +174,6 @@ class _LoginPageState extends State<LoginPage> {

// Hàm chuyển hướng đến trang đăng ký
void navigateToRegister() {
setState(() {
message = null;
_submitted = false; // Reset the submitted flag
_formKey.currentState?.reset();
emailController.clear();
passwordController.clear();
});
Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -212,13 +200,76 @@ class _LoginPageState extends State<LoginPage> {
),
),
),
// ... (Các widget Positioned khác không thay đổi)
// Thêm nhiều bong bóng nền hơn
Positioned(
top: -50,
left: -50,
child: Container(
width: 250, // đường kính của bubble
height: 250,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color.fromRGBO(161, 214, 178, 0.25), Color.fromRGBO(241, 243, 194, 0.75)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
),
),
Positioned(
bottom: -100,
right: -50,
child: Container(
width: 200, // đường kính của bubble
height: 200,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color.fromRGBO(161, 214, 178, 1), Color.fromRGBO(241, 243, 194, 1)],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
),
),
Positioned(
top: 120,
right: 50,
child: Container(
width: 150, // đường kính của bubble
height: 150,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color.fromRGBO(161, 214, 178, 0.75), Color.fromRGBO(241, 243, 194, 0.25)],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
),
),
),
),
Positioned(
bottom: 100,
right: 500,
child: Container(
width: 300, // đường kính của bubble
height: 300,
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color.fromRGBO(161, 214, 178, 0.75), Color.fromRGBO(241, 243, 194, 0.25)],
begin: Alignment.topCenter,
end: Alignment.centerRight,
),
),
),
),
// Nội dung chính
Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Container(
height: isMobile ? double.infinity : 600,
width: isMobile ? double.infinity : 800, // Độ rộng tùy theo thiết bị
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
Expand All @@ -236,24 +287,11 @@ class _LoginPageState extends State<LoginPage> {
? buildLoginForm()
: IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Bên trái: Form đăng nhập
Expanded(
flex: 1,
child: Center(
// Thêm Center để căn giữa theo chiều dọc
child: buildLoginForm(),
),
/*
Hoặc sử dụng Column:
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
buildLoginForm(),
],
),
*/
child: buildLoginForm(),
),
const SizedBox(width: 32),
// Bên phải: Chào mừng
Expand Down Expand Up @@ -346,6 +384,7 @@ class _LoginPageState extends State<LoginPage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 50),
const Text(
'ĐĂNG NHẬP',
style: TextStyle(
Expand All @@ -354,14 +393,12 @@ class _LoginPageState extends State<LoginPage> {
color: Colors.green,
),
),
const SizedBox(height: 15),
const SizedBox(height: 24),
TextFormField(
controller: emailController,
autovalidateMode: _submitted ? AutovalidateMode.onUserInteraction : AutovalidateMode.disabled,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.email),
labelText: 'Email',
helperText: ' ', // Dự trữ không gian cho thông báo lỗi
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
Expand All @@ -377,10 +414,9 @@ class _LoginPageState extends State<LoginPage> {
return null;
},
),
const SizedBox(height: 5),
const SizedBox(height: 16),
TextFormField(
controller: passwordController,
autovalidateMode: _submitted ? AutovalidateMode.onUserInteraction : AutovalidateMode.disabled,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock),
labelText: 'Mật khẩu',
Expand All @@ -399,6 +435,7 @@ class _LoginPageState extends State<LoginPage> {
return null;
},
),
const SizedBox(height: 5),
Align(
alignment: Alignment.centerRight,
child: TextButton(
Expand Down Expand Up @@ -442,7 +479,7 @@ class _LoginPageState extends State<LoginPage> {
),
),
),
const SizedBox(height: 20),
const SizedBox(height: 16),
// Nút Đăng Ký với viền gradient và nền trắng
Container(
width: double.infinity,
Expand Down Expand Up @@ -479,6 +516,7 @@ class _LoginPageState extends State<LoginPage> {
),
),
),
const SizedBox(height: 50),
],
),
);
Expand Down
28 changes: 12 additions & 16 deletions lib/features/.authentication/presentation/register_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class _RegisterPageState extends State<RegisterPage> {
final TextEditingController emailController = TextEditingController();
final TextEditingController passwordController = TextEditingController();

String selectedRole = 'resident'; // Mặc định là 'Cư Dân'
String selectedRole = 'resident'; // Mặc định là 'Cư dân'

bool isLoading = false;
String? message;
Expand Down Expand Up @@ -94,7 +94,7 @@ class _RegisterPageState extends State<RegisterPage> {
top: -50,
left: -50,
child: Container(
width: 250, // Đường kính của bubble
width: 250, // đường kính của bubble
height: 250,
decoration: const BoxDecoration(
shape: BoxShape.circle,
Expand All @@ -110,7 +110,7 @@ class _RegisterPageState extends State<RegisterPage> {
bottom: -100,
right: -50,
child: Container(
width: 200, // Đường kính của bubble
width: 200, // đường kính của bubble
height: 200,
decoration: const BoxDecoration(
shape: BoxShape.circle,
Expand All @@ -126,7 +126,7 @@ class _RegisterPageState extends State<RegisterPage> {
top: 120,
right: 50,
child: Container(
width: 150, // Đường kính của bubble
width: 150, // đường kính của bubble
height: 150,
decoration: const BoxDecoration(
shape: BoxShape.circle,
Expand All @@ -142,7 +142,7 @@ class _RegisterPageState extends State<RegisterPage> {
bottom: 100,
right: 500,
child: Container(
width: 300, // Đường kính của bubble
width: 300, // đường kính của bubble
height: 300,
decoration: const BoxDecoration(
shape: BoxShape.circle,
Expand All @@ -159,7 +159,6 @@ class _RegisterPageState extends State<RegisterPage> {
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Container(
height: isMobile ? double.infinity : 600,
width: isMobile ? double.infinity : 800, // Độ rộng tùy theo thiết bị
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
Expand All @@ -177,14 +176,11 @@ class _RegisterPageState extends State<RegisterPage> {
? buildRegisterForm()
: IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Bên trái: Form đăng ký
Expanded(
flex: 1,
child: Center(
child: buildRegisterForm(),
),
child: buildRegisterForm(),
),
const SizedBox(width: 32),
// Bên phải: Chào mừng
Expand Down Expand Up @@ -277,6 +273,7 @@ class _RegisterPageState extends State<RegisterPage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 50),
const Text(
'ĐĂNG KÝ',
style: TextStyle(
Expand All @@ -285,13 +282,12 @@ class _RegisterPageState extends State<RegisterPage> {
color: Colors.green,
),
),
const SizedBox(height: 15),
const SizedBox(height: 24),
TextFormField(
controller: emailController,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.email),
labelText: 'Email',
helperText: ' ', // Dự trữ không gian cho thông báo lỗi
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
Expand All @@ -307,13 +303,12 @@ class _RegisterPageState extends State<RegisterPage> {
return null;
},
),
const SizedBox(height: 5),
const SizedBox(height: 16),
TextFormField(
controller: passwordController,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock),
labelText: 'Mật khẩu',
helperText: ' ', // Dự trữ không gian cho thông báo lỗi
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
Expand All @@ -329,7 +324,7 @@ class _RegisterPageState extends State<RegisterPage> {
return null;
},
),
const SizedBox(height: 5),
const SizedBox(height: 16),
DropdownButtonFormField<String>(
value: selectedRole,
decoration: InputDecoration(
Expand Down Expand Up @@ -386,7 +381,7 @@ class _RegisterPageState extends State<RegisterPage> {
),
),
),
const SizedBox(height: 20),
const SizedBox(height: 16),
// Nút Quay lại Đăng Nhập với viền gradient và nền trắng
Container(
width: double.infinity,
Expand Down Expand Up @@ -425,6 +420,7 @@ class _RegisterPageState extends State<RegisterPage> {
),
),
),
const SizedBox(height: 50),
],
),
);
Expand Down
Loading

0 comments on commit cc52ace

Please sign in to comment.