add print qr code page
This commit is contained in:
@@ -52,6 +52,7 @@ Future<void> generateCartonPdf(Carton carton) async {
|
||||
style: pw.TextStyle(
|
||||
fontSize: 10,
|
||||
)),
|
||||
pw.SizedBox(height: 3),
|
||||
pw.Text("${carton.actualWeight} lb",
|
||||
style: pw.TextStyle(
|
||||
fontSize: 10,
|
||||
|
||||
@@ -310,7 +310,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
CupertinoPageRoute(builder: (context) => CartonInfo(carton: c)),
|
||||
);
|
||||
},
|
||||
child: CartonRow(box: c));
|
||||
child: CartonRow(carton: c));
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import '../widgets/local_button.dart';
|
||||
import 'carton_package_editor.dart';
|
||||
import 'mix_carton/mix_carton_editor.dart';
|
||||
import 'model/carton_model.dart';
|
||||
import 'print_qr_code_page.dart';
|
||||
|
||||
class CartonInfo extends StatefulWidget {
|
||||
final Carton carton;
|
||||
@@ -100,7 +101,16 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
labelTextKey: "box.number",
|
||||
);
|
||||
|
||||
final cartonQrBox = DisplayText(iconData: AntDesign.qrcode);
|
||||
final cartonQrBox = IconButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => PrintQrCodePage(carton: _carton)),
|
||||
);
|
||||
},
|
||||
icon: Icon(AntDesign.qrcode, color: Colors.black));
|
||||
|
||||
final cartonSubTypeBox = DisplayText(
|
||||
text: _carton.cartonType == carton_from_packages
|
||||
? "Carton for packages"
|
||||
@@ -315,8 +325,8 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
child: LocalText(context, "box.imageupload.title",
|
||||
color: Colors.white, fontSize: 14)),
|
||||
);
|
||||
|
||||
final deleteBtn = Padding(
|
||||
|
||||
final deleteBtn = Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 30),
|
||||
child: LocalButton(
|
||||
color: dangerColor,
|
||||
@@ -400,7 +410,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
const SizedBox(height: 30),
|
||||
img,
|
||||
const SizedBox(height: 40),
|
||||
deleteBtn,
|
||||
deleteBtn,
|
||||
const SizedBox(height: 20)
|
||||
]))));
|
||||
}
|
||||
@@ -446,7 +456,8 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
_init();
|
||||
}
|
||||
}
|
||||
_delete() {
|
||||
|
||||
_delete() {
|
||||
showConfirmDialog(context, "box.delete.confirm", () {
|
||||
_deleteCarton();
|
||||
});
|
||||
|
||||
64
lib/pages/carton/print_qr_code_page.dart
Normal file
64
lib/pages/carton/print_qr_code_page.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
import '../../helpers/pdf.dart';
|
||||
|
||||
class PrintQrCodePage extends StatelessWidget {
|
||||
final Carton carton;
|
||||
const PrintQrCodePage({required this.carton});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: LocalAppBar(
|
||||
labelKey: "box.print.qr.title",
|
||||
backgroundColor: Colors.white,
|
||||
labelColor: primaryColor,
|
||||
arrowColor: primaryColor,
|
||||
actions: []),
|
||||
body: ListView(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
children: [
|
||||
const SizedBox(height: 40),
|
||||
Row(
|
||||
children: [
|
||||
QrImageView(
|
||||
data: 'This is a simple QR code',
|
||||
version: QrVersions.auto,
|
||||
size: 100,
|
||||
gapless: true,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(carton.cartonNumber ?? "",
|
||||
style: TextStyle(fontSize: 18,fontFamily: "Roboto")),
|
||||
Text(carton.userName!, style: TextStyle(fontSize: 16,fontFamily: "Roboto")),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 3),
|
||||
child: Text("${carton.actualWeight} lb",
|
||||
style: TextStyle(fontSize: 16, color: labelColor,fontFamily: "Roboto")),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 40),
|
||||
child: LocalButton(
|
||||
textKey: "box.print.btn",
|
||||
color: primaryColor,
|
||||
iconData: Icons.print_outlined,
|
||||
callBack: () {
|
||||
generateCartonPdf(carton);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
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/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../helpers/pdf.dart';
|
||||
import '../carton_info.dart';
|
||||
import '../print_qr_code_page.dart';
|
||||
|
||||
class CartonListRow extends StatelessWidget {
|
||||
final Carton box;
|
||||
@@ -68,7 +66,12 @@ class CartonListRow extends StatelessWidget {
|
||||
const SizedBox(width: 15),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_pdf(box, context);
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
PrintQrCodePage(carton: box)),
|
||||
);
|
||||
},
|
||||
icon:
|
||||
Icon(AntDesign.qrcode, color: Colors.black))
|
||||
@@ -107,11 +110,4 @@ class CartonListRow extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_pdf(Carton carton, BuildContext context) async {
|
||||
Carton? c = await context.read<CartonModel>().getCarton(carton.id!);
|
||||
if (c == null) return;
|
||||
|
||||
generateCartonPdf(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../print_qr_code_page.dart';
|
||||
|
||||
class CartonRow extends StatelessWidget {
|
||||
final Carton box;
|
||||
CartonRow({Key? key, required this.box}) : super(key: key);
|
||||
final Carton carton;
|
||||
CartonRow({Key? key, required this.carton}) : super(key: key);
|
||||
|
||||
final double dotSize = 15.0;
|
||||
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||
@@ -23,25 +26,34 @@ class CartonRow extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Text(box.cartonNumber ?? "",
|
||||
new Text(carton.cartonNumber ?? "",
|
||||
style:
|
||||
new TextStyle(fontSize: 15.0, color: Colors.black)),
|
||||
const SizedBox(width: 15),
|
||||
IconButton(onPressed: () {}, icon: Icon(AntDesign.qrcode)),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
PrintQrCodePage(carton: carton)),
|
||||
);
|
||||
},
|
||||
icon: Icon(AntDesign.qrcode)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
box.cartonWeight == 0
|
||||
carton.cartonWeight == 0
|
||||
? Container()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, bottom: 5),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
"${box.cartonWeight.toStringAsFixed(2)} lb",
|
||||
"${carton.cartonWeight.toStringAsFixed(2)} lb",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user