67 lines
2.0 KiB
Dart
67 lines
2.0 KiB
Dart
import 'package:aitrainer_app/viewmodel/exercise_changing_view_model.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:aitrainer_app/viewmodel/customer_view_model.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class CustomerListWidget extends StatefulWidget {
|
|
static const routeName = '/customer_list';
|
|
final List<CustomerViewModel> customers;
|
|
|
|
CustomerListWidget({this.customers});
|
|
|
|
@override
|
|
_CustomerListWidget createState() => _CustomerListWidget();
|
|
|
|
}
|
|
|
|
class _CustomerListWidget extends State<CustomerListWidget> {
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView.builder(
|
|
itemCount: widget.customers.length,
|
|
itemBuilder: (context, index) {
|
|
|
|
final customer = widget.customers[index];
|
|
|
|
return ListTile(
|
|
contentPadding: EdgeInsets.all(10),
|
|
leading:Icon(Icons.accessibility),
|
|
title: Text(customer.name + " " + customer.firstName),
|
|
subtitle:
|
|
Container(
|
|
child: Visibility(
|
|
visible: customer.visibleDetails,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Text(customer.age.toString() + " years, " + customer.sex),
|
|
new RaisedButton(
|
|
child: new Text('Modify'),
|
|
color: Color.fromRGBO(244, 122, 22, 0.9),
|
|
onPressed: () => {
|
|
|
|
},
|
|
),
|
|
new RaisedButton(
|
|
child: new Text('Select'),
|
|
color: Colors.blueGrey,
|
|
onPressed: () => {
|
|
Provider.of<ExerciseChangingViewModel>(context, listen: false).setCustomer(customer.customer),
|
|
Navigator.pop(context)
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
onTap: () { setState( () {
|
|
customer.visibleDetails = true;
|
|
});
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
} |