Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class SignUp extends StatefulWidget {
  4. @override
  5. _SignUpState createState() => _SignUpState();
  6. }
  7.  
  8. class _SignUpState extends State<SignUp> {
  9. int _currentIndex = 0;
  10. @override
  11. Widget build(BuildContext context) {
  12. double _height = MediaQuery.of(context).size.height;
  13. double _width = MediaQuery.of(context).size.width;
  14. return Scaffold(
  15. body: SafeArea(
  16. child: Container(
  17. color: Colors.white,
  18. height: _height,
  19. width: _width,
  20. child: SingleChildScrollView(
  21. padding: const EdgeInsets.only(),
  22. child: Column(
  23. children: <Widget>[
  24. Padding(
  25. padding: const EdgeInsets.only(top: 8.0, left: 12.0, bottom: 20),
  26. child: Stack(
  27. children: <Widget>[
  28. GestureDetector(
  29. child: Icon(Icons.keyboard_backspace),
  30. onTap: () {
  31. if (_currentIndex > 0) {
  32. setState(() {
  33. _currentIndex = _currentIndex - 1;
  34. });
  35. } else {
  36. return null;
  37. }
  38. }),
  39. Container(
  40. alignment: Alignment.center,
  41. child: Text(
  42. 'Sign Up',
  43. style: TextStyle(
  44. fontWeight: FontWeight.bold,
  45. fontSize: 25.0,
  46. ),
  47. textAlign: TextAlign.center,
  48. ),
  49. ),
  50. ],
  51. ),
  52. ),
  53. Container(
  54. color: Colors.white,
  55. height: _height * 0.8,
  56. width: _width,
  57. child: _buildTheListOfContainers(context)[_currentIndex],
  58. )
  59. ],
  60. ),
  61. ),
  62. )));
  63. }
  64.  
  65. List<Widget> _buildTheListOfContainers(BuildContext context) {
  66. List<Widget> containers = [
  67. _buildSignUpContainer(
  68. context: context,
  69. text: 'When\'s your birthday?',
  70. labelText: 'BIRTHDAY',
  71. function: () {
  72. _currentIndex = _currentIndex + 1;
  73. },
  74. hintText: 'dd/mm/yyyy',
  75. ),
  76. _buildSignUpContainer(
  77. context: context,
  78. text : 'What\'s your email?',
  79. labelText: 'E-mail',
  80. function: () {
  81. _currentIndex = _currentIndex + 1;
  82. },
  83. ),
  84. _buildSignUpContainer(
  85. context:context,
  86. text: 'Create a password',
  87. labelText: 'Password',
  88. function:() {
  89. _currentIndex = _currentIndex + 1;
  90. },
  91. ),
  92. Column(
  93. crossAxisAlignment: CrossAxisAlignment.start,
  94. children: <Widget>[
  95. _buildSignUpContainer(
  96. context: context,
  97. text: 'Create a username',
  98. labelText:'Username',
  99. function: () {
  100. //_currentIndex = _currentIndex + 1;
  101. },
  102. buttonText:'SIGN UP',
  103. ),
  104. Padding(
  105. padding: const EdgeInsets.only(top: 10.0, left: 20.0),
  106. child: Row(children: <Widget>[
  107. Text('By pressing Sign Up, you agree to the '),
  108. GestureDetector(child: Text('Terms and Condition.', style: TextStyle(color: Colors.amber, decoration: TextDecoration.underline)), onTap: () => null,)
  109. ],),
  110. )
  111. ],)
  112.  
  113. ];
  114. return containers;
  115. }
  116.  
  117. Widget _buildSignUpContainer(
  118. {BuildContext context,
  119. String text,
  120. String labelText,
  121. Function function,
  122. String hintText = '',
  123. String buttonText = 'CONTINUE'}) {
  124. return Container(
  125. margin: const EdgeInsets.only(top: 50),
  126. color: Colors.white,
  127. child: Column(
  128. crossAxisAlignment: CrossAxisAlignment.start,
  129. children: <Widget>[
  130. Padding(
  131. padding: const EdgeInsets.only(
  132. left: 20.0,
  133. ),
  134. child: Text(
  135. text,
  136. style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
  137. ),
  138. ),
  139. Padding(
  140. padding: const EdgeInsets.only(left: 20.0, right: 20.0),
  141. child: TextField(
  142. decoration:
  143. InputDecoration(labelText: labelText, hintText: hintText,),
  144. keyboardType: labelText == 'BIRTHDAY' ? TextInputType.number : TextInputType.text
  145. ),
  146. ),
  147. InkWell(
  148. onTap: () {
  149. setState(() {
  150. function();
  151. });
  152. },
  153. child: Container(
  154. margin: const EdgeInsets.only(left: 20, right: 20, top: 35),
  155. alignment: Alignment.center,
  156. width: 400,
  157. height: 45.0,
  158. decoration: BoxDecoration(
  159. color: Colors.orange[400],
  160. border: Border.all(color: Colors.white, width: 2.0),
  161. borderRadius: BorderRadius.circular(10.0),
  162. ),
  163. child: Text(
  164. buttonText,
  165. style: TextStyle(fontSize: 18.0, color: Colors.white),
  166. ),
  167. ),
  168. ),
  169. ],
  170. ),
  171. );
  172. }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement