Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.26 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:the_mill_flutter/Helpers/AppState.dart';
  3. import 'package:the_mill_flutter/Helpers/NavigationHelpers.dart';
  4. import 'package:the_mill_flutter/Models/form.dart';
  5. import 'package:the_mill_flutter/StyleSource/styles.dart';
  6. import 'package:the_mill_flutter/StyleSource/textformfields.dart';
  7. import 'package:the_mill_flutter/StyleSource/themes.dart';
  8. import 'dart:math';
  9.  
  10. class BdtCreateWODesso extends StatefulWidget {
  11. @override
  12. _BdtCreateWODessoState createState() => _BdtCreateWODessoState();
  13. }
  14.  
  15. class _BdtCreateWODessoState extends State<BdtCreateWODesso> {
  16. List<Widget> _children = [];
  17. int _count = 1;
  18.  
  19. int _key;
  20.  
  21. _collapse() {
  22. int newKey;
  23. do {
  24. _key = new Random().nextInt(10000);
  25. } while (newKey == _key);
  26. }
  27.  
  28. @override
  29. void initState() {
  30. super.initState();
  31. _collapse();
  32. }
  33.  
  34. final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
  35.  
  36. @override
  37. Widget build(BuildContext context) {
  38. AppState state = AppContainer.of(context);
  39. return Scaffold(
  40. appBar: AppBar(
  41. iconTheme: IconThemeData(color: MillTheme.title),
  42. title: Text(
  43. "CREATE WORK ORDER",
  44. style: AppStyles.textStyleTitle(),
  45. ),
  46. backgroundColor: Colors.transparent,
  47. elevation: 0.0,
  48. centerTitle: true,
  49. actions: <Widget>[
  50. IconButton(
  51. icon: Icon(
  52. Icons.notifications,
  53. color: MillTheme.title,
  54. ),
  55. onPressed: () {
  56. NavigationHelpers.goToNoti(context);
  57. },
  58. )
  59. ],
  60. ),
  61. floatingActionButton: Padding(
  62. padding: const EdgeInsets.only(top: 25.0),
  63. child: RaisedButton(
  64. color: MillTheme.millBlue,
  65. child: Text('Add new'),
  66. textColor: MillTheme.bgWelcome,
  67. onPressed: (() {
  68. setState(() {
  69. _add();
  70. });
  71. }),
  72. ),
  73. ),
  74. floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
  75. body: SingleChildScrollView(
  76. child: Card(
  77. child: new ExpansionTile(
  78. key: new Key(_key.toString()),
  79. initiallyExpanded: false,
  80. title: new Text('Product ${_count}'),
  81. backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
  82. children: [
  83. new Container(
  84. child: Builder(
  85. builder: (context) => Form(
  86. key: _formKey,
  87. child: SingleChildScrollView(
  88. padding: const EdgeInsets.all(20),
  89. child: Column(
  90. crossAxisAlignment: CrossAxisAlignment.stretch,
  91. children: <Widget>[
  92. TextFormFields.build(
  93. label: 'Product',
  94. validator: Validator._notNull,
  95. onSaved: (value) =>
  96. state.formDesso.desso_product = value),
  97. TextFormFields.build(
  98. label: 'Color',
  99. validator: Validator._notNull,
  100. onSaved: (value) =>
  101. state.formDesso.desso_color = value),
  102. TextFormFields.build(
  103. label: 'Area',
  104. validator: Validator._notNull,
  105. onSaved: (value) =>
  106. state.formDesso.desso_area = value),
  107. TextFormFields.build(
  108. label: 'Unit Price',
  109. validator: Validator._notNull,
  110. onSaved: (value) =>
  111. state.formDesso.desso_unitPrice = value),
  112. TextFormFields.build(
  113. label: 'Selling Price',
  114. validator: Validator._notNull,
  115. onSaved: (value) =>
  116. state.formDesso.desso_sellingPrice = value),
  117. TextFormFields.build(
  118. label: 'Estimated Roll(s)',
  119. validator: Validator._notNull,
  120. onSaved: (value) =>
  121. state.formDesso.desso_rolls = value),
  122. TextFormFields.build(
  123. label: 'Remarks',
  124. validator: Validator._notNull,
  125. onSaved: (value) =>
  126. state.formDesso.remarks_desso = value),
  127. Texts.build(
  128. 'Special Instructions',
  129. ),
  130. TextFormFields.buildNewCustomerTextField(
  131. label: 'For Operation Team',
  132. validator: Validator._notNull,
  133. onSaved: (value) =>
  134. state.formDesso.special_desso_OT = value),
  135. TextFormFields.buildNewCustomerTextField(
  136. label: 'For Account Team',
  137. validator: Validator._notNull,
  138. onSaved: (value) =>
  139. state.formDesso.special_desso_AT = value),
  140. Padding(
  141. child: Row(
  142. mainAxisAlignment: MainAxisAlignment.end,
  143. children: <Widget>[
  144. ButtonTheme(
  145. minWidth: 100.0,
  146. height: 40.0,
  147. buttonColor: MillTheme.millBlue,
  148. child: RaisedButton(
  149. onPressed: () {
  150. setState(() {
  151. _collapse();
  152. _formKey.currentState.save();
  153. });
  154. },
  155. child: Text("Done"),
  156. textColor: MillTheme.bgWelcome,
  157. ),
  158. ),
  159. ]),
  160. padding: EdgeInsets.only(left: 15.0))
  161. ],
  162. ),
  163. ),
  164. ),
  165. ),
  166. ),
  167. ],
  168. ),
  169. ),
  170. ),
  171. // Padding(
  172. // padding: const EdgeInsets.only(top: 30.0),
  173. // child: Container(
  174. // child: ListView(children: _children.toList()),
  175. // )),
  176. );
  177. }
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. //
  190. // void _add() {
  191. // final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
  192. //
  193. // AppState state = AppContainer.of(context);
  194. //
  195. // _children = List.from(_children)
  196. // ..add(
  197. // Card(
  198. // child: new ExpansionTile(
  199. // initiallyExpanded: false,
  200. // title: new Text('Product ${_count}'),
  201. // backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
  202. // children: [
  203. // new Container(
  204. // child: Builder(
  205. // builder: (context) => Form(
  206. // key: _formKey,
  207. // child: SingleChildScrollView(
  208. // padding: const EdgeInsets.all(20),
  209. // child: Column(
  210. // crossAxisAlignment: CrossAxisAlignment.stretch,
  211. // children: <Widget>[
  212. // TextFormFields.build(
  213. // label: 'Product',
  214. // validator: Validator._notNull,
  215. // onSaved: (value) =>
  216. // state.formDesso.desso_product = value),
  217. // TextFormFields.build(
  218. // label: 'Color',
  219. // validator: Validator._notNull,
  220. // onSaved: (value) =>
  221. // state.formDesso.desso_color = value),
  222. // TextFormFields.build(
  223. // label: 'Area',
  224. // validator: Validator._notNull,
  225. // onSaved: (value) =>
  226. // state.formDesso.desso_area = value),
  227. // TextFormFields.build(
  228. // label: 'Unit Price',
  229. // validator: Validator._notNull,
  230. // onSaved: (value) =>
  231. // state.formDesso.desso_unitPrice = value),
  232. // TextFormFields.build(
  233. // label: 'Selling Price',
  234. // validator: Validator._notNull,
  235. // onSaved: (value) =>
  236. // state.formDesso.desso_sellingPrice = value),
  237. // TextFormFields.build(
  238. // label: 'Estimated Roll(s)',
  239. // validator: Validator._notNull,
  240. // onSaved: (value) =>
  241. // state.formDesso.desso_rolls = value),
  242. // TextFormFields.build(
  243. // label: 'Remarks',
  244. // validator: Validator._notNull,
  245. // onSaved: (value) =>
  246. // state.formDesso.remarks_desso = value),
  247. // Texts.build(
  248. // 'Special Instructions',
  249. // ),
  250. // TextFormFields.buildNewCustomerTextField(
  251. // label: 'For Operation Team',
  252. // validator: Validator._notNull,
  253. // onSaved: (value) =>
  254. // state.formDesso.special_desso_OT = value),
  255. // TextFormFields.buildNewCustomerTextField(
  256. // label: 'For Account Team',
  257. // validator: Validator._notNull,
  258. // onSaved: (value) =>
  259. // state.formDesso.special_desso_AT = value),
  260. // Padding(
  261. // child: Row(
  262. // mainAxisAlignment: MainAxisAlignment.end,
  263. // children: <Widget>[
  264. // ButtonTheme(
  265. // minWidth: 100.0,
  266. // height: 40.0,
  267. // buttonColor: MillTheme.millBlue,
  268. // child: RaisedButton(
  269. // onPressed: () {
  270. // setState(() {
  271. // _formKey.currentState.save();
  272. // });
  273. // },
  274. // child: Text("Done"),
  275. // textColor: MillTheme.bgWelcome,
  276. // ),
  277. // ),
  278. // ]),
  279. // padding: EdgeInsets.only(left: 15.0))
  280. // ],
  281. // ),
  282. // ),
  283. // ),
  284. // ),
  285. // ),
  286. // ],
  287. // ),
  288. // ),
  289. // );
  290. // setState(() => ++_count);
  291. // }
  292.  
  293.  
  294.  
  295.  
  296.  
  297. }
  298.  
  299. class Validator {
  300. static String _notNull(String value) {
  301. if (value.isEmpty) return 'Please input something';
  302. return null;
  303. }
  304. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement