|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:google_fonts/google_fonts.dart'; |
| 3 | +import 'package:email_otp/email_otp.dart'; |
| 4 | + |
| 5 | +import 'Registration.dart'; |
| 6 | +import 'welcomeScreen.dart'; |
| 7 | + |
| 8 | +class Verify extends StatefulWidget { |
| 9 | + const Verify({super.key}); |
| 10 | + |
| 11 | + @override |
| 12 | + State<Verify> createState() => _VerifyState(); |
| 13 | +} |
| 14 | + |
| 15 | +late String _txt = ""; |
| 16 | +late String _Password = ""; |
| 17 | + |
| 18 | +class _VerifyState extends State<Verify> { |
| 19 | + EmailOTP myauth = EmailOTP(); |
| 20 | + |
| 21 | + @override |
| 22 | + Widget build(BuildContext context) { |
| 23 | + double h = (MediaQuery.of(context).size.height), |
| 24 | + w = (MediaQuery.of(context).size.width); |
| 25 | + return Scaffold( |
| 26 | + body: SingleChildScrollView( |
| 27 | + child: Container( |
| 28 | + color: Color(0xffFAFAFC), |
| 29 | + padding: EdgeInsets.only( |
| 30 | + top: h / 9, bottom: h / 15, left: w / 16, right: w / 16), |
| 31 | + child: Column( |
| 32 | + children: [ |
| 33 | + TopText(), |
| 34 | + SizedBox( |
| 35 | + height: h / 25, |
| 36 | + ), |
| 37 | + Row( |
| 38 | + children: [ |
| 39 | + SizedBox( |
| 40 | + width: w / 18, |
| 41 | + ), |
| 42 | + Align( |
| 43 | + alignment: Alignment.centerLeft, |
| 44 | + child: Text( |
| 45 | + textAlign: TextAlign.left, |
| 46 | + 'Verification', |
| 47 | + style: GoogleFonts.poppins( |
| 48 | + fontSize: w / 16, |
| 49 | + fontWeight: FontWeight.w600, |
| 50 | + color: Color(0xffFFBA25)), |
| 51 | + ), |
| 52 | + ), |
| 53 | + ], |
| 54 | + ), |
| 55 | + SizedBox( |
| 56 | + height: h / 30, |
| 57 | + ), |
| 58 | + Container( |
| 59 | + margin: EdgeInsets.symmetric(horizontal: h / 80), |
| 60 | + padding: EdgeInsets.only(left: w / 80), |
| 61 | + height: h / 13, |
| 62 | + decoration: BoxDecoration( |
| 63 | + color: Colors.white, |
| 64 | + borderRadius: BorderRadius.circular(15), |
| 65 | + boxShadow: Shadow, |
| 66 | + ), |
| 67 | + child: Center( |
| 68 | + child: TextFormField( |
| 69 | + onChanged: (value) { |
| 70 | + _txt = value; |
| 71 | + }, |
| 72 | + decoration: InputDecoration( |
| 73 | + border: InputBorder.none, |
| 74 | + hintText: 'Email', |
| 75 | + hintStyle: GoogleFonts.poppins( |
| 76 | + fontSize: w / 25, color: Colors.grey[500]), |
| 77 | + prefixIcon: Icon( |
| 78 | + Icons.person, |
| 79 | + color: Colors.grey[500], |
| 80 | + )), |
| 81 | + ), |
| 82 | + ), |
| 83 | + ), |
| 84 | + Align( |
| 85 | + alignment: Alignment.centerRight, |
| 86 | + child: GestureDetector( |
| 87 | + onTap: () async { |
| 88 | + myauth.setConfig( |
| 89 | + |
| 90 | + appName: "Email OTP", |
| 91 | + userEmail: _txt, |
| 92 | + otpLength: 6, |
| 93 | + otpType: OTPType.digitsOnly); |
| 94 | + if (await myauth.sendOTP() == true) { |
| 95 | + ScaffoldMessenger.of(context) |
| 96 | + .showSnackBar(const SnackBar( |
| 97 | + content: Text("OTP has been sent"), |
| 98 | + )); |
| 99 | + } else { |
| 100 | + ScaffoldMessenger.of(context) |
| 101 | + .showSnackBar(const SnackBar( |
| 102 | + content: Text("Oops, OTP send failed"), |
| 103 | + )); |
| 104 | + } |
| 105 | + }, |
| 106 | + child: Container( |
| 107 | + padding: EdgeInsets.symmetric( |
| 108 | + horizontal: w / 15, vertical: h / 80), |
| 109 | + child: Text( |
| 110 | + 'SendOtp', |
| 111 | + ))), |
| 112 | + ), |
| 113 | + SizedBox( |
| 114 | + height: h / 35, |
| 115 | + ), |
| 116 | + Container( |
| 117 | + margin: EdgeInsets.symmetric(horizontal: h / 80), |
| 118 | + height: h / 13, |
| 119 | + decoration: BoxDecoration( |
| 120 | + color: Colors.white, |
| 121 | + borderRadius: BorderRadius.circular(15), |
| 122 | + boxShadow: Shadow, |
| 123 | + ), |
| 124 | + child: Center( |
| 125 | + child: TextFormField( |
| 126 | + onChanged: (value) { |
| 127 | + _Password = value; |
| 128 | + }, |
| 129 | + decoration: InputDecoration( |
| 130 | + border: InputBorder.none, |
| 131 | + hintText: 'OTP', |
| 132 | + hintStyle: GoogleFonts.poppins( |
| 133 | + fontSize: w / 25, color: Colors.grey[500]), |
| 134 | + prefixIcon: Icon( |
| 135 | + Icons.lock_outline_rounded, |
| 136 | + color: Colors.grey[500], |
| 137 | + ), |
| 138 | + suffixIcon: IconButton( |
| 139 | + icon: Icn, |
| 140 | + color: Colors.grey[500], |
| 141 | + onPressed: () { |
| 142 | + setState(() { |
| 143 | + pressed = !pressed; |
| 144 | + }); |
| 145 | + }), |
| 146 | + ), |
| 147 | + ), |
| 148 | + ), |
| 149 | + ), |
| 150 | + SizedBox( |
| 151 | + height: h / 15, |
| 152 | + ), |
| 153 | + GestureDetector( |
| 154 | + onTap: () async { |
| 155 | + setState(() async { |
| 156 | + if (await myauth.verifyOTP(otp: _Password) == true) { |
| 157 | + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( |
| 158 | + content: Text("OTP is verified"), |
| 159 | + )); |
| 160 | + Navigator.push( |
| 161 | + context, |
| 162 | + MaterialPageRoute( |
| 163 | + builder: (context) => Registpage())); |
| 164 | + } else { |
| 165 | + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( |
| 166 | + content: Text("Invalid OTP"), |
| 167 | + )); |
| 168 | + } |
| 169 | + }); |
| 170 | + }, |
| 171 | + child: Padding( |
| 172 | + padding: const EdgeInsets.symmetric(horizontal: 30), |
| 173 | + child: Container( |
| 174 | + margin: EdgeInsets.only(top: 20), |
| 175 | + height: h / 14, |
| 176 | + width: w / 1.18, |
| 177 | + decoration: BoxDecoration( |
| 178 | + gradient: const LinearGradient( |
| 179 | + colors: [Color(0xffFFDA94), Color(0xffFF942F)], |
| 180 | + begin: Alignment.topCenter, |
| 181 | + end: Alignment.bottomCenter), |
| 182 | + borderRadius: BorderRadius.circular(12), |
| 183 | + color: Color(0xff4BB0FE)), |
| 184 | + child: Center( |
| 185 | + child: Text( |
| 186 | + 'Verify', |
| 187 | + style: GoogleFonts.poppins( |
| 188 | + fontSize: w / 24.5, |
| 189 | + fontWeight: FontWeight.w600, |
| 190 | + color: Colors.white), |
| 191 | + ), |
| 192 | + ), |
| 193 | + ), |
| 194 | + ), |
| 195 | + ), |
| 196 | + ], |
| 197 | + ), |
| 198 | + ), |
| 199 | + ), |
| 200 | + ); |
| 201 | + } |
| 202 | +} |
| 203 | + |
| 204 | +List<BoxShadow> Shadow = [ |
| 205 | + BoxShadow(color: Colors.grey[300]!, blurRadius: 10, offset: Offset(0, 10)) |
| 206 | +]; |
0 commit comments