update carton and add staff name
This commit is contained in:
101
lib/pages/carton_search/carton_list_row.dart
Normal file
101
lib/pages/carton_search/carton_list_row.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
|
||||
import 'carton_search.dart';
|
||||
|
||||
class CartonListRow extends StatefulWidget {
|
||||
final CallbackCartonSelect callbackCartonSelect;
|
||||
final Carton carton;
|
||||
const CartonListRow({this.carton, this.callbackCartonSelect});
|
||||
|
||||
@override
|
||||
_CartonListRowState createState() => _CartonListRowState();
|
||||
}
|
||||
|
||||
class _CartonListRowState extends State<CartonListRow> {
|
||||
final double dotSize = 15.0;
|
||||
Carton _carton;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
this._carton = widget.carton;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey[300]),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
if (widget.callbackCartonSelect != null)
|
||||
widget.callbackCartonSelect(widget.carton);
|
||||
},
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
padding: new EdgeInsets.symmetric(
|
||||
horizontal: 25.0 - dotSize / 2),
|
||||
child: Icon(
|
||||
MaterialCommunityIcons.package,
|
||||
color: primaryColor,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_carton.cartonNumber ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
_carton.userName ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 8.0, bottom: 5, right: 10),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
"${_carton.actualWeight?.toStringAsFixed(2) ?? ''} lb",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
122
lib/pages/carton_search/carton_search.dart
Normal file
122
lib/pages/carton_search/carton_search.dart
Normal file
@@ -0,0 +1,122 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton/model/carton_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'carton_list_row.dart';
|
||||
|
||||
typedef CallbackCartonSelect(Carton carton);
|
||||
|
||||
Future<Carton> searchCarton(BuildContext context,
|
||||
{CallbackCartonSelect callbackCartonSelect}) async =>
|
||||
await showSearch<Carton>(
|
||||
context: context,
|
||||
delegate: PartSearchDelegate(callbackCartonSelect: callbackCartonSelect),
|
||||
);
|
||||
|
||||
class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
final CallbackCartonSelect callbackCartonSelect;
|
||||
PartSearchDelegate({this.callbackCartonSelect});
|
||||
|
||||
@override
|
||||
String get searchFieldLabel => 'Search by Carton Number/Customer Name';
|
||||
|
||||
@override
|
||||
ThemeData appBarTheme(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return theme.copyWith(
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
hintStyle: TextStyle(
|
||||
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
|
||||
textTheme: theme.textTheme.copyWith(
|
||||
title: theme.textTheme.title.copyWith(
|
||||
color: theme.primaryTextTheme.title.color, fontSize: 16)),
|
||||
primaryColor: primaryColor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> buildActions(BuildContext context) {
|
||||
return [
|
||||
IconButton(
|
||||
icon: Icon(Icons.clear),
|
||||
onPressed: () => query = '',
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildLeading(BuildContext context) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () => close(context, null),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildResults(BuildContext context) {
|
||||
final cartonModel = Provider.of<CartonModel>(context);
|
||||
return FutureBuilder(
|
||||
future: cartonModel.searchCarton(query),
|
||||
builder: (context, AsyncSnapshot<List<Carton>> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
if (snapshot.data.length == 0) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No result found",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
child: ListView(
|
||||
children: snapshot.data
|
||||
.map((u) => CartonListRow(
|
||||
carton: u,
|
||||
callbackCartonSelect: callbackCartonSelect,
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${snapshot.error}',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor:
|
||||
new AlwaysStoppedAnimation<Color>(primaryColor)),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildSuggestions(BuildContext context) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Opacity(
|
||||
opacity: 0.2,
|
||||
child: Icon(
|
||||
MaterialCommunityIcons.package,
|
||||
color: primaryColor,
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user