signup_view.dart 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. // ignore_for_file: unused_local_variable, must_be_immutable
  2. // import packages
  3. import 'package:toast/toast.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:provider/provider.dart';
  6. import 'package:flutter/cupertino.dart';
  7. import 'package:flutter_form_builder/flutter_form_builder.dart';
  8. import 'package:form_field_validator/form_field_validator.dart';
  9. // import translation
  10. import 'package:gozap_package/components/localization/app_translations.dart';
  11. // import components
  12. import 'package:gozap_package/components/common.dart';
  13. import 'package:gozap_package/components/responsive.dart';
  14. import 'package:gozap_package/components/themes/themes.dart';
  15. // import model
  16. import 'package:gozap_package/models/signup/signup_model.dart';
  17. // import controller
  18. import 'package:gozap_package/controllers/signup/signup_controller.dart';
  19. // import View
  20. import 'package:gozap_package/views/log_in/log_in_view.dart';
  21. class SignupView extends StatefulWidget {
  22. SignupView({
  23. super.key,
  24. required this.nextScreen,
  25. });
  26. Widget nextScreen;
  27. @override
  28. State<SignupView> createState() => _SignupViewState();
  29. }
  30. class _SignupViewState extends State<SignupView> {
  31. final _globalLogin = GlobalKey<FormBuilderState>();
  32. bool _obscureTextLogin = true;
  33. @override
  34. Widget build(BuildContext context) {
  35. SignupController viewController = SignupController();
  36. return ChangeNotifierProvider<SignupModel>(
  37. create: (context) => SignupModel.instance(),
  38. child: Consumer<SignupModel>(
  39. builder: (context, viewModel, child) {
  40. var signupFormWidget = Container(
  41. constraints: const BoxConstraints(maxWidth: 400),
  42. padding: const EdgeInsets.all(20),
  43. child: Column(
  44. children: [
  45. //signup Form
  46. FormBuilder(
  47. key: _globalLogin,
  48. onChanged: () {
  49. _globalLogin.currentState!.save();
  50. },
  51. child: Column(
  52. children: <Widget>[
  53. //rider Name
  54. FormBuilderTextField(
  55. name: "name",
  56. inputFormatters: const [],
  57. validator: MultiValidator([
  58. RequiredValidator(
  59. errorText: AppTranslations.of(context)!
  60. .text("key_field_requird")),
  61. ]),
  62. keyboardType: TextInputType.text,
  63. textInputAction: TextInputAction.done,
  64. decoration: InputDecoration(
  65. border: OutlineInputBorder(
  66. borderRadius: BorderRadius.circular(20.0),
  67. ),
  68. errorBorder: OutlineInputBorder(
  69. borderRadius: BorderRadius.circular(20.0),
  70. borderSide:
  71. const BorderSide(color: Colors.red, width: 0.0),
  72. ),
  73. fillColor: Colors.white,
  74. filled: true,
  75. prefixIcon: const Icon(
  76. CupertinoIcons.person,
  77. color: Colors.black,
  78. size: 15.0,
  79. ),
  80. hintText: AppTranslations.of(context)!
  81. .text("key_login_field_RiderName"),
  82. ),
  83. ),
  84. const SizedBox(
  85. height: 20,
  86. ),//DE ID
  87. FormBuilderTextField(
  88. name: "DEID",
  89. inputFormatters: const [],
  90. validator: MultiValidator([
  91. RequiredValidator(
  92. errorText: AppTranslations.of(context)!
  93. .text("key_field_requird")),
  94. ]),
  95. keyboardType: TextInputType.number,
  96. textInputAction: TextInputAction.done,
  97. decoration: InputDecoration(
  98. border: OutlineInputBorder(
  99. borderRadius: BorderRadius.circular(20.0),
  100. ),
  101. errorBorder: OutlineInputBorder(
  102. borderRadius: BorderRadius.circular(20.0),
  103. borderSide:
  104. const BorderSide(color: Colors.red, width: 0.0),
  105. ),
  106. fillColor: Colors.white,
  107. filled: true,
  108. prefixIcon: const Icon(
  109. CupertinoIcons.person,
  110. color: Colors.black,
  111. size: 15.0,
  112. ),
  113. hintText: AppTranslations.of(context)!
  114. .text("key_login_field_DEID"),
  115. ),
  116. ),
  117. const SizedBox(
  118. height: 20,
  119. ),
  120. //rider ID / Phone Number
  121. FormBuilderTextField(
  122. name: "phonenumber",
  123. inputFormatters: const [],
  124. validator: MultiValidator([
  125. RequiredValidator(
  126. errorText: AppTranslations.of(context)!
  127. .text("key_field_requird")),
  128. MaxLengthValidator(10,
  129. errorText: AppTranslations.of(context)!
  130. .text("key_field_phonenumber_requird")),
  131. MinLengthValidator(10,
  132. errorText: AppTranslations.of(context)!
  133. .text("key_field_phonenumber_requird")),
  134. ]),
  135. keyboardType: TextInputType.number,
  136. textInputAction: TextInputAction.done,
  137. decoration: InputDecoration(
  138. border: OutlineInputBorder(
  139. borderRadius: BorderRadius.circular(20.0),
  140. ),
  141. errorBorder: OutlineInputBorder(
  142. borderRadius: BorderRadius.circular(20.0),
  143. borderSide:
  144. const BorderSide(color: Colors.red, width: 0.0),
  145. ),
  146. fillColor: Colors.white,
  147. filled: true,
  148. prefixIcon: const Icon(
  149. CupertinoIcons.person,
  150. color: Colors.black,
  151. size: 15.0,
  152. ),
  153. hintText: AppTranslations.of(context)!
  154. .text("key_login_field_PhoneNumber"),
  155. ),
  156. ),
  157. const SizedBox(
  158. height: 20,
  159. ),
  160. //Password
  161. FormBuilderTextField(
  162. name: "password",
  163. validator: MultiValidator([
  164. RequiredValidator(
  165. errorText: AppTranslations.of(context)!
  166. .text("key_field_requird")),
  167. ]),
  168. keyboardType: TextInputType.text,
  169. textInputAction: TextInputAction.done,
  170. obscureText: _obscureTextLogin,
  171. decoration: InputDecoration(
  172. border: OutlineInputBorder(
  173. borderRadius: BorderRadius.circular(20.0),
  174. ),
  175. errorBorder: OutlineInputBorder(
  176. borderRadius: BorderRadius.circular(20.0),
  177. borderSide:
  178. const BorderSide(color: Colors.red, width: 0.0),
  179. ),
  180. fillColor: Colors.white,
  181. filled: true,
  182. prefixIcon: const Icon(
  183. CupertinoIcons.lock_fill,
  184. color: Colors.black,
  185. size: 15.0,
  186. ),
  187. suffixIcon: GestureDetector(
  188. onTap: () {
  189. setState(() {
  190. _obscureTextLogin = !_obscureTextLogin;
  191. });
  192. },
  193. child: Icon(
  194. _obscureTextLogin
  195. ? CupertinoIcons.eye
  196. : CupertinoIcons.eye_slash_fill,
  197. color: Colors.black,
  198. size: 22.0,
  199. ),
  200. ),
  201. hintText: AppTranslations.of(context)!
  202. .text("key_login_field_Password"),
  203. ),
  204. ),
  205. const SizedBox(
  206. height: 20,
  207. ),
  208. FormBuilderTextField(
  209. name: "confirmpassword",
  210. validator: (val) => MatchValidator(
  211. errorText: AppTranslations.of(context)!.text(
  212. "key_signup_field_Password_missmatech"))
  213. .validateMatch(val!,
  214. _globalLogin.currentState?.value["password"]),
  215. // validator: MultiValidator([
  216. // RequiredValidator(
  217. // errorText: AppTranslations.of(context)!
  218. // .text("key_field_requird")),
  219. // ]),
  220. keyboardType: TextInputType.text,
  221. textInputAction: TextInputAction.done,
  222. obscureText: _obscureTextLogin,
  223. decoration: InputDecoration(
  224. border: OutlineInputBorder(
  225. borderRadius: BorderRadius.circular(20.0),
  226. ),
  227. errorBorder: OutlineInputBorder(
  228. borderRadius: BorderRadius.circular(20.0),
  229. borderSide:
  230. const BorderSide(color: Colors.red, width: 0.0),
  231. ),
  232. fillColor: Colors.white,
  233. filled: true,
  234. prefixIcon: const Icon(
  235. CupertinoIcons.lock_fill,
  236. color: Colors.black,
  237. size: 15.0,
  238. ),
  239. suffixIcon: GestureDetector(
  240. onTap: () {
  241. setState(() {
  242. _obscureTextLogin = !_obscureTextLogin;
  243. });
  244. },
  245. child: Icon(
  246. _obscureTextLogin
  247. ? CupertinoIcons.eye
  248. : CupertinoIcons.eye_slash_fill,
  249. color: Colors.black,
  250. size: 22.0,
  251. ),
  252. ),
  253. hintText: AppTranslations.of(context)!
  254. .text("key_login_field_Confrim_Password"),
  255. ),
  256. ),
  257. const SizedBox(
  258. height: 20,
  259. ),
  260. FormBuilderTextField(
  261. name: "referRiderid",
  262. inputFormatters: const [],
  263. validator: MultiValidator([
  264. RequiredValidator(
  265. errorText: AppTranslations.of(context)!
  266. .text("key_field_requird")),
  267. ]),
  268. keyboardType: TextInputType.text,
  269. textInputAction: TextInputAction.done,
  270. decoration: InputDecoration(
  271. border: OutlineInputBorder(
  272. borderRadius: BorderRadius.circular(20.0),
  273. ),
  274. errorBorder: OutlineInputBorder(
  275. borderRadius: BorderRadius.circular(20.0),
  276. borderSide:
  277. const BorderSide(color: Colors.red, width: 0.0),
  278. ),
  279. fillColor: Colors.white,
  280. filled: true,
  281. prefixIcon: const Icon(
  282. CupertinoIcons.person,
  283. color: Colors.black,
  284. size: 15.0,
  285. ),
  286. hintText: AppTranslations.of(context)!
  287. .text("key_login_field_ReferID"),
  288. ),
  289. ),
  290. const SizedBox(
  291. height: 20,
  292. ),
  293. //signup Button
  294. SizedBox(
  295. width: double.infinity,
  296. child: ElevatedButton(
  297. style: ButtonStyle(
  298. shape: MaterialStateProperty.all(
  299. RoundedRectangleBorder(
  300. // Change your radius here
  301. borderRadius: BorderRadius.circular(10),
  302. ),
  303. ),
  304. ),
  305. onPressed: () {
  306. if (_globalLogin
  307. .currentState?.value["confirmpassword"] !=
  308. _globalLogin
  309. .currentState?.value["password"]) {
  310. Toast.show(
  311. AppTranslations.of(context)!.text(
  312. "key_signup_field_Password_missmatech"),
  313. duration: Toast.lengthLong,
  314. gravity: Toast.bottom);
  315. } else if (_globalLogin
  316. .currentState?.value["name"] !=
  317. null &&
  318. _globalLogin
  319. .currentState?.value["phonenumber"] !=
  320. null &&
  321. _globalLogin
  322. .currentState?.value["password"] !=
  323. null &&
  324. _globalLogin.currentState
  325. ?.value["confirmpassword"] !=
  326. null) {
  327. viewModel.setter(context,
  328. data: _globalLogin.currentState?.value,
  329. nextScreen: widget.nextScreen);
  330. } else {
  331. Toast.show(
  332. AppTranslations.of(context)!
  333. .text("key_field_requird"),
  334. duration: Toast.lengthLong,
  335. gravity: Toast.bottom);
  336. }
  337. },
  338. child: Padding(
  339. padding: const EdgeInsets.all(10),
  340. child: Text(
  341. AppTranslations.of(context)!
  342. .text("key_btn_sign_up"),
  343. style: const TextStyle(fontSize: 16),
  344. ),
  345. )),
  346. ),
  347. ],
  348. ),
  349. ),
  350. const SizedBox(
  351. height: 20,
  352. ),
  353. //Forgor Password & Sign Up
  354. Row(
  355. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  356. children: [
  357. //Forgor Password
  358. TextButton(
  359. onPressed: () {},
  360. child: Text(
  361. AppTranslations.of(context)!
  362. .text("key_btn_forgot_password"),
  363. style: const TextStyle(
  364. decoration: TextDecoration.underline,
  365. ),
  366. ),
  367. ),
  368. //Sign Up
  369. TextButton(
  370. onPressed: () {
  371. Navigator.pushReplacement(
  372. context,
  373. MaterialPageRoute(
  374. builder: (context) =>
  375. LogInView(nextScreen: widget.nextScreen)));
  376. },
  377. child: Text(
  378. AppTranslations.of(context)!.text("key_btn_login"),
  379. style: const TextStyle(
  380. decoration: TextDecoration.underline,
  381. ),
  382. ),
  383. ),
  384. ],
  385. ),
  386. ],
  387. ),
  388. );
  389. return Scaffold(
  390. body: SizedBox(
  391. width: double.infinity,
  392. child: SingleChildScrollView(
  393. scrollDirection: Axis.vertical,
  394. child: ResponsiveWidget(
  395. mobileBody: Column(
  396. children: [
  397. //GoZAP Small Banner
  398. Common.brandSmallBannerWidget(context),
  399. //GoZAP Small Color Logo
  400. Common.brandSmallColorLogoWidget(context),
  401. //GoZAP Welcome Text
  402. Common.welcomeTextWidget(context),
  403. //GoZAP Welcome signup Phara
  404. Common.signupPharaWidget(context),
  405. //GoZAP signup Form
  406. signupFormWidget,
  407. ],
  408. ),
  409. desktopBody: Row(
  410. mainAxisAlignment: MainAxisAlignment.center,
  411. children: [
  412. Container(
  413. width: MediaQuery.of(context).size.width * .65,
  414. height: MediaQuery.of(context).size.height,
  415. color: AppTheme.secondaryColor,
  416. child: Column(
  417. mainAxisAlignment: MainAxisAlignment.center,
  418. children: [
  419. //GoZAP Large Banner
  420. Common.brandLargeBannerWidget(context),
  421. ],
  422. ),
  423. ),
  424. Expanded(
  425. child: Column(
  426. children: [
  427. //GoZAP Small Color Logo
  428. Common.brandSmallColorLogoWidget(context),
  429. //GoZAP Welcome Text
  430. Common.welcomeTextWidget(context),
  431. //GoZAP Welcome signup Phara
  432. Common.signupPharaWidget(context),
  433. //GoZAP signup Form
  434. signupFormWidget,
  435. ],
  436. ),
  437. )
  438. ],
  439. ),
  440. ),
  441. ),
  442. ),
  443. );
  444. },
  445. ),
  446. );
  447. }
  448. }