Aitrainer_app 0.0.1
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import 'package:aitrainer_app/viewmodel/customer_changing_view_model.dart';
|
||||
import 'package:aitrainer_app/viewmodel/customer_view_model.dart';
|
||||
import 'package:aitrainer_app/widgets/nav_drawer.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:aitrainer_app/widgets/customer_list_widget.dart';
|
||||
|
||||
class CustomerListPage extends StatefulWidget{
|
||||
_CustomerListPageState createState() => _CustomerListPageState();
|
||||
}
|
||||
|
||||
class _CustomerListPageState extends State<CustomerListPage> {
|
||||
//final TextEditingController _controller = TextEditingController();
|
||||
Future<List<CustomerViewModel>> _customers;
|
||||
final _customerViewModel = CustomerChangingViewModel(null);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_customers = _customerViewModel.getCustomers();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
//final customerViewModel = CustomerChangingViewModel(null);
|
||||
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text("Real customers")
|
||||
),
|
||||
body: Center(
|
||||
child: FutureBuilder<List<CustomerViewModel>>(
|
||||
future: _customers,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return CustomerListWidget(customers: _customerViewModel.customerList);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text("${snapshot.error}");
|
||||
}
|
||||
|
||||
// By default, show a loading spinner.
|
||||
return CircularProgressIndicator();
|
||||
},
|
||||
),
|
||||
),
|
||||
/* body: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
),
|
||||
child: TextField(
|
||||
controller: _controller,
|
||||
onSubmitted: (value) {
|
||||
if(value.isNotEmpty) {
|
||||
customerViewModel.getCustomers();
|
||||
_controller.clear();
|
||||
}
|
||||
},
|
||||
style: TextStyle(color: Colors.white),
|
||||
decoration: InputDecoration(
|
||||
hintText: "Search",
|
||||
hintStyle: TextStyle(color: Colors.white),
|
||||
border: InputBorder.none
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CustomerListWidget(customers: customerViewModel.customers)),
|
||||
]),
|
||||
|
||||
), */
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
'customerNewPage',
|
||||
),
|
||||
child: Icon(Icons.add,),
|
||||
mini: true,
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:aitrainer_app/widgets/nav_drawer.dart';
|
||||
|
||||
class CustomerModifyPage extends StatefulWidget{
|
||||
_CustomerModifyPageState createState() => _CustomerModifyPageState();
|
||||
}
|
||||
|
||||
class _CustomerModifyPageState extends State {
|
||||
//final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text('Modify customer'),
|
||||
),
|
||||
body: Center(
|
||||
child: Text('Modify customer'),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => {},
|
||||
child: Icon(Icons.save,),
|
||||
mini: true,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
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<FormState>();
|
||||
|
||||
@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: <Widget>[
|
||||
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.setAge(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,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import 'package:aitrainer_app/viewmodel/exercise_changing_view_model.dart';
|
||||
import 'package:aitrainer_app/widgets/nav_drawer.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
|
||||
|
||||
class ExerciseNewPage extends StatefulWidget{
|
||||
_ExerciseNewPageState createState() => _ExerciseNewPageState();
|
||||
}
|
||||
|
||||
class _ExerciseNewPageState extends State {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final format = DateFormat("yyyy-MM-dd HH:mm");
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ExerciseChangingViewModel model = Provider.of<ExerciseChangingViewModel>(context, listen: false);
|
||||
model.createNewModel();
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text('New exercise'),
|
||||
),
|
||||
body: Center(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Name',
|
||||
),
|
||||
readOnly: true,
|
||||
initialValue: model != null && model.customer != null ? model.customer.name + " " + model.customer.firstName : "Please select a customer",
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Exercise',
|
||||
),
|
||||
readOnly: true,
|
||||
initialValue: model != null && model.exerciseType != null ? model.exerciseType.name : "Please select an exercise",
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Quantity',
|
||||
),
|
||||
validator: (input) => (int.parse(input) < 1000 && int.parse(input) > 0) ?
|
||||
null :
|
||||
"Please type the right quantity 0-1000",
|
||||
onChanged: (input) => model.exerciseViewModel.setQuantity(int.parse(input)),
|
||||
),
|
||||
|
||||
Text('Exercise date and time'),
|
||||
DateTimeField(
|
||||
format: format,
|
||||
initialValue: DateTime.now(),
|
||||
onShowPicker: (context, currentValue) async {
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
firstDate: DateTime(1900),
|
||||
initialDate: DateTime.now(),
|
||||
lastDate: DateTime(2100),
|
||||
builder: (context, child) => Localizations.override(
|
||||
context: context,
|
||||
locale: Locale('hu'),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
if (date != null) {
|
||||
final time = await showTimePicker(
|
||||
context: context,
|
||||
initialTime:
|
||||
TimeOfDay.fromDateTime(currentValue ?? DateTime.now()),
|
||||
builder: (context, child) => Localizations.override(
|
||||
context: context,
|
||||
locale: Locale('hu'),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
return DateTimeField.combine(date, time);
|
||||
} else {
|
||||
return currentValue;
|
||||
}
|
||||
},
|
||||
onChanged: (input) => model.exerciseViewModel.setDatetimeExercise(input),
|
||||
),
|
||||
]),
|
||||
)
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => {
|
||||
if (_formKey.currentState.validate()) {
|
||||
//model = ExerciseChangingViewModel(model.exerciseViewModel),
|
||||
model.addExercise(),
|
||||
Navigator.pop(context),
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.save,),
|
||||
mini: true,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'package:aitrainer_app/viewmodel/exercise_type_changing_view_model.dart';
|
||||
import 'package:aitrainer_app/viewmodel/exercise_type_view_model.dart';
|
||||
import 'package:aitrainer_app/widgets/exercise_type_list_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:aitrainer_app/widgets/nav_drawer.dart';
|
||||
|
||||
class ExerciseTypeListPage extends StatefulWidget{
|
||||
_ExerciseTypeListPageState createState() => _ExerciseTypeListPageState();
|
||||
}
|
||||
|
||||
class _ExerciseTypeListPageState extends State {
|
||||
Future<List<ExerciseTypeViewModel>> _exerciseTypes;
|
||||
final _exerciseTypeViewModel = ExerciseTypeChangingViewModel(null);
|
||||
|
||||
// Push the page and remove everything else
|
||||
navigateToPage(BuildContext context, String page) {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(page, (Route<dynamic> route) => false);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_exerciseTypes = _exerciseTypeViewModel.getExerciseTypes();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text('Exercises'),
|
||||
),
|
||||
body: Center(
|
||||
child: FutureBuilder<List<ExerciseTypeViewModel>>(
|
||||
future: _exerciseTypes,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return ExerciseTypeListWidget(exerciseTypes: _exerciseTypeViewModel.exerciseTypeList);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text("${snapshot.error}");
|
||||
}
|
||||
|
||||
// By default, show a loading spinner.
|
||||
return CircularProgressIndicator();
|
||||
},
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
'exerciseTypeNewPage',
|
||||
),
|
||||
child: Icon(Icons.add,),
|
||||
mini: true,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import 'package:aitrainer_app/viewmodel/exercise_type_changing_view_model.dart';
|
||||
import 'package:aitrainer_app/viewmodel/exercise_type_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:aitrainer_app/widgets/nav_drawer.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class ExerciseTypeModifyPage extends StatefulWidget{
|
||||
ExerciseTypeViewModel exerciseTypeViewModel;
|
||||
ExerciseTypeModifyPage({this.exerciseTypeViewModel});
|
||||
_ExerciseTypeModifyPageState createState() => _ExerciseTypeModifyPageState();
|
||||
}
|
||||
|
||||
class _ExerciseTypeModifyPageState extends State<ExerciseTypeModifyPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ExerciseTypeViewModel exerciseType = ModalRoute.of(context).settings.arguments;
|
||||
ExerciseTypeChangingViewModel changeModel;
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text('Modify "' + exerciseType.name + '"' ),
|
||||
),
|
||||
body: Center(
|
||||
child: Form(
|
||||
key:_formKey,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
initialValue: exerciseType.name,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Exercise',
|
||||
),
|
||||
validator: (input) => input.length == 0 ? "Please type the name of the exercise" : null,
|
||||
onChanged: (input) => exerciseType.setName(input),
|
||||
) ,
|
||||
TextFormField(
|
||||
initialValue: exerciseType.description,
|
||||
minLines: 4,
|
||||
maxLines: 10,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Description',
|
||||
),
|
||||
onChanged: (input) => exerciseType.setDescription(input),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => {
|
||||
if (_formKey.currentState.validate()) {
|
||||
changeModel = ExerciseTypeChangingViewModel(exerciseType),
|
||||
changeModel.saveExerciseType(),
|
||||
Navigator.pop(context),
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.save,),
|
||||
mini: true,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:aitrainer_app/viewmodel/exercise_type_changing_view_model.dart';
|
||||
import 'package:aitrainer_app/viewmodel/exercise_type_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:aitrainer_app/widgets/nav_drawer.dart';
|
||||
|
||||
class ExerciseTypeNewPage extends StatefulWidget{
|
||||
_ExerciseTypeNewPageState createState() => _ExerciseTypeNewPageState();
|
||||
}
|
||||
|
||||
class _ExerciseTypeNewPageState extends State {
|
||||
final ExerciseTypeViewModel exerciseType = ExerciseTypeViewModel();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ExerciseTypeChangingViewModel model;
|
||||
exerciseType.createNew();
|
||||
return Scaffold(
|
||||
drawer: NavDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text('New exercise'),
|
||||
),
|
||||
body: Center(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Exercise',
|
||||
),
|
||||
validator: (input) => input.length == 0 ? "Please type the name of the exercise" : null,
|
||||
onChanged: (input) => exerciseType.setName(input),
|
||||
) ,
|
||||
TextFormField(
|
||||
minLines: 4,
|
||||
maxLines: 10,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Description',
|
||||
),
|
||||
onChanged: (input) => exerciseType.setDescription(input),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => {
|
||||
if (_formKey.currentState.validate()) {
|
||||
model = ExerciseTypeChangingViewModel(exerciseType),
|
||||
model.addExerciseType(),
|
||||
model.addNewExercise(exerciseType),
|
||||
Navigator.pop(context),
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.save,),
|
||||
mini: true,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user