diff --git a/lib/main.dart b/lib/main.dart index 129dcad6..7e432d77 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,6 +9,7 @@ import 'package:uae_stat/config/old_theme.dart'; import 'package:uae_stat/domain/entities/language_locale.dart'; import 'package:uae_stat/domain/use_cases/auth_use_case.dart'; import 'package:uae_stat/presentation/Screens/profilepage.dart'; +import 'package:uae_stat/presentation/Screens/registration.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -27,7 +28,8 @@ class MainApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - home: ProfileScreen(), + home: RegisterScreen(), + // home: ProfileScreen(), debugShowCheckedModeBanner: false, ); } diff --git a/lib/presentation/Screens/profilepage.dart b/lib/presentation/Screens/profilepage.dart index 10e2dc93..767f8253 100644 --- a/lib/presentation/Screens/profilepage.dart +++ b/lib/presentation/Screens/profilepage.dart @@ -335,21 +335,11 @@ class _ProfileScreenState extends State { showConfirmationDialog(context); } else { ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Please accept the terms and conditions.')), + SnackBar(content: Text('Please accept the terms and conditions.',style: TextStyle(color: Colors.white),)), ); } } }, - // { - // // Validate the fields - // if (_formKey.currentState?.validate() ?? false) { - // _formKey.currentState?.save(); - // - // //Alertbox display after the validations - // showConfirmationDialog(context); - // } - // - // }, icon: Icon( Icons.save, color: Colors.white, diff --git a/lib/presentation/Screens/registration.dart b/lib/presentation/Screens/registration.dart new file mode 100644 index 00000000..874b8c3e --- /dev/null +++ b/lib/presentation/Screens/registration.dart @@ -0,0 +1,562 @@ +// import 'package:flutter/material.dart'; +// +// class RegisterScreen extends StatefulWidget { +// +// @override +// _RegisterScreenState createState() => _RegisterScreenState(); +// } +// +// class _RegisterScreenState extends State { +// final _formKey = GlobalKey(); +// bool _obscurePassword = true; +// bool _obscureConfirmPassword = true; +// bool isChecked = false; +// bool showError = false; +// +// String? _validateUsername(String? value) { +// if (value == null || value.isEmpty) { +// return 'Required'; +// } else if (RegExp(r'[^a-zA-Z0-9]').hasMatch(value)) { +// return 'Invalid Characters'; +// } +// return null; +// } +// +// String? _validateEmail(String? value) { +// if (value == null || value.isEmpty) { +// return 'Required'; +// } else if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) { +// return 'Invalid Email'; +// } +// return null; +// } +// +// String? _validatePassword(String? value) { +// if (value == null || value.isEmpty) { +// return 'Required'; +// } else if (value.length < 6) { +// return 'Password must be at least 6 characters'; +// } +// return null; +// } +// +// @override +// Widget build(BuildContext context) { +// double screenheight = MediaQuery.of(context).size.height; +// double screenwidth = MediaQuery.of(context).size.width; +// return Scaffold( +// backgroundColor: Colors.white, +// body: Padding( +// padding: const EdgeInsets.all(20.0), +// child: Form( +// key: _formKey, +// child: SingleChildScrollView( +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// SizedBox(height: screenheight / 6), +// Text( +// 'Register', +// style: TextStyle(fontSize: 32, fontWeight: FontWeight.w400), +// ), +// SizedBox(height: 10), +// Text('Please enter your details'), +// SizedBox(height: 20), +// TextFormField( +// decoration: InputDecoration( +// hintText: 'Username', +// prefixIcon: Icon( +// Icons.person, +// color: Colors.blue, +// ), +// border: OutlineInputBorder(), +// ), +// validator: _validateUsername, +// ), +// SizedBox(height: 15), +// TextFormField( +// decoration: InputDecoration( +// hintText: 'Enter your email', +// prefixIcon: Icon( +// Icons.email, +// color: Colors.blue, +// ), +// border: OutlineInputBorder(), +// ), +// validator: _validateEmail, +// ), +// SizedBox(height: 15), +// TextFormField( +// obscureText: _obscurePassword, +// decoration: InputDecoration( +// hintText: 'Enter your password', +// prefixIcon: Icon( +// Icons.lock, +// color: Colors.blue, +// ), +// suffixIcon: IconButton( +// icon: Icon( +// _obscurePassword +// ? Icons.visibility +// : Icons.visibility_off, +// color: Colors.blue, +// ), +// onPressed: () { +// setState(() { +// _obscurePassword = !_obscurePassword; +// }); +// }, +// ), +// border: OutlineInputBorder(), +// ), +// validator: _validatePassword, +// ), +// SizedBox(height: 15), +// TextFormField( +// obscureText: _obscureConfirmPassword, +// decoration: InputDecoration( +// hintText: 'Confirm password', +// prefixIcon: Icon( +// Icons.lock, +// color: Colors.blue, +// ), +// suffixIcon: IconButton( +// icon: Icon( +// _obscureConfirmPassword +// ? Icons.visibility +// : Icons.visibility_off, +// color: Colors.blue, +// ), +// onPressed: () { +// setState(() { +// _obscureConfirmPassword = !_obscureConfirmPassword; +// }); +// }, +// ), +// border: OutlineInputBorder(), +// ), +// validator: _validatePassword, +// ), +// SizedBox(height: 10), +// Row( +// children: [ +// Checkbox( +// value: isChecked, +// onChanged: (value) { +// setState(() { +// isChecked = value ?? false; +// showError = false; +// }); +// }, +// side: BorderSide( +// color: showError ? Colors.red : Colors.grey, +// width: 1.5, +// ), +// ), +// Expanded( +// child: Text.rich( +// TextSpan( +// text: 'I agree to ', +// children: [ +// TextSpan( +// text: 'Terms & Conditions', +// style: TextStyle(color: Colors.blue), +// ), +// TextSpan(text: ' and '), +// TextSpan( +// text: 'Privacy Policy', +// style: TextStyle(color: Colors.blue), +// ), +// ], +// ), +// ), +// ), +// ], +// ), +// if (showError) +// Row( +// mainAxisAlignment: MainAxisAlignment.start, +// children: [ +// Padding( +// padding: const EdgeInsets.only(left: 10.0), +// child: Text( +// 'Required', +// style: TextStyle( +// color: Colors.red[700], +// fontSize: 12, +// ), +// ), +// ), +// ], +// ), +// SizedBox(height: 20), +// SizedBox( +// width: screenwidth/1.3, +// child: ElevatedButton( +// onPressed: () { +// if ((_formKey.currentState?.validate() ?? +// false )&& isChecked) { +// // Proceed with registration if form is valid and checkbox is checked +// } else { +// setState(() { +// showError = +// !isChecked; // Show error if the checkbox is not checked +// }); +// } +// }, +// style: ElevatedButton.styleFrom( +// backgroundColor: Color(0xFFA7887A), +// // Brownish color for Register +// +// shape: RoundedRectangleBorder( +// borderRadius: BorderRadius.circular(20), +// ), +// ), +// child: Row( +// mainAxisSize: MainAxisSize.min, +// children: [ +// Text( +// "Register", +// style: TextStyle(fontSize: 16, color: Colors.white), +// ), +// SizedBox(width: 8), +// Icon(Icons.arrow_forward, color: Colors.white), +// ], +// ), +// ), +// ), +// SizedBox(height: 10), +// Text( +// "Already have an account?", +// style: TextStyle(fontSize: 16, color: Colors.grey[600]), +// ), +// SizedBox(height: 10), +// SizedBox( +// width: screenwidth/1.3, +// child: ElevatedButton( +// onPressed: () { +// // Add your login logic here +// }, +// style: ElevatedButton.styleFrom( +// backgroundColor: Color(0xFF82AFCB), +// // Blueish color for Login +// shape: RoundedRectangleBorder( +// borderRadius: BorderRadius.circular(20), +// ), +// ), +// child: Row( +// mainAxisSize: MainAxisSize.min, +// children: [ +// Text( +// "Login", +// style: TextStyle(fontSize: 16, color: Colors.white), +// ), +// SizedBox(width: 8), +// Icon(Icons.arrow_forward, color: Colors.white), +// ], +// ), +// ), +// ), +// ], +// ), +// ), +// ), +// ), +// ); +// } +// } + + + +import 'package:flutter/material.dart'; +import 'package:uae_stat/presentation/Screens/profilepage.dart'; + +class RegisterScreen extends StatefulWidget { + @override + _RegisterScreenState createState() => _RegisterScreenState(); +} + +class _RegisterScreenState extends State { + final _formKey = GlobalKey(); + bool _obscurePassword = true; + bool _obscureConfirmPassword = true; + bool isChecked = false; + bool showError = false; + + String? _password; + + String? _validateUsername(String? value) { + if (value == null || value.isEmpty) { + return 'Required'; + } else if (RegExp(r'[^a-zA-Z0-9]').hasMatch(value)) { + return 'Invalid Characters'; + } + return null; + } + + String? _validateEmail(String? value) { + if (value == null || value.isEmpty) { + return 'Required'; + } else if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) { + return 'Invalid Email'; + } + return null; + } + + String? _validatePassword(String? value) { + if (value == null || value.isEmpty) { + return 'Required'; + } else if (value.length < 6) { + return 'Password must be at least 6 characters'; + } + _password = value; // Store the password for confirm password validation + return null; + } + + String? _validateConfirmPassword(String? value) { + if (value == null || value.isEmpty) { + return 'Required'; + } else if (value != _password) { + return 'Passwords do not match'; + } + return null; + } + + @override + Widget build(BuildContext context) { + double screenheight = MediaQuery.of(context).size.height; + double screenwidth = MediaQuery.of(context).size.width; + return Scaffold( + backgroundColor: Colors.white, + body: Padding( + padding: const EdgeInsets.all(20.0), + child: Form( + key: _formKey, + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: screenheight / 6), + Text( + 'Register', + style: TextStyle(fontSize: 32, fontWeight: FontWeight.w400), + ), + SizedBox(height: 10), + Text('Please enter your details'), + SizedBox(height: 20), + TextFormField( + decoration: InputDecoration( + hintText: 'Username', + prefixIcon: Icon( + Icons.person, + color: Colors.blue, + ), + border: OutlineInputBorder(), + ), + validator: _validateUsername, + ), + SizedBox(height: 15), + TextFormField( + decoration: InputDecoration( + hintText: 'Enter your email', + prefixIcon: Icon( + Icons.email, + color: Colors.blue, + ), + border: OutlineInputBorder(), + ), + validator: _validateEmail, + ), + SizedBox(height: 15), + TextFormField( + obscureText: _obscurePassword, + decoration: InputDecoration( + hintText: 'Enter your password', + prefixIcon: Icon( + Icons.lock, + color: Colors.blue, + ), + suffixIcon: IconButton( + icon: Icon( + _obscurePassword + ? Icons.visibility + : Icons.visibility_off, + color: Colors.blue, + ), + onPressed: () { + setState(() { + _obscurePassword = !_obscurePassword; + }); + }, + ), + border: OutlineInputBorder(), + ), + validator: _validatePassword, + ), + SizedBox(height: 15), + TextFormField( + obscureText: _obscureConfirmPassword, + decoration: InputDecoration( + hintText: 'Confirm password', + prefixIcon: Icon( + Icons.lock, + color: Colors.blue, + ), + suffixIcon: IconButton( + icon: Icon( + _obscureConfirmPassword + ? Icons.visibility + : Icons.visibility_off, + color: Colors.blue, + ), + onPressed: () { + setState(() { + _obscureConfirmPassword = !_obscureConfirmPassword; + }); + }, + ), + border: OutlineInputBorder(), + ), + validator: _validateConfirmPassword, + ), + SizedBox(height: 10), + Row( + children: [ + Checkbox( + value: isChecked, + onChanged: (value) { + setState(() { + isChecked = value ?? false; + showError = false; + }); + }, + side: BorderSide( + color: showError ? Colors.red : Colors.grey, + width: 1.5, + ), + ), + Expanded( + child: Text.rich( + TextSpan( + text: 'I agree to ', + children: [ + TextSpan( + text: 'Terms & Conditions', + style: TextStyle(color: Colors.blue), + ), + TextSpan(text: ' and '), + TextSpan( + text: 'Privacy Policy', + style: TextStyle(color: Colors.blue), + ), + ], + ), + ), + ), + ], + ), + if (showError) + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 10.0), + child: Text( + 'Required', + style: TextStyle( + color: Colors.red[700], + fontSize: 12, + ), + ), + ), + ], + ), + SizedBox(height: 20), + SizedBox( + width: screenwidth/1.3, + child: ElevatedButton( + onPressed: () { + if ((_formKey.currentState?.validate() ?? false) && isChecked) { + // Proceed with registration if form is valid and checkbox is checked + Navigator.push( + context, + MaterialPageRoute(builder: (context) => ProfileScreen()), + ); + } else { + setState(() { + showError = !isChecked; // Show error if the checkbox is not checked + }); + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFA7887A), // Brownish color for Register + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Register", + style: TextStyle(fontSize: 16, color: Colors.white), + ), + SizedBox(width: 8), + Icon(Icons.arrow_forward, color: Colors.white), + ], + ), + ), + ), + SizedBox(height: 10), + Text( + "Already have an account?", + style: TextStyle(fontSize: 16, color: Colors.grey[600]), + ), + SizedBox(height: 10), + SizedBox( + width: screenwidth/1.3, + child: ElevatedButton( + onPressed: () { + // Add your login logic here + }, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF82AFCB), // Blueish color for Login + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Login", + style: TextStyle(fontSize: 16, color: Colors.white), + ), + SizedBox(width: 8), + Icon(Icons.arrow_forward, color: Colors.white), + ], + ), + ), + ), + SizedBox(height: 10,), + Center( + child: Container( + height: screenheight/8, + width: screenwidth/2, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/splash_screen/logo.png"), // Background image asset + fit: BoxFit.fill, + ), + ), + ))], + ), + ), + ), + ), + ); + } +} + + + diff --git a/pubspec.yaml b/pubspec.yaml index cab28e16..58e853e9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -99,6 +99,7 @@ flutter: - assets/cached_responses/sharepoint/gov_init/ - assets/cached_responses/sharepoint/country_leader_imgs/ - assets/edit_profile/ + - assets/splash_screen/ fonts: - family: Segoe