null safety
This commit is contained in:
@@ -22,6 +22,7 @@ import 'package:fcs/pages/widgets/local_title.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final shipmentWeightBox = DisplayText(
|
final shipmentWeightBox = DisplayText(
|
||||||
text: shipmentWeight.toStringAsFixed(0) : "",
|
text: shipmentWeight.toStringAsFixed(0),
|
||||||
labelTextKey: "box.shipment_weight",
|
labelTextKey: "box.shipment_weight",
|
||||||
iconData: MaterialCommunityIcons.weight,
|
iconData: MaterialCommunityIcons.weight,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'delivery_info.dart';
|
import 'delivery_info.dart';
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class DeliveryAddressEditor extends StatefulWidget {
|
class DeliveryAddressEditor extends StatefulWidget {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
|
|
||||||
typedef SelectionCallback(DeliveryAddress deliveryAddress);
|
typedef SelectionCallback(DeliveryAddress deliveryAddress);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:fcs/pages/widgets/input_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:fcs/pages/discount/discount_editor.dart';
|
|||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
typedef OnSelect(Discount discount);
|
typedef OnSelect(Discount discount);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
const info = "Select additional page";
|
const info = "Select additional page";
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ Widget itemTitle(BuildContext context, String textKey) {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(left: 18.0, top: 15, bottom: 0),
|
padding: const EdgeInsets.only(left: 18.0, top: 15, bottom: 0),
|
||||||
child: Text(
|
child: Text(
|
||||||
AppTranslations.of(context).text(textKey),
|
AppTranslations.of(context)!.text(textKey),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold, fontSize: 18, color: Colors.black),
|
fontWeight: FontWeight.bold, fontSize: 18, color: Colors.black),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget subItemTitle(BuildContext context, String textKey, {IconData iconData}) {
|
Widget subItemTitle(BuildContext context, String textKey, {IconData? iconData}) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(left: 0, top: 0, bottom: 0),
|
padding: const EdgeInsets.only(left: 0, top: 0, bottom: 0),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -25,7 +25,7 @@ Widget subItemTitle(BuildContext context, String textKey, {IconData iconData}) {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
Text(
|
Text(
|
||||||
AppTranslations.of(context).text(textKey),
|
AppTranslations.of(context)!.text(textKey),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w700, fontSize: 15, color: primaryColor),
|
fontWeight: FontWeight.w700, fontSize: 15, color: primaryColor),
|
||||||
),
|
),
|
||||||
@@ -35,7 +35,7 @@ Widget subItemTitle(BuildContext context, String textKey, {IconData iconData}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget contactItem(BuildContext context, String text, IconData iconData,
|
Widget contactItem(BuildContext context, String text, IconData iconData,
|
||||||
{Function() onTap, String labelKey}) {
|
{Function()? onTap, String? labelKey}) {
|
||||||
return Material(
|
return Material(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 18.0, bottom: 10, right: 18),
|
padding: const EdgeInsets.only(left: 18.0, bottom: 10, right: 18),
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
labelStyle: languageModel.isEng
|
labelStyle: languageModel.isEng
|
||||||
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
||||||
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
||||||
labelText: AppTranslations.of(context)
|
labelText: AppTranslations.of(context)!
|
||||||
.text('FCSshipment.shipment_type'),
|
.text('FCSshipment.shipment_type'),
|
||||||
icon: Icon(Ionicons.ios_airplane, color: primaryColor)),
|
icon: Icon(Ionicons.ios_airplane, color: primaryColor)),
|
||||||
items: mainModel.setting.shipmentTypes
|
items: mainModel.setting.shipmentTypes
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
|||||||
onChanged: (Currency? value) {
|
onChanged: (Currency? value) {
|
||||||
if(value != null)
|
if(value != null)
|
||||||
setState(() {
|
setState(() {
|
||||||
_currency = value!;
|
_currency = value;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -96,7 +96,7 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
|||||||
onChanged: (Currency? value) {
|
onChanged: (Currency? value) {
|
||||||
if(value != null)
|
if(value != null)
|
||||||
setState(() {
|
setState(() {
|
||||||
_currency = value!;
|
_currency = value;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class _CargoEditorState extends State<CargoEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
if (widget.cargo != null) {
|
if (widget.cargo != null) {
|
||||||
_cargo = widget.cargo!;
|
_cargo = widget.cargo!;
|
||||||
_descController.text = _cargo.name;
|
_descController.text = _cargo.name ?? '';
|
||||||
_rateController.text = _cargo.rate.toStringAsFixed(2);
|
_rateController.text = _cargo.rate?.toStringAsFixed(2) ?? '';
|
||||||
} else {
|
} else {
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,8 @@ class _CargoEditorState extends State<CargoEditor> {
|
|||||||
try {
|
try {
|
||||||
var shipmentRateModel =
|
var shipmentRateModel =
|
||||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
await shipmentRateModel.deleteCargoType(this._cargo.id);
|
if(this._cargo.id != null)
|
||||||
|
await shipmentRateModel.deleteCargoType(this._cargo.id!);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ class _CargoTypeListState extends State<CargoTypeList> {
|
|||||||
)));
|
)));
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
child: _row(cargo.name,
|
child: _row(cargo.name?? '',
|
||||||
"\$ " + cargo.rate.toStringAsFixed(2), 'per pound'),
|
"\$ " + cargo.rate!.toStringAsFixed(2), 'per pound'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
if (widget.custom != null) {
|
if (widget.custom != null) {
|
||||||
_custom = widget.custom!;
|
_custom = widget.custom!;
|
||||||
_productController.text = _custom.name;
|
_productController.text = _custom.name ?? '';
|
||||||
_feeController.text = _custom.customDutyFee.toStringAsFixed(2);
|
_feeController.text = _custom.customDutyFee?.toStringAsFixed(2) ?? '';
|
||||||
_shipmentRateController.text =
|
_shipmentRateController.text =
|
||||||
_custom.rate == null ? "" : _custom.rate.toStringAsFixed(2);
|
_custom.rate == null ? "" : _custom.rate?.toStringAsFixed(2) ?? '';
|
||||||
} else {
|
} else {
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,8 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
try {
|
try {
|
||||||
var shipmentRateModel =
|
var shipmentRateModel =
|
||||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
await shipmentRateModel.deleteCustomDuty(this._custom.id);
|
if(this._custom.id != null)
|
||||||
|
await shipmentRateModel.deleteCustomDuty(this._custom.id!);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -81,11 +81,15 @@ class _CustomListState extends State<CustomList> {
|
|||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
child: _row(
|
child: _row(
|
||||||
custom.name,
|
custom.name ?? '',
|
||||||
"Custom Fee \$ " + custom.customDutyFee.toStringAsFixed(2),
|
custom.customDutyFee == null
|
||||||
|
? ""
|
||||||
|
: "Custom Fee \$ " +
|
||||||
|
custom.customDutyFee!.toStringAsFixed(2),
|
||||||
custom.rate == null
|
custom.rate == null
|
||||||
? ""
|
? ""
|
||||||
: "Shipment rate \$ " + custom.rate.toStringAsFixed(2)),
|
: "Shipment rate \$ " +
|
||||||
|
custom.rate!.toStringAsFixed(2)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
|
|
||||||
typedef SelectionCallback(CustomDuty custom);
|
typedef SelectionCallback(CustomDuty custom);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
|
||||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
import 'package:fcs/domain/entities/rate.dart';
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
@@ -186,7 +185,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
return cargos.map((cargo) {
|
return cargos.map((cargo) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(
|
child: _row(
|
||||||
cargo.name, "\$ " + cargo.rate.toStringAsFixed(2), 'per pound'),
|
cargo.name ?? '', "\$ " + cargo.rate!.toStringAsFixed(2), 'per pound'),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
@@ -194,7 +193,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
List<Widget> getCustonWidget(List<CargoType> customs) {
|
List<Widget> getCustonWidget(List<CargoType> customs) {
|
||||||
return customs.map((c) {
|
return customs.map((c) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(c.name, "\$ " + c.customDutyFee.toStringAsFixed(2), ''),
|
child: _row(c.name ?? '', "\$ " + c.customDutyFee!.toStringAsFixed(2), ''),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ShipmentRatesCal extends StatefulWidget {
|
class ShipmentRatesCal extends StatefulWidget {
|
||||||
@@ -61,11 +62,11 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
var amount = box.calAmount(rate);
|
var amount = box.calAmount(rate);
|
||||||
var shipmentWeight = box.getShipmentWeight(rate.volumetricRatio);
|
var shipmentWeight = box.getShipmentWeight(rate.volumetricRatio);
|
||||||
var effectiveWeight =
|
var effectiveWeight =
|
||||||
_cargoType.weight > shipmentWeight ? _cargoType.weight : shipmentWeight;
|
_cargoType.weight! > shipmentWeight ? _cargoType.weight : shipmentWeight;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_deliveryFee =
|
_deliveryFee =
|
||||||
effectiveWeight > rate.freeDeliveryWeight ? 0 : rate.deliveryFee;
|
effectiveWeight! > rate.freeDeliveryWeight ? 0 : rate.deliveryFee;
|
||||||
_amount = amount == null ? 0 : amount + _deliveryFee;
|
_amount = amount == null ? 0 : amount + _deliveryFee;
|
||||||
_shipmentWeight = shipmentWeight.toDouble();
|
_shipmentWeight = shipmentWeight.toDouble();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import 'package:provider/provider.dart';
|
|||||||
typedef void FindCallBack();
|
typedef void FindCallBack();
|
||||||
|
|
||||||
class StaffEditor extends StatefulWidget {
|
class StaffEditor extends StatefulWidget {
|
||||||
final User staff;
|
final User? staff;
|
||||||
const StaffEditor({this.staff});
|
const StaffEditor({this.staff});
|
||||||
@override
|
@override
|
||||||
_StaffEditorState createState() => _StaffEditorState();
|
_StaffEditorState createState() => _StaffEditorState();
|
||||||
@@ -25,8 +25,8 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
TextEditingController _phoneInput = new TextEditingController();
|
TextEditingController _phoneInput = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
User user;
|
late User user;
|
||||||
User selectedUser;
|
User? selectedUser;
|
||||||
List<Privilege> privileges = [];
|
List<Privilege> privileges = [];
|
||||||
bool isNew = true;
|
bool isNew = true;
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
user = User();
|
user = User();
|
||||||
if (!isNew) {
|
if (!isNew) {
|
||||||
user =
|
user =
|
||||||
User(name: widget.staff.name, phoneNumber: widget.staff.phoneNumber);
|
User(name: widget.staff!.name, phoneNumber: widget.staff!.phoneNumber);
|
||||||
user.privileges = widget.staff.privileges;
|
user.privileges = widget.staff!.privileges;
|
||||||
privileges.forEach((p) => user.privileges.contains(p.id)
|
privileges.forEach((p) => user.privileges.contains(p.id)
|
||||||
? p.isChecked = true
|
? p.isChecked = true
|
||||||
: p.isChecked = false);
|
: p.isChecked = false);
|
||||||
@@ -64,7 +64,8 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
new Checkbox(
|
new Checkbox(
|
||||||
value: p.isChecked == null ? false : p.isChecked,
|
value: p.isChecked == null ? false : p.isChecked,
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
onChanged: (bool value) {
|
onChanged: (bool? value) {
|
||||||
|
if(value != null)
|
||||||
setState(() {
|
setState(() {
|
||||||
p.isChecked = value;
|
p.isChecked = value;
|
||||||
});
|
});
|
||||||
@@ -110,7 +111,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
style: textStyle,
|
style: textStyle,
|
||||||
decoration: new InputDecoration(
|
decoration: new InputDecoration(
|
||||||
labelText:
|
labelText:
|
||||||
AppTranslations.of(context).text('staff.phone.search'),
|
AppTranslations.of(context)!.text('staff.phone.search'),
|
||||||
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM,
|
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM,
|
||||||
// icon: Icon(
|
// icon: Icon(
|
||||||
// Icons.search,
|
// Icons.search,
|
||||||
@@ -226,7 +227,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
});
|
});
|
||||||
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
|
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
await staffModel.updatePrivileges(this.selectedUser.id, privilegesIDs());
|
await staffModel.updatePrivileges(this.selectedUser!.id, privilegesIDs());
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
@@ -248,7 +249,7 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
if (widget.staff == null) return;
|
if (widget.staff == null) return;
|
||||||
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
|
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
await staffModel.updatePrivileges(widget.staff.id, privilegesIDs());
|
await staffModel.updatePrivileges(widget.staff!.id, privilegesIDs());
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -84,7 +83,7 @@ class _StaffListState extends State<StaffList> {
|
|||||||
padding: new EdgeInsets.symmetric(
|
padding: new EdgeInsets.symmetric(
|
||||||
horizontal: 32.0 - dotSize / 2),
|
horizontal: 32.0 - dotSize / 2),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
MaterialCommunityIcons.worker,
|
Icons.person,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
size: 40,
|
size: 40,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'package:fcs/pages/user_search/user_serach.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class UserListRow extends StatefulWidget {
|
class UserListRow extends StatefulWidget {
|
||||||
final OnUserRowSelect onUserRowSelect;
|
final OnUserRowSelect? onUserRowSelect;
|
||||||
final User user;
|
final User user;
|
||||||
const UserListRow({this.user, this.onUserRowSelect});
|
const UserListRow({required this.user, this.onUserRowSelect});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_UserListRowState createState() => _UserListRowState();
|
_UserListRowState createState() => _UserListRowState();
|
||||||
@@ -14,7 +14,7 @@ class UserListRow extends StatefulWidget {
|
|||||||
|
|
||||||
class _UserListRowState extends State<UserListRow> {
|
class _UserListRowState extends State<UserListRow> {
|
||||||
final double dotSize = 15.0;
|
final double dotSize = 15.0;
|
||||||
User user;
|
late User user;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -31,7 +31,7 @@ class _UserListRowState extends State<UserListRow> {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.onUserRowSelect != null)
|
if (widget.onUserRowSelect != null)
|
||||||
widget.onUserRowSelect(widget.user);
|
widget.onUserRowSelect!(widget.user);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import 'package:provider/provider.dart';
|
|||||||
typedef OnUserSelect(User suer);
|
typedef OnUserSelect(User suer);
|
||||||
typedef OnUserRowSelect(User suer);
|
typedef OnUserRowSelect(User suer);
|
||||||
|
|
||||||
Future<User> searchUser(BuildContext context,
|
Future<User?> searchUser(BuildContext context,
|
||||||
{OnUserSelect onUserSelect, bool popPage = false}) async =>
|
{required OnUserSelect onUserSelect, bool popPage = false}) async =>
|
||||||
await showSearch<User>(
|
await showSearch<User>(
|
||||||
context: context,
|
context: context,
|
||||||
delegate:
|
delegate:
|
||||||
@@ -17,10 +17,10 @@ Future<User> searchUser(BuildContext context,
|
|||||||
);
|
);
|
||||||
|
|
||||||
class UserSearchDelegate extends SearchDelegate<User> {
|
class UserSearchDelegate extends SearchDelegate<User> {
|
||||||
final OnUserSelect onUserSelect;
|
final OnUserSelect? onUserSelect;
|
||||||
final bool popPage;
|
final bool popPage;
|
||||||
|
|
||||||
UserSearchDelegate({this.onUserSelect, this.popPage});
|
UserSearchDelegate({this.onUserSelect, required this.popPage});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get searchFieldLabel => 'Search by FCS ID or Name';
|
String get searchFieldLabel => 'Search by FCS ID or Name';
|
||||||
@@ -31,10 +31,10 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
|||||||
return theme.copyWith(
|
return theme.copyWith(
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
|
color: theme.primaryTextTheme.caption?.color, fontSize: 14)),
|
||||||
textTheme: theme.textTheme.copyWith(
|
textTheme: theme.textTheme.copyWith(
|
||||||
title: theme.textTheme.title.copyWith(
|
title: theme.textTheme.title?.copyWith(
|
||||||
color: theme.primaryTextTheme.title.color, fontSize: 16)),
|
color: theme.primaryTextTheme.title?.color, fontSize: 16)),
|
||||||
primaryColor: primaryColor,
|
primaryColor: primaryColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
|||||||
Widget buildLeading(BuildContext context) {
|
Widget buildLeading(BuildContext context) {
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: Icon(Icons.arrow_back),
|
icon: Icon(Icons.arrow_back),
|
||||||
onPressed: () => close(context, null),
|
onPressed: () => close(context,User()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
|||||||
future: packageModel.searchUser(query),
|
future: packageModel.searchUser(query),
|
||||||
builder: (context, AsyncSnapshot<List<User>> snapshot) {
|
builder: (context, AsyncSnapshot<List<User>> snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
if (snapshot.data.length == 0) {
|
if (snapshot.data?.length == 0) {
|
||||||
return Container(
|
return Container(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -77,7 +77,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(top: 15),
|
padding: EdgeInsets.only(top: 15),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: snapshot.data
|
children: snapshot.data!
|
||||||
.map((u) => UserListRow(
|
.map((u) => UserListRow(
|
||||||
user: u,
|
user: u,
|
||||||
onUserRowSelect: (u) => _onUserRowSelect(context, u),
|
onUserRowSelect: (u) => _onUserRowSelect(context, u),
|
||||||
@@ -119,7 +119,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
|||||||
|
|
||||||
_onUserRowSelect(BuildContext context, User user) {
|
_onUserRowSelect(BuildContext context, User user) {
|
||||||
if (onUserSelect != null) {
|
if (onUserSelect != null) {
|
||||||
onUserSelect(user);
|
onUserSelect!(user);
|
||||||
}
|
}
|
||||||
if (popPage) {
|
if (popPage) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|||||||
28
pubspec.lock
28
pubspec.lock
@@ -349,6 +349,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.1"
|
version: "1.5.1"
|
||||||
|
flutter_local_notifications:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_local_notifications
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "8.2.0"
|
||||||
|
flutter_local_notifications_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_local_notifications_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.1"
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -373,6 +387,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_vector_icons:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_vector_icons
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -866,6 +887,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.5"
|
version: "0.0.5"
|
||||||
|
timezone:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: timezone
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.8.0"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user