SignupPage.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. import 'package:flutter/material.dart';
  2. class SignupPage extends StatefulWidget {
  3. const SignupPage({Key? key}) : super(key: key);
  4. @override
  5. State<SignupPage> createState() => _SignupPageState();
  6. }
  7. class _SignupPageState extends State<SignupPage> {
  8. int _pageIndex = 0;
  9. List<Widget> forms = [SignupForm1(title: '',), SignupForm2(title: '',), SignupForm3(title: '',)];
  10. void _updatePageIndex(int newPageIndex) {
  11. if(newPageIndex == -1) {
  12. Navigator.pushNamed(context, '/');
  13. } else if (newPageIndex == 3) {
  14. //autentification
  15. newPageIndex = 2;
  16. } else {
  17. setState(() {
  18. _pageIndex = newPageIndex;
  19. });
  20. }
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return Scaffold(
  25. floatingActionButton: Row(
  26. mainAxisAlignment: MainAxisAlignment.end,
  27. children: [
  28. FloatingActionButton(child: Icon(Icons.navigate_before_outlined),
  29. onPressed: () => _updatePageIndex(_pageIndex - 1)
  30. ),
  31. SizedBox(
  32. width: 25,
  33. ),
  34. FloatingActionButton(child: Icon(Icons.navigate_next_outlined),
  35. onPressed: () => _updatePageIndex(_pageIndex +1 ))
  36. ],
  37. ),
  38. body: Center(child: forms[_pageIndex]),
  39. );
  40. }
  41. }
  42. class SignupForm1 extends StatefulWidget {
  43. const SignupForm1({Key? key, required this.title}) : super(key: key);
  44. final String title;
  45. @override
  46. //_RegisterScreen createState() => _RegisterScreen();
  47. State<SignupForm1> createState() => _SignupForm1();
  48. }
  49. class _SignupForm1 extends State<SignupForm1> {
  50. DateTime? _dateTime;
  51. String? _dateString;
  52. @override
  53. Widget build(BuildContext context) {
  54. return Scaffold(
  55. appBar: AppBar(
  56. title: const Text('Register Screen'),
  57. ),
  58. body: Center(
  59. child: SizedBox(
  60. width: 300,
  61. child: Column(children: <Widget>[
  62. const SizedBox(height: 30),
  63. Text(
  64. 'Personal Information',
  65. style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
  66. ),
  67. const SizedBox(height: 30),
  68. Image.asset(
  69. 'assets/user.png',
  70. width: 150,
  71. ),
  72. const SizedBox(height: 30),
  73. TextField(
  74. decoration: InputDecoration(
  75. hintText: 'Name',
  76. ),
  77. ),
  78. const SizedBox(height: 10),
  79. TextField(
  80. decoration: InputDecoration(
  81. hintText: 'Surname',
  82. ),
  83. ),
  84. const SizedBox(height: 10),
  85. Row(children: <Widget>[
  86. Text(_dateString == null
  87. ? 'Select birthday date :'
  88. : _dateString.toString()),
  89. const SizedBox(width: 49),
  90. ElevatedButton(
  91. onPressed: () {
  92. showDatePicker(
  93. context: context,
  94. initialDate: DateTime.now(),
  95. firstDate: DateTime(1900),
  96. lastDate: DateTime(2222))
  97. .then((date) {
  98. setState(() {
  99. _dateTime = date!;
  100. _dateString = "${date.day}/${date.month}/${date.year}";
  101. });
  102. });
  103. },
  104. child: const Text('Select date'),
  105. ),
  106. ]),
  107. const SizedBox(height: 10),
  108. ]),
  109. )),
  110. );
  111. }
  112. }
  113. class SignupForm2 extends StatefulWidget {
  114. const SignupForm2({Key? key, required this.title}) : super(key: key);
  115. final String title;
  116. @override
  117. //_RegisterScreen createState() => _RegisterScreen();
  118. State<SignupForm2> createState() => _SignupForm2();
  119. }
  120. class _SignupForm2 extends State<SignupForm2> {
  121. bool isChecked = false;
  122. @override
  123. Widget build(BuildContext context) {
  124. return Scaffold(
  125. appBar: AppBar(
  126. title: const Text('Register Screen'),
  127. ),
  128. body: Center(
  129. child: SizedBox(
  130. width: 300,
  131. child: Column(children: <Widget>[
  132. const SizedBox(height: 30),
  133. Text(
  134. 'Contact Details',
  135. style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
  136. ),
  137. const SizedBox(height: 30),
  138. Image.asset(
  139. 'assets/communicate.png',
  140. width: 150,
  141. ),
  142. const SizedBox(height: 30),
  143. TextField(
  144. decoration: InputDecoration(
  145. hintText: 'Mail',
  146. ),
  147. ),
  148. const SizedBox(height: 10),
  149. TextField(
  150. decoration: InputDecoration(
  151. hintText: 'Phone Number',
  152. ),
  153. ),
  154. const SizedBox(height: 10),
  155. TextField(
  156. decoration: InputDecoration(
  157. hintText: 'Home Adress..',
  158. ),
  159. ),
  160. const SizedBox(height: 10),
  161. Row(children: <Widget>[
  162. Text('Anonymous'),
  163. Checkbox(
  164. checkColor: Colors.white,
  165. value: isChecked,
  166. onChanged: (bool? value) {
  167. setState(() {
  168. isChecked = value!;
  169. });
  170. },),
  171. ]),
  172. const SizedBox(height: 10),
  173. ]),
  174. )),
  175. );
  176. }
  177. }
  178. class SignupForm3 extends StatefulWidget {
  179. const SignupForm3({Key? key, required this.title}) : super(key: key);
  180. final String title;
  181. @override
  182. //_RegisterScreen createState() => _RegisterScreen();
  183. State<SignupForm3> createState() => _SignupForm3();
  184. }
  185. class _SignupForm3 extends State<SignupForm3> {
  186. @override
  187. Widget build(BuildContext context) {
  188. return Scaffold(
  189. appBar: AppBar(
  190. title: const Text('Register Screen'),
  191. ),
  192. body: Center(
  193. child: SizedBox(
  194. width: 300,
  195. child: Column(children: <Widget>[
  196. const SizedBox(height: 30),
  197. Text(
  198. 'User details',
  199. style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
  200. ),
  201. const SizedBox(height: 30),
  202. Image.asset(
  203. 'assets/id-card.png',
  204. width: 150,
  205. ),
  206. const SizedBox(height: 30),
  207. TextField(
  208. decoration: InputDecoration(
  209. hintText: 'Username',
  210. ),
  211. ),
  212. const SizedBox(height: 10),
  213. TextField(
  214. decoration: InputDecoration(
  215. hintText: 'Password',
  216. ),
  217. ),
  218. const SizedBox(height: 10),
  219. TextField(
  220. decoration: InputDecoration(
  221. hintText: 'Repeat password',
  222. ),
  223. ),
  224. const SizedBox(height: 10),
  225. ]),
  226. )),
  227. );
  228. }
  229. }