add shipments

This commit is contained in:
Sai Naw Wun
2020-10-13 07:50:25 +06:30
parent dc79f424a5
commit e032cee922
31 changed files with 1108 additions and 1035 deletions

View File

@@ -0,0 +1,2 @@
typedef OnTap();
typedef CallBack = void Function();

View File

@@ -0,0 +1,56 @@
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'callbacks.dart';
import 'display_text.dart';
import 'local_text.dart';
class DefaultDeliveryAddress extends StatelessWidget {
final DeliveryAddress deliveryAddress;
final String labelKey;
final OnTap onTap;
const DefaultDeliveryAddress(
{Key key, this.deliveryAddress, this.onTap, this.labelKey})
: super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: this.labelKey ?? "delivery_address",
iconData: MaterialCommunityIcons.truck_fast,
),
),
onTap == null
? Container()
: GestureDetector(
onTap: () => onTap(),
child: Chip(
label: LocalText(
context, "delivery_address.change_address",
color: primaryColor)),
)
],
),
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: deliveryAddress == null
? Container()
: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress),
),
],
);
}
}

View File

@@ -0,0 +1,85 @@
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class DeliveryAddressSelection extends StatelessWidget {
final DeliveryAddress deliveryAddress;
const DeliveryAddressSelection({Key key, this.deliveryAddress})
: super(key: key);
@override
Widget build(BuildContext context) {
var shipmentModel = Provider.of<DeliveryAddressModel>(context);
return Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.pop(context),
),
backgroundColor: primaryColor,
title: LocalText(
context,
"delivery_addresses",
fontSize: 20,
color: Colors.white,
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context)
.push(BottomUpPageRoute(DeliveryAddressEditor()));
},
icon: Icon(Icons.add),
label: LocalText(context, "delivery_address.new_address",
color: Colors.white),
backgroundColor: primaryColor,
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.separated(
separatorBuilder: (c, i) => Divider(
color: primaryColor,
),
itemCount: shipmentModel.deliveryAddresses.length,
itemBuilder: (context, index) {
return _row(context, shipmentModel.deliveryAddresses[index]);
}),
));
}
_row(BuildContext context, DeliveryAddress _deliveryAddress) {
return InkWell(
onTap: () => _select(context, _deliveryAddress),
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: Icon(Icons.check,
color: deliveryAddress != null &&
_deliveryAddress.id == deliveryAddress.id
? primaryColor
: Colors.black26),
),
Expanded(
child: DeliveryAddressRow(
key: ValueKey(_deliveryAddress.id),
deliveryAddress: _deliveryAddress,
)),
],
),
);
}
_select(BuildContext context, DeliveryAddress _deliveryAddress) {
Navigator.pop(context, _deliveryAddress);
}
}

View File

@@ -2,7 +2,7 @@ import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'multi_img_controller.dart';
import 'callbacks.dart';
class FcsExpansionTile extends StatefulWidget {
final ValueChanged<bool> onExpansionChanged;

View File

@@ -0,0 +1,56 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'callbacks.dart';
class LocalButton extends StatelessWidget {
final CallBack callBack;
final IconData iconData;
final String textKey;
const LocalButton({Key key, this.callBack, this.iconData, this.textKey})
: super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 10, right: 10, top: 10),
child: Container(
height: 45.0,
decoration: BoxDecoration(
color: primaryColor,
shape: BoxShape.rectangle,
),
child: ButtonTheme(
minWidth: 900.0,
height: 100.0,
child: FlatButton(
onPressed: callBack == null ? null : () => callBack(),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
iconData == null
? Container()
: Icon(
iconData,
color: Colors.white,
),
SizedBox(
width: 15,
),
LocalText(
context,
textKey,
color: Colors.white,
fontSize: 16,
),
],
),
),
),
),
);
}
}

View File

@@ -0,0 +1,68 @@
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'local_text.dart';
class LocalDropdown<T> extends StatelessWidget {
final Function(T) callback;
final IconData iconData;
final T selectedValue;
final List<T> values;
const LocalDropdown(
{Key key, this.callback, this.iconData, this.selectedValue, this.values})
: super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 5.0, right: 0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 0, right: 10),
child: Icon(iconData, color: primaryColor),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
"shipment.type",
color: Colors.black54,
fontSize: 16,
),
),
DropdownButton<T>(
isDense: true,
value: selectedValue,
style: TextStyle(color: Colors.black, fontSize: 14),
underline: Container(
height: 1,
color: Colors.grey,
),
onChanged: (T newValue) {
callback(newValue);
},
isExpanded: true,
items: values.map<DropdownMenuItem<T>>((T value) {
return DropdownMenuItem<T>(
value: value,
child: Text(value==null? "":value.toString(),
overflow: TextOverflow.ellipsis,
style: TextStyle(color: primaryColor)),
);
}).toList(),
),
],
),
),
],
),
);
}
}

View File

@@ -1,9 +1,8 @@
import 'dart:io';
import 'callbacks.dart';
import 'display_image_source.dart';
typedef CallBack = void Function();
class MultiImgController {
List<String> imageUrls;
List<DisplayImageSource> addedFiles = [];

View File

@@ -0,0 +1,52 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'callbacks.dart';
class TitleWithAddButton extends StatelessWidget {
final IconData iconData;
final String titleKey;
final OnTap onTap;
const TitleWithAddButton({Key key, this.iconData, this.titleKey, this.onTap})
: super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 15.0),
child: Icon(
this.iconData,
color: primaryColor,
),
),
LocalText(
context,
titleKey,
color: Colors.black54,
fontSize: 20,
)
],
),
Spacer(),
onTap == null
? Container()
: Padding(
padding: const EdgeInsets.only(right: 25.0),
child: IconButton(
onPressed: () => onTap(),
icon: Icon(
Icons.add_circle,
color: primaryColor,
)),
)
],
);
}
}