Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:the_mill_flutter/Helpers/AppState.dart';
- import 'package:the_mill_flutter/Helpers/NavigationHelpers.dart';
- import 'package:the_mill_flutter/Models/form.dart';
- import 'package:the_mill_flutter/StyleSource/styles.dart';
- import 'package:the_mill_flutter/StyleSource/textformfields.dart';
- import 'package:the_mill_flutter/StyleSource/themes.dart';
- import 'dart:math';
- class BdtCreateWODesso extends StatefulWidget {
- @override
- _BdtCreateWODessoState createState() => _BdtCreateWODessoState();
- }
- class _BdtCreateWODessoState extends State<BdtCreateWODesso> {
- List<Widget> _children = [];
- int _count = 1;
- int _key;
- _collapse() {
- int newKey;
- do {
- _key = new Random().nextInt(10000);
- } while (newKey == _key);
- }
- @override
- void initState() {
- super.initState();
- _collapse();
- }
- final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
- @override
- Widget build(BuildContext context) {
- AppState state = AppContainer.of(context);
- return Scaffold(
- appBar: AppBar(
- iconTheme: IconThemeData(color: MillTheme.title),
- title: Text(
- "CREATE WORK ORDER",
- style: AppStyles.textStyleTitle(),
- ),
- backgroundColor: Colors.transparent,
- elevation: 0.0,
- centerTitle: true,
- actions: <Widget>[
- IconButton(
- icon: Icon(
- Icons.notifications,
- color: MillTheme.title,
- ),
- onPressed: () {
- NavigationHelpers.goToNoti(context);
- },
- )
- ],
- ),
- floatingActionButton: Padding(
- padding: const EdgeInsets.only(top: 25.0),
- child: RaisedButton(
- color: MillTheme.millBlue,
- child: Text('Add new'),
- textColor: MillTheme.bgWelcome,
- onPressed: (() {
- setState(() {
- _add();
- });
- }),
- ),
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
- body: SingleChildScrollView(
- child: Card(
- child: new ExpansionTile(
- key: new Key(_key.toString()),
- initiallyExpanded: false,
- title: new Text('Product ${_count}'),
- backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
- children: [
- new Container(
- child: Builder(
- builder: (context) => Form(
- key: _formKey,
- child: SingleChildScrollView(
- padding: const EdgeInsets.all(20),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: <Widget>[
- TextFormFields.build(
- label: 'Product',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.desso_product = value),
- TextFormFields.build(
- label: 'Color',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.desso_color = value),
- TextFormFields.build(
- label: 'Area',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.desso_area = value),
- TextFormFields.build(
- label: 'Unit Price',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.desso_unitPrice = value),
- TextFormFields.build(
- label: 'Selling Price',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.desso_sellingPrice = value),
- TextFormFields.build(
- label: 'Estimated Roll(s)',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.desso_rolls = value),
- TextFormFields.build(
- label: 'Remarks',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.remarks_desso = value),
- Texts.build(
- 'Special Instructions',
- ),
- TextFormFields.buildNewCustomerTextField(
- label: 'For Operation Team',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.special_desso_OT = value),
- TextFormFields.buildNewCustomerTextField(
- label: 'For Account Team',
- validator: Validator._notNull,
- onSaved: (value) =>
- state.formDesso.special_desso_AT = value),
- Padding(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: <Widget>[
- ButtonTheme(
- minWidth: 100.0,
- height: 40.0,
- buttonColor: MillTheme.millBlue,
- child: RaisedButton(
- onPressed: () {
- setState(() {
- _collapse();
- _formKey.currentState.save();
- });
- },
- child: Text("Done"),
- textColor: MillTheme.bgWelcome,
- ),
- ),
- ]),
- padding: EdgeInsets.only(left: 15.0))
- ],
- ),
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- // Padding(
- // padding: const EdgeInsets.only(top: 30.0),
- // child: Container(
- // child: ListView(children: _children.toList()),
- // )),
- );
- }
- //
- // void _add() {
- // final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
- //
- // AppState state = AppContainer.of(context);
- //
- // _children = List.from(_children)
- // ..add(
- // Card(
- // child: new ExpansionTile(
- // initiallyExpanded: false,
- // title: new Text('Product ${_count}'),
- // backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
- // children: [
- // new Container(
- // child: Builder(
- // builder: (context) => Form(
- // key: _formKey,
- // child: SingleChildScrollView(
- // padding: const EdgeInsets.all(20),
- // child: Column(
- // crossAxisAlignment: CrossAxisAlignment.stretch,
- // children: <Widget>[
- // TextFormFields.build(
- // label: 'Product',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.desso_product = value),
- // TextFormFields.build(
- // label: 'Color',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.desso_color = value),
- // TextFormFields.build(
- // label: 'Area',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.desso_area = value),
- // TextFormFields.build(
- // label: 'Unit Price',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.desso_unitPrice = value),
- // TextFormFields.build(
- // label: 'Selling Price',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.desso_sellingPrice = value),
- // TextFormFields.build(
- // label: 'Estimated Roll(s)',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.desso_rolls = value),
- // TextFormFields.build(
- // label: 'Remarks',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.remarks_desso = value),
- // Texts.build(
- // 'Special Instructions',
- // ),
- // TextFormFields.buildNewCustomerTextField(
- // label: 'For Operation Team',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.special_desso_OT = value),
- // TextFormFields.buildNewCustomerTextField(
- // label: 'For Account Team',
- // validator: Validator._notNull,
- // onSaved: (value) =>
- // state.formDesso.special_desso_AT = value),
- // Padding(
- // child: Row(
- // mainAxisAlignment: MainAxisAlignment.end,
- // children: <Widget>[
- // ButtonTheme(
- // minWidth: 100.0,
- // height: 40.0,
- // buttonColor: MillTheme.millBlue,
- // child: RaisedButton(
- // onPressed: () {
- // setState(() {
- // _formKey.currentState.save();
- // });
- // },
- // child: Text("Done"),
- // textColor: MillTheme.bgWelcome,
- // ),
- // ),
- // ]),
- // padding: EdgeInsets.only(left: 15.0))
- // ],
- // ),
- // ),
- // ),
- // ),
- // ),
- // ],
- // ),
- // ),
- // );
- // setState(() => ++_count);
- // }
- }
- class Validator {
- static String _notNull(String value) {
- if (value.isEmpty) return 'Please input something';
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement