Last active
September 14, 2023 20:47
-
-
Save muindetuva/e24081bfee2b064bc6825ef3c813ca32 to your computer and use it in GitHub Desktop.
New Signup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:http/http.dart' as http; | |
| import 'package:vazeey/FloatingTab.dart'; | |
| import 'loginpage.dart'; | |
| class SignupPage extends StatefulWidget { | |
| const SignupPage({Key? key}) : super(key: key); | |
| @override | |
| _SignupPageState createState() => _SignupPageState(); | |
| } | |
| class _SignupPageState extends State<SignupPage> { | |
| final TextEditingController emailController = TextEditingController(); | |
| final TextEditingController firstNameController = TextEditingController(); | |
| final TextEditingController passwordController = TextEditingController(); | |
| final TextEditingController repeatPasswordController = TextEditingController(); | |
| Future<void> _signUp() async { | |
| final email = emailController.text; | |
| final firstName = firstNameController.text; | |
| final password = passwordController.text; | |
| final repeatPassword = repeatPasswordController.text; | |
| // Check if passwords match | |
| if (password != repeatPassword) { | |
| // Show an error message or dialog | |
| return; | |
| } | |
| // Replace this URL with your server's endpoint for storing user data | |
| final apiUrl = Uri.parse('http://vazeey.muindetuva.com/api/register'); | |
| try { | |
| final response = await http.post( | |
| apiUrl, | |
| body: { | |
| 'email': email, | |
| 'name': firstName, | |
| 'password': password, | |
| 'phonenumber': "0794323232" | |
| }, | |
| ); | |
| if (response.statusCode == 200) { | |
| // User successfully signed up | |
| // You can handle the response here, e.g., navigate to another screen | |
| Navigator.pushReplacement( | |
| context, | |
| MaterialPageRoute( | |
| builder: (context) => const FloatingTab(), // Replace with your desired page | |
| ), | |
| ); | |
| } else { | |
| // Handle errors, e.g., show an error message | |
| // You can parse the response body for more details if needed | |
| } | |
| } catch (error) { | |
| // Handle network errors or other exceptions | |
| // You can show an error message or perform other actions | |
| } | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| final screenHeight = MediaQuery.of(context).size.height; | |
| final screenWidth = MediaQuery.of(context).size.width; | |
| // Your UI code remains the same | |
| return Scaffold( | |
| // ... Rest of your UI code ... | |
| resizeToAvoidBottomInset: false, | |
| body: SingleChildScrollView( // Wrap the Stack with SingleChildScrollView | |
| child: Container( | |
| width: double.infinity, | |
| height: screenHeight, | |
| decoration: const BoxDecoration( | |
| gradient: LinearGradient( | |
| begin: Alignment.topCenter, | |
| end: Alignment.bottomCenter, | |
| colors: [Color.fromRGBO(255, 255, 255, 1), Color.fromRGBO(3, 120, 100, 1)], | |
| ), | |
| ), | |
| child: Stack( | |
| children: <Widget>[ | |
| // Logo | |
| Positioned( | |
| top: -screenHeight * 0.02, | |
| left: screenWidth * 0.21, | |
| child: Container( | |
| width: 200, | |
| height: 250.00, | |
| decoration: const BoxDecoration( | |
| image: DecorationImage( | |
| image: AssetImage('assets/Vazeeylogo_nobg.png'), | |
| fit: BoxFit.fitWidth, | |
| ), | |
| ), | |
| ), | |
| ), | |
| // "Hi There!" text | |
| Positioned( | |
| top: screenHeight * 0.23, | |
| left: screenWidth * 0.15, | |
| child: SizedBox( | |
| width: screenWidth * 0.7, | |
| height: screenHeight * 0.15, | |
| child: const Text( | |
| 'Hi There!', | |
| textAlign: TextAlign.center, | |
| style: TextStyle( | |
| color: Colors.black, | |
| fontFamily: 'Merriweather Sans', | |
| fontSize: 35, | |
| fontWeight: FontWeight.w400, | |
| ), | |
| ), | |
| ), | |
| ), | |
| // "Let us get started" text | |
| Positioned( | |
| top: screenHeight * 0.34, | |
| left: screenWidth * 0.2, | |
| child: SizedBox( | |
| width: screenWidth * 0.6, | |
| height: screenHeight * 0.1, | |
| child: const Text( | |
| 'Let us get started', | |
| textAlign: TextAlign.center, | |
| style: TextStyle( | |
| color: Colors.black, | |
| fontFamily: 'Montserrat', | |
| fontSize: 19, | |
| fontWeight: FontWeight.bold, | |
| ), | |
| ), | |
| ), | |
| ), | |
| // Email Address text field | |
| Positioned( | |
| top: screenHeight * 0.50, | |
| left: screenWidth * 0.1, | |
| right: screenWidth * 0.1, | |
| child: Container( | |
| height: screenHeight * 0.08, | |
| decoration: BoxDecoration( | |
| borderRadius: BorderRadius.circular(screenHeight * 0.04), | |
| color: const Color.fromRGBO(255, 255, 255, 1), | |
| ), | |
| child: TextField( | |
| decoration: InputDecoration( | |
| hintText: 'Email Address', | |
| border: InputBorder.none, | |
| contentPadding: EdgeInsets.symmetric(horizontal: screenWidth * 0.04), | |
| ), | |
| ), | |
| ), | |
| ), | |
| // First Name text field | |
| Positioned( | |
| top: screenHeight * 0.40, | |
| left: screenWidth * 0.1, | |
| right: screenWidth * 0.1, | |
| child: Container( | |
| height: screenHeight * 0.08, | |
| decoration: BoxDecoration( | |
| borderRadius: BorderRadius.circular(screenHeight * 0.04), | |
| color: const Color.fromRGBO(255, 255, 255, 1), | |
| ), | |
| child: TextField( | |
| decoration: InputDecoration( | |
| hintText: 'First Name', | |
| border: InputBorder.none, | |
| contentPadding: EdgeInsets.symmetric(horizontal: screenWidth * 0.04), | |
| ), | |
| ), | |
| ), | |
| ), | |
| // Password text field | |
| Positioned( | |
| top: screenHeight * 0.6, | |
| left: screenWidth * 0.1, | |
| right: screenWidth * 0.1, | |
| child: Container( | |
| height: screenHeight * 0.08, | |
| decoration: BoxDecoration( | |
| borderRadius: BorderRadius.circular(screenHeight * 0.04), | |
| color: const Color.fromRGBO(255, 255, 255, 1), | |
| ), | |
| child: TextField( | |
| obscureText: true, | |
| decoration: InputDecoration( | |
| hintText: 'Password', | |
| border: InputBorder.none, | |
| contentPadding: EdgeInsets.symmetric(horizontal: screenWidth * 0.04), | |
| ), | |
| ), | |
| ), | |
| ), | |
| // Repeat Password text field | |
| Positioned( | |
| top: screenHeight * 0.7, | |
| left: screenWidth * 0.1, | |
| right: screenWidth * 0.1, | |
| child: Container( | |
| height: screenHeight * 0.08, | |
| decoration: BoxDecoration( | |
| borderRadius: BorderRadius.circular(screenHeight * 0.04), | |
| color: const Color.fromRGBO(255, 255, 255, 1), | |
| ), | |
| child: TextField( | |
| obscureText: true, | |
| decoration: InputDecoration( | |
| hintText: 'Repeat password', | |
| border: InputBorder.none, | |
| contentPadding: EdgeInsets.symmetric(horizontal: screenWidth * 0.04), | |
| ), | |
| ), | |
| ), | |
| ), | |
| // Log in button | |
| Positioned( | |
| bottom: screenHeight * 0.121, | |
| left: screenWidth * 0.1, | |
| right: screenWidth * 0.1, | |
| child: Container( | |
| height: screenHeight * 0.08, | |
| decoration: BoxDecoration( | |
| borderRadius: BorderRadius.circular(screenHeight * 0.04), | |
| color: const Color.fromRGBO(0, 166, 147, 1), | |
| ), | |
| child: ElevatedButton( | |
| onPressed: _signUp, | |
| // onPressed: () { | |
| // Navigator.push(context, | |
| // MaterialPageRoute( | |
| // builder: (context) => const FloatingTab(), | |
| // )); | |
| // }, | |
| style: ElevatedButton.styleFrom( | |
| backgroundColor: const Color.fromRGBO(0, 166, 147, 1), | |
| shape: RoundedRectangleBorder( | |
| borderRadius: BorderRadius.circular(screenHeight * 0.04), | |
| ), | |
| ), | |
| child: Text( | |
| 'Log in', | |
| style: TextStyle( | |
| color: Colors.white, | |
| fontFamily: 'Montserrat', | |
| fontSize: screenHeight * 0.024, | |
| fontWeight: FontWeight.bold, | |
| ), | |
| ), | |
| ), | |
| ), | |
| ), | |
| Positioned( | |
| bottom: screenHeight * 0.07, | |
| left: screenWidth * 0.40, | |
| child: InkWell( | |
| onTap: () { | |
| // Add your navigation logic here when the text is clicked | |
| // For example, you can navigate to the login page | |
| Navigator.push( | |
| context, | |
| MaterialPageRoute( | |
| builder: (context) => const loginpage(), // Replace LoginPage with your desired page | |
| ), | |
| ); | |
| }, | |
| child: Text( | |
| 'Already have an account?', | |
| textAlign: TextAlign.center, | |
| style: TextStyle( | |
| decoration: TextDecoration.underline, | |
| color: Colors.red, | |
| fontFamily: 'Merriweather Sans', | |
| fontSize: screenHeight * 0.022, | |
| fontWeight: FontWeight.w400, | |
| ), | |
| ), | |
| ), | |
| ), | |
| ], | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| // ElevatedButton( | |
| // onPressed: _signUp, // Call the _signUp function when the button is pressed | |
| // // ... Rest of your button code ... | |
| // ), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment