93 lines
3.0 KiB
Dart
93 lines
3.0 KiB
Dart
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,
|
|
)
|
|
|
|
);
|
|
}
|
|
|
|
} |