From 8363d7772f9c0e357904aa70739eb20eaf0df3b6 Mon Sep 17 00:00:00 2001 From: Bossanyi Tibor Date: Mon, 17 Aug 2020 12:31:36 +0200 Subject: [PATCH] wt1.1a introducing flutter_bloc --- lib/view/customer_new_page.dart | 112 -------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 lib/view/customer_new_page.dart diff --git a/lib/view/customer_new_page.dart b/lib/view/customer_new_page.dart deleted file mode 100644 index 43415df..0000000 --- a/lib/view/customer_new_page.dart +++ /dev/null @@ -1,112 +0,0 @@ -import 'package:aitrainer_app/viewmodel/customer_changing_view_model.dart'; -import 'package:aitrainer_app/viewmodel/customer_view_model.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:aitrainer_app/widgets/nav_drawer.dart'; - -class CustomerNewPage extends StatefulWidget{ - _CustomerNewPageState createState() => _CustomerNewPageState(); -} - -class _CustomerNewPageState extends State { - final CustomerViewModel customer = CustomerViewModel(); - String groupValue = "m"; - final _formKey = GlobalKey(); - - @override - Widget build(BuildContext context) { - CustomerChangingViewModel model; - customer.createNew(); - customer.setSex(groupValue); - return Scaffold( - drawer: NavDrawer(), - appBar: AppBar( - title: Text('New customer'), - ), - body: Center( - child: Form( - key: _formKey, - child: Column( - children: [ - TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Name', - ), - validator: (input) => input.length == 0 ? "Please type the name" : null, - onChanged: (input) => customer.setName(input), - ), - TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'First Name', - ), - validator: (input) => input.length == 0 ? "Please type the first name" : null, - onChanged: (input) => customer.setFirstName(input), - ), - TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Email', - ), - validator: (String input) { - RegExp exp = new RegExp(r"[\w._]+\@[\w._]+.[a-z]+", - caseSensitive: false, - multiLine: false,); - String ret = exp.hasMatch(input) == true ? - null: - "Please type an email address"; - return ret; - }, - onChanged: (input) => customer.setEmail(input), - ), - TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Age', - ), - validator: (input) => (int.parse(input) < 99 && int.parse(input) > 0) ? - null : - "Please type the right age 0-99", - onChanged: (input) => customer.setBirthYear(int.parse(input)), - ), - RadioListTile( - title: const Text('Man'), - value: "m", - groupValue: groupValue, - onChanged: (input) => { - setState(() { - groupValue = input; - customer.setSex(input); - } - )}, - - ),RadioListTile( - title: const Text('Woman'), - value: "w", - groupValue: groupValue, - onChanged: (input) => { - setState(() { - groupValue = input; - customer.setSex(input); - } - )}, - ), - ]) - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: () => { - if (_formKey.currentState.validate()) { - model = CustomerChangingViewModel(customer), - model.addCustomer(), - model.addNewCustomerToList(customer), - Navigator.pop(context), - } - }, - child: Icon(Icons.save,), - mini: true, - ) - ); - } -} \ No newline at end of file