add version text

This commit is contained in:
Sai Naw Wun
2020-11-09 05:53:25 +06:30
parent 84e8053040
commit 08c90fce74
12 changed files with 258 additions and 138 deletions

View File

@@ -511,14 +511,14 @@
"receiving.info":"Receiving", "receiving.info":"Receiving",
"receiving.new":"New receiving", "receiving.new":"New receiving",
"receiving.create":"New Receiving", "receiving.create":"New Receiving",
"receiving.update":"Update Reveiving", "receiving.update":"Update Receiving",
"receiving.tracking.id":"Tracking ID", "receiving.tracking.id":"Tracking ID",
"receiving.remark":"Remark", "receiving.remark":"Remark",
"receiving.fcs.id":"FCS ID", "receiving.fcs.id":"FCS ID",
"receiving.name":"Customer name", "receiving.name":"Customer name",
"receiving.phone":"Phone number", "receiving.phone":"Phone number",
"receiving.create_btn":"Complete receiving", "receiving.create_btn":"Complete receiving",
"receiving.update_btn":"Update reveiving", "receiving.update_btn":"Update receiving",
"receiving.delete.confirm":"Delete this receiving?", "receiving.delete.confirm":"Delete this receiving?",
"receiving.return.btn":"Return package", "receiving.return.btn":"Return package",
"receiving.return.confirm":"Return package?", "receiving.return.confirm":"Return package?",

View File

@@ -88,7 +88,6 @@ class AuthFb {
} }
Future<fcs.AuthResult> signInWithPhoneNumber(String smsCode) async { Future<fcs.AuthResult> signInWithPhoneNumber(String smsCode) async {
User user;
try { try {
final AuthCredential credential = PhoneAuthProvider.getCredential( final AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: _verificationId, verificationId: _verificationId,
@@ -102,7 +101,6 @@ class AuthFb {
} on Exception catch (e) { } on Exception catch (e) {
return Future.error(SigninException(e.toString())); return Future.error(SigninException(e.toString()));
} }
if (user == null) Future.error(SigninException("No current user!"));
return Future.value(fcs.AuthResult(authStatus: AuthStatus.AUTH_VERIFIED)); return Future.value(fcs.AuthResult(authStatus: AuthStatus.AUTH_VERIFIED));
} }

View File

@@ -1,3 +1,5 @@
const uploadPhotoLimit = 10;
const config_collection = "configs"; const config_collection = "configs";
const user_collection = "users"; const user_collection = "users";
const invitations_collection = "invitations"; const invitations_collection = "invitations";

View File

@@ -96,8 +96,9 @@ class Package {
desc: map['desc'], desc: map['desc'],
status: map['status'], status: map['status'],
deliveryAddress: _da, deliveryAddress: _da,
currentStatusDate: currentStatusDate: _currentStatusDate != null
_currentStatusDate != null ? _currentStatusDate.toDate() : null, ? _currentStatusDate.toDate().toLocal()
: null,
photoUrls: _photoUrls, photoUrls: _photoUrls,
shipmentHistory: _shipmentStatus); shipmentHistory: _shipmentStatus);
} }

View File

