|
1 | 1 | import 'package:flutter/material.dart';
|
2 | 2 | import 'package:flutter_ui_nice/const/gradient_const.dart';
|
| 3 | +import 'package:flutter_ui_nice/const/size_const.dart'; |
| 4 | +import 'dart:async'; |
| 5 | +import 'package:google_places_picker/google_places_picker.dart'; |
| 6 | +import 'package:intl/intl.dart'; |
3 | 7 |
|
4 | 8 | class SignPageSeven extends StatefulWidget {
|
5 | 9 | @override
|
6 | 10 | _SignPageSevenState createState() => _SignPageSevenState();
|
7 | 11 | }
|
8 | 12 |
|
9 | 13 | class _SignPageSevenState extends State<SignPageSeven> {
|
| 14 | + String _currentDate = DateFormat('M/d/y').format(DateTime.now()); |
| 15 | + List<String> _countries = ["Germany", "Turkey", "Spain"]; |
| 16 | + List<String> _states = ["Hessen", "Istanbul", "Barcelona"]; |
| 17 | + String _currentCountry = "Germany"; |
| 18 | + String _currentState = "Hessen"; |
| 19 | + Place _place; |
| 20 | + void changeDropDownCountryItem(String selectedCountry) { |
| 21 | + setState(() { |
| 22 | + _currentCountry = selectedCountry; |
| 23 | + }); |
| 24 | + } |
| 25 | + |
| 26 | + void changeDropDownStateItem(String selectedState) { |
| 27 | + setState(() { |
| 28 | + _currentState = selectedState; |
| 29 | + }); |
| 30 | + } |
| 31 | + |
| 32 | + Future _selectDate() async { |
| 33 | + DateTime picked = await showDatePicker( |
| 34 | + context: context, |
| 35 | + initialDate: new DateTime.now(), |
| 36 | + firstDate: new DateTime(2016), |
| 37 | + lastDate: new DateTime(2050)); |
| 38 | + if (picked != null) |
| 39 | + setState( |
| 40 | + () => _currentDate = DateFormat('M/d/y').format(picked), |
| 41 | + ); |
| 42 | + } |
| 43 | + |
| 44 | + Future _selectPlace(BuildContext context) async { |
| 45 | + try { |
| 46 | + Place _picker = await PluginGooglePlacePicker.showPlacePicker(); |
| 47 | + setState(() { |
| 48 | + _place = _picker; |
| 49 | + }); |
| 50 | + } catch (e) {} |
| 51 | + } |
| 52 | + |
10 | 53 | @override
|
11 | 54 | Widget build(BuildContext context) {
|
12 | 55 | final _media = MediaQuery.of(context).size;
|
13 |
| - final _toolbarSize = MediaQuery.of(context).padding; |
14 | 56 | return Scaffold(
|
15 | 57 | body: SingleChildScrollView(
|
16 | 58 | physics: BouncingScrollPhysics(),
|
@@ -74,24 +116,190 @@ class _SignPageSevenState extends State<SignPageSeven> {
|
74 | 116 | ),
|
75 | 117 | ],
|
76 | 118 | ),
|
77 |
| - Container( |
78 |
| - margin: EdgeInsets.only( |
79 |
| - top: 110, |
80 |
| - left: 50, |
81 |
| - right: 50, |
82 |
| - bottom: 100, |
83 |
| - ), |
84 |
| - height: _media.height, |
85 |
| - width: _media.width, |
86 |
| - decoration: BoxDecoration( |
87 |
| - borderRadius: BorderRadius.circular(10), |
88 |
| - color: Colors.red, |
89 |
| - ), |
| 119 | + Stack( |
| 120 | + children: <Widget>[ |
| 121 | + Container( |
| 122 | + margin: EdgeInsets.only( |
| 123 | + top: 110, |
| 124 | + left: 50, |
| 125 | + right: 50, |
| 126 | + bottom: 80, |
| 127 | + ), |
| 128 | + height: _media.height, |
| 129 | + width: _media.width, |
| 130 | + decoration: BoxDecoration( |
| 131 | + borderRadius: BorderRadius.circular(10), |
| 132 | + gradient: SIGNUP_CARD_BACKGROUND, |
| 133 | + boxShadow: [ |
| 134 | + BoxShadow( |
| 135 | + color: Colors.grey.shade400, |
| 136 | + blurRadius: 30, |
| 137 | + spreadRadius: 0, |
| 138 | + offset: Offset( |
| 139 | + 0, |
| 140 | + 10, |
| 141 | + ), |
| 142 | + ) |
| 143 | + ], |
| 144 | + ), |
| 145 | + child: Padding( |
| 146 | + padding: const EdgeInsets.only( |
| 147 | + left: 25.0, |
| 148 | + right: 25, |
| 149 | + top: 30, |
| 150 | + ), |
| 151 | + child: Column( |
| 152 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 153 | + mainAxisAlignment: MainAxisAlignment.start, |
| 154 | + children: <Widget>[ |
| 155 | + formTextField("DATE OF BIRTH"), |
| 156 | + buildDivider(), |
| 157 | + buildDropdown("COUNTRY", _countries, _currentCountry, |
| 158 | + changeDropDownCountryItem), |
| 159 | + buildDivider(), |
| 160 | + buildDropdown("STATE", _states, _currentState, |
| 161 | + changeDropDownStateItem), |
| 162 | + buildDivider(), |
| 163 | + buildCity("CITY", context), |
| 164 | + buildDivider(), |
| 165 | + buildCity("STREET", context), |
| 166 | + buildDivider(), |
| 167 | + ], |
| 168 | + ), |
| 169 | + ), |
| 170 | + ), |
| 171 | + ], |
90 | 172 | ),
|
91 | 173 | ],
|
92 | 174 | ),
|
93 | 175 | ),
|
94 | 176 | ),
|
95 | 177 | );
|
96 | 178 | }
|
| 179 | + |
| 180 | + Widget buildCity(String text, BuildContext context) { |
| 181 | + return Column( |
| 182 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 183 | + mainAxisAlignment: MainAxisAlignment.center, |
| 184 | + children: <Widget>[ |
| 185 | + Text( |
| 186 | + text, |
| 187 | + style: TextStyle( |
| 188 | + fontSize: 10.5, |
| 189 | + fontWeight: FontWeight.w500, |
| 190 | + color: Colors.black26, |
| 191 | + ), |
| 192 | + ), |
| 193 | + Padding( |
| 194 | + padding: const EdgeInsets.only(top: 15.0, bottom: 20), |
| 195 | + child: InkWell( |
| 196 | + onTap: () => _selectPlace(context), |
| 197 | + child: Text( |
| 198 | + _place != null ? _place.name : 'Frankfurt am Main', |
| 199 | + style: TextStyle( |
| 200 | + letterSpacing: 2.0, |
| 201 | + color: Color(0xff353535), |
| 202 | + fontSize: 12.0, |
| 203 | + fontWeight: FontWeight.bold, |
| 204 | + fontFamily: 'Montserrat'), |
| 205 | + overflow: TextOverflow.fade, |
| 206 | + ), |
| 207 | + ), |
| 208 | + ) |
| 209 | + ], |
| 210 | + ); |
| 211 | + } |
| 212 | + |
| 213 | + Widget formTextField(String text) { |
| 214 | + return Column( |
| 215 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 216 | + mainAxisAlignment: MainAxisAlignment.center, |
| 217 | + children: <Widget>[ |
| 218 | + Text( |
| 219 | + text, |
| 220 | + style: TextStyle( |
| 221 | + fontSize: 10.5, |
| 222 | + fontWeight: FontWeight.w500, |
| 223 | + color: Colors.black26, |
| 224 | + ), |
| 225 | + ), |
| 226 | + TextField( |
| 227 | + keyboardType: TextInputType.datetime, |
| 228 | + onTap: _selectDate, |
| 229 | + decoration: InputDecoration( |
| 230 | + border: InputBorder.none, |
| 231 | + hintText: _currentDate, |
| 232 | + hintStyle: TextStyle( |
| 233 | + letterSpacing: 2.0, |
| 234 | + color: Color(0xff353535), |
| 235 | + fontSize: 12.0, |
| 236 | + fontWeight: FontWeight.bold, |
| 237 | + fontFamily: 'Montserrat', |
| 238 | + ), |
| 239 | + suffixIcon: Padding( |
| 240 | + padding: const EdgeInsets.only(left: 25.0), |
| 241 | + child: Icon( |
| 242 | + Icons.arrow_drop_down, |
| 243 | + color: Colors.grey.shade700, |
| 244 | + ), |
| 245 | + ), |
| 246 | + ), |
| 247 | + ), |
| 248 | + ], |
| 249 | + ); |
| 250 | + } |
| 251 | + |
| 252 | + Column buildDropdown( |
| 253 | + String text, List dropDownList, String current, Function change) { |
| 254 | + return Column( |
| 255 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 256 | + mainAxisAlignment: MainAxisAlignment.center, |
| 257 | + children: <Widget>[ |
| 258 | + Text( |
| 259 | + text, |
| 260 | + style: TextStyle( |
| 261 | + fontSize: 10.5, |
| 262 | + fontWeight: FontWeight.w500, |
| 263 | + color: Colors.black26, |
| 264 | + ), |
| 265 | + ), |
| 266 | + DropdownButtonHideUnderline( |
| 267 | + child: DropdownButton<String>( |
| 268 | + style: TextStyle( |
| 269 | + letterSpacing: 2.0, |
| 270 | + color: Color(0xff353535), |
| 271 | + fontSize: 12.0, |
| 272 | + fontWeight: FontWeight.bold, |
| 273 | + fontFamily: 'Montserrat', |
| 274 | + ), |
| 275 | + isExpanded: true, |
| 276 | + onChanged: change, |
| 277 | + items: dropDownList.map((items) { |
| 278 | + return DropdownMenuItem<String>( |
| 279 | + value: items, |
| 280 | + child: Text( |
| 281 | + items, |
| 282 | + style: TextStyle( |
| 283 | + letterSpacing: 1.1, |
| 284 | + ), |
| 285 | + ), |
| 286 | + ); |
| 287 | + }).toList(), |
| 288 | + value: current, |
| 289 | + ), |
| 290 | + ), |
| 291 | + ], |
| 292 | + ); |
| 293 | + } |
| 294 | + |
| 295 | + Container buildDivider() { |
| 296 | + return Container( |
| 297 | + margin: EdgeInsets.only(top: 0, right: 8, bottom: 15), |
| 298 | + padding: EdgeInsets.only( |
| 299 | + right: 5, |
| 300 | + ), |
| 301 | + color: Colors.black, |
| 302 | + height: 1.2, |
| 303 | + ); |
| 304 | + } |
97 | 305 | }
|
0 commit comments