@@ -204,6 +204,7 @@ class _HomePageState extends State<HomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
User user = Provider.of<MainModel>(context).user; User user = Provider.of<MainModel>(context).user;
if (user == null) { if (user == null) {
Future.microtask( Future.microtask(
() => Navigator.pushNamedAndRemoveUntil(context, "/", (r) => false)); () => Navigator.pushNamedAndRemoveUntil(context, "/", (r) => false));

View File

@@ -66,9 +66,12 @@ class _SplashScreenState extends State<SplashScreen> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
new Image.asset( Container(
"assets/logo.jpg", height: 180,
width: 180, width: 180,
child: new Image.asset(
"assets/logo.jpg",
),
), ),
SizedBox(height: 50), SizedBox(height: 50),
Column( Column(

View File

@@ -108,7 +108,7 @@ class PackageModel extends BaseModel {
if (forCustomer) { if (forCustomer) {
q = q.where("user_id", isEqualTo: user.id); q = q.where("user_id", isEqualTo: user.id);
} }
q = q.orderBy("tracking_id", descending: false); q = q.orderBy("update_time", descending: true);
listener = q.snapshots().listen((QuerySnapshot snapshot) { listener = q.snapshots().listen((QuerySnapshot snapshot) {
_packages.clear(); _packages.clear();
_packages = snapshot.documents.map((documentSnapshot) { _packages = snapshot.documents.map((documentSnapshot) {
@@ -139,6 +139,25 @@ class PackageModel extends BaseModel {
return null; return null;
} }
Future<Package> getPackageByTrackingID(String trackingID) async {
if (user == null) return null;
String path = "/$packages_collection";
try {
var snaps = await Firestore.instance
.collection("$path")
.where("tracking_id", isEqualTo: trackingID)
.getDocuments(source: Source.server);
if (snaps.documents.length == 1) {
var snap = snaps.documents[0];
var package = Package.fromMap(snap.data, snap.documentID);
return package;
}
} catch (e) {
log.warning("Error!! $e");
}
return null;
}
Future<Package> lookupPackage(String trackingID) async { Future<Package> lookupPackage(String trackingID) async {
if (user == null) return null; if (user == null) return null;
String path = "/$packages_collection"; String path = "/$packages_collection";
@@ -201,8 +220,15 @@ class PackageModel extends BaseModel {
return Services.instance.userService.searchUser(term); return Services.instance.userService.searchUser(term);
} }
Future<List<Package>> searchPackage(String term) { Future<List<Package>> searchPackage(String term) async {
return Services.instance.packageService.searchPackage(term); List<Package> packages =
await Services.instance.packageService.searchPackage(term);
Package pkg = await getPackageByTrackingID(term);
if (pkg != null && !packages.contains(pkg)) {
packages.insert(0, pkg);
}
return packages;
} }
Future<void> createPackages(User user, List<Package> packages) { Future<void> createPackages(User user, List<Package> packages) {
@@ -216,7 +242,8 @@ class PackageModel extends BaseModel {
package.fcsID = user.fcsID; package.fcsID = user.fcsID;
} }
if (files != null) { if (files != null) {
if (files.length > 5) throw Exception("Exceed number of file upload"); if (files.length > uploadPhotoLimit)
throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls; package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) { for (File f in files) {
String path = Path.join(pkg_files_path); String path = Path.join(pkg_files_path);
@@ -240,7 +267,12 @@ class PackageModel extends BaseModel {
} }
if (files != null) { if (files != null) {
if (files.length > 5) throw Exception("Exceed number of file upload"); var count = (package.photoUrls?.length ?? 0) +
files.length -
(deletedUrls?.length ?? 0);
if (count > uploadPhotoLimit)
throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls; package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) { for (File f in files) {
String path = Path.join(pkg_files_path); String path = Path.join(pkg_files_path);
@@ -265,7 +297,12 @@ class PackageModel extends BaseModel {
} }
if (files != null) { if (files != null) {
if (files.length > 5) throw Exception("Exceed number of file upload"); var count = (package.photoUrls?.length ?? 0) +
files.length -
(deletedUrls?.length ?? 0);
if (count > uploadPhotoLimit)
throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls; package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) { for (File f in files) {
String path = Path.join(pkg_files_path); String path = Path.join(pkg_files_path);

View File

@@ -52,6 +52,17 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
} else { } else {
package = new Package(); package = new Package();
} }
_trackingIDCtl.addListener(() {
var text = _trackingIDCtl.text;
if (text.contains(RegExp(r'[a-z ]'))) {
text = text.toUpperCase().replaceAll(" ", "");
_trackingIDCtl.value = _trackingIDCtl.value.copyWith(
text: text,
selection:
TextSelection(baseOffset: text.length, extentOffset: text.length),
);
}
});
} }
@override @override
@@ -158,7 +169,9 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
height: 10, height: 10,
), ),
remarkBox, remarkBox,
Divider(),
img, img,
Divider(),
SizedBox( SizedBox(
height: 10, height: 10,
), ),

View File

@@ -9,6 +9,14 @@ Future<String> scanBarcode() async {
if (barcode.contains(gs)) { if (barcode.contains(gs)) {
var codes = barcode.split(gs); var codes = barcode.split(gs);
barcode = codes.length >= 2 ? codes[1] : barcode; barcode = codes.length >= 2 ? codes[1] : barcode;
} else if (barcode.startsWith("96")) {
if (barcode.length == 34) {
int start = barcode.length - 12;
barcode = barcode.substring(start);
} else if (barcode.length == 22) {
int start = barcode.length - 15;
barcode = barcode.substring(start);
}
} }
return barcode; return barcode;
} catch (e) { } catch (e) {

View File

@@ -1,22 +1,30 @@
import 'package:fcs/pages/contact/contact_page.dart'; import 'package:fcs/pages/contact/contact_page.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/term/term_page.dart'; import 'package:fcs/pages/term/term_page.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.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/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
class BottomWidgets extends StatelessWidget { class BottomWidgets extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( var pkgInfo = Provider.of<MainModel>(context).packageInfo;
final versionBox = Text(
"v${pkgInfo.version}+${pkgInfo.buildNumber}",
style: TextStyle(color: Colors.white30),
);
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
InkWell( InkWell(
onTap: () { onTap: () {
Navigator.of(context) Navigator.of(context).push(
.push(CupertinoPageRoute(builder: (context) => ContactPage())); CupertinoPageRoute(builder: (context) => ContactPage()));
}, },
child: _buildSmallButton( child: _buildSmallButton(
context, "contact.btn", SimpleLineIcons.support), context, "contact.btn", SimpleLineIcons.support),
@@ -29,6 +37,12 @@ class BottomWidgets extends StatelessWidget {
child: _buildSmallButton(context, "term.btn", Icons.info_outline), child: _buildSmallButton(context, "term.btn", Icons.info_outline),
), ),
], ],
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: versionBox,
),
],
); );
} }

View File

@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/callbacks.dart';
import 'package:fcs/pages/widgets/right_left_page_rout.dart'; import 'package:fcs/pages/widgets/right_left_page_rout.dart';
import 'package:fcs/pages/widgets/show_img.dart'; import 'package:fcs/pages/widgets/show_img.dart';
import 'package:fcs/pages/widgets/show_multiple_img.dart'; import 'package:fcs/pages/widgets/show_multiple_img.dart';
@@ -48,49 +49,66 @@ class _MultiImageFileState extends State<MultiImageFile> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Column(
height: 130, children: [
width: 500, widget.enabled
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: () => {_openImagePicker(false)},
child: Stack(
children: [
Container(
width: 50,
height: 50,
child: Icon(
MaterialCommunityIcons.image,
color: primaryColor,
size: 35,
),
),
Positioned(
right: 0,
top: 0,
child: actionIcon(
color: Colors.green, iconData: Icons.add))
],
),
),
InkWell(
onTap: () => {_openImagePicker(true)},
child: Stack(
children: [
Container(
width: 50,
height: 50,
child: Icon(
MaterialCommunityIcons.camera,
color: primaryColor,
size: 35,
),
),
Positioned(
right: 0,
top: 0,
child: actionIcon(
color: Colors.green, iconData: Icons.add))
],
),
),
],
)
: Container(),
Container(
height: 100,
child: ListView.separated( child: ListView.separated(
separatorBuilder: (context, index) => Divider( separatorBuilder: (context, index) => Divider(
color: Colors.black, color: Colors.black,
), ),
itemCount: itemCount: fileContainers.length,
widget.enabled ? fileContainers.length + 1 : fileContainers.length,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index == fileContainers.length) {
return InkWell(
onTap: () async {
bool camera = false, gallery = false;
await _dialog(
context, () => camera = true, () => gallery = true);
if (camera || gallery) {
var selectedFile = await ImagePicker().getImage(
source: camera ? ImageSource.camera : ImageSource.gallery,
imageQuality: 80,
maxWidth: 1000);
if (selectedFile != null) {
_fileAdded(DisplayImageSource(), File(selectedFile.path));
}
}
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 200,
height: 130,
decoration: BoxDecoration(
border: Border.all(
color: primaryColor,
width: 2.0,
),
),
child: Icon(SimpleLineIcons.plus),
),
),
);
} else {
return InkWell( return InkWell(
onTap: () => Navigator.push( onTap: () => Navigator.push(
context, context,
@@ -102,16 +120,17 @@ class _MultiImageFileState extends State<MultiImageFile> {
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Container( child: Container(
width: 200, width: 100,
height: 130, height: 100,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
color: primaryColor, color: primaryColor,
width: 2.0, width: 1.0,
), ),
), ),
child: fileContainers[index].file == null child: fileContainers[index].file == null
? CachedNetworkImage( ? CachedNetworkImage(
fit: BoxFit.cover,
width: 50, width: 50,
height: 50, height: 50,
imageUrl: fileContainers[index].url, imageUrl: fileContainers[index].url,
@@ -128,37 +147,44 @@ class _MultiImageFileState extends State<MultiImageFile> {
errorWidget: (context, url, error) => errorWidget: (context, url, error) =>
Icon(Icons.error), Icon(Icons.error),
) )
// Image.network(fileContainers[index].url, : FittedBox(
// width: 50, height: 50) fit: BoxFit.cover,
: Image.file(fileContainers[index].file, child: Image.file(
width: 50, height: 50), fileContainers[index].file,
),
),
), ),
), ),
widget.enabled widget.enabled
? Positioned( ? Positioned(
top: 0, top: 10,
right: 0, right: 0,
child: Container( child: actionIcon(
height: 50, color: Colors.red,
width: 50, iconData: Icons.remove,
child: IconButton( onTap: () =>
icon: Icon(
Icons.close,
color: primaryColor,
),
onPressed: () =>
{_fileRemove(fileContainers[index])}), {_fileRemove(fileContainers[index])}),
),
) )
: Container(), : Container(),
]), ]),
); );
}
}, },
), ),
),
],
); );
} }
_openImagePicker(bool camera) async {
var selectedFile = await ImagePicker().getImage(
source: camera ? ImageSource.camera : ImageSource.gallery,
imageQuality: 80,
maxWidth: 1000);
if (selectedFile != null) {
_fileAdded(DisplayImageSource(), File(selectedFile.path));
}
}
_fileAdded(DisplayImageSource fileContainer, File selectedFile) { _fileAdded(DisplayImageSource fileContainer, File selectedFile) {
fileContainer.file = selectedFile; fileContainer.file = selectedFile;
setState(() { setState(() {
@@ -281,4 +307,21 @@ class _MultiImageFileState extends State<MultiImageFile> {
}, },
); );
} }
Widget actionIcon({OnTap onTap, Color color, IconData iconData}) {
return InkWell(
onTap: onTap,
child: ClipOval(
child: Container(
color: color,
height: 20,
width: 20,
child: Icon(
iconData,
color: Colors.white,
size: 15,
)),
),
);
}
} }

View File

@@ -2,7 +2,7 @@ name: fcs
description: FCS Logistics description: FCS Logistics
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+4 version: 1.0.5+7
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"