first commit
This commit is contained in:
55
lib/app/constant.dart
Normal file
55
lib/app/constant.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Constant {
|
||||
static double designHeight = 982;
|
||||
static double designWidth = 1512;
|
||||
static String versi = "Versi 16";
|
||||
|
||||
static TextStyle title({required BuildContext context}) {
|
||||
return TextStyle(
|
||||
fontSize: Constant.getActualX(context: context, x: 32),
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
}
|
||||
|
||||
static TextStyle subTitle({required BuildContext context}) {
|
||||
return TextStyle(
|
||||
fontSize: Constant.getActualX(context: context, x: 22),
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
}
|
||||
|
||||
static TextStyle layananTitle({required BuildContext context}) {
|
||||
return TextStyle(
|
||||
fontSize: Constant.getActualX(context: context, x: 18),
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
}
|
||||
|
||||
static TextStyle label({required BuildContext context}) {
|
||||
return TextStyle(
|
||||
fontSize: Constant.getActualX(context: context, x: 16),
|
||||
fontStyle: FontStyle.italic);
|
||||
}
|
||||
|
||||
static TextStyle normal({required BuildContext context}) {
|
||||
return TextStyle(
|
||||
fontSize: Constant.getActualX(context: context, x: 16),
|
||||
);
|
||||
}
|
||||
|
||||
//size convertion
|
||||
static double getActualX({
|
||||
required BuildContext context,
|
||||
required double x,
|
||||
}) {
|
||||
return x / designWidth * MediaQuery.of(context).size.width;
|
||||
}
|
||||
|
||||
static double getActualY({
|
||||
required BuildContext context,
|
||||
required double y,
|
||||
}) {
|
||||
return y / designHeight * MediaQuery.of(context).size.height;
|
||||
}
|
||||
}
|
||||
367
lib/app/print_ticket.dart
Normal file
367
lib/app/print_ticket.dart
Normal file
@@ -0,0 +1,367 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||
import 'package:flutter_pos_printer_platform_image_3/flutter_pos_printer_platform_image_3.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class PrintTicket {
|
||||
// Future printTest() async {
|
||||
// List<int> bytes = [];
|
||||
// var profile = await CapabilityProfile.load();
|
||||
|
||||
// var generator = Generator(PaperSize.mm80, profile);
|
||||
// bytes += generator.setGlobalCodeTable('CP1252');
|
||||
// bytes += generator.text('TEST PRINT',
|
||||
// styles: const PosStyles(align: PosAlign.center));
|
||||
// bytes += generator.cut();
|
||||
// PrinterManager.instance.send(type: PrinterType.usb, bytes: bytes);
|
||||
// }
|
||||
|
||||
Future printTicket(
|
||||
{required String boothId,
|
||||
required String header,
|
||||
required String date,
|
||||
required String time,
|
||||
required String antrianNumb,
|
||||
required String name,
|
||||
required String location,
|
||||
required StringqrCode,
|
||||
required String isConsult,
|
||||
required String DoctorName,
|
||||
required String layananName,
|
||||
required String capabilityName,
|
||||
required String footer}) async {
|
||||
try {
|
||||
List<int> bytes = [];
|
||||
final dt = DateFormat('yyyy-MM-dd-HH-mm-ss').format(DateTime.now());
|
||||
final splited = dt.split('-');
|
||||
final date = splited[2].toString();
|
||||
final month = splited[1].toString();
|
||||
final year = splited[0].toString();
|
||||
final hour = splited[3].toString();
|
||||
final minute = splited[4].toString();
|
||||
|
||||
final displayDate = "$date/$month/$year - $hour.$minute WIB";
|
||||
|
||||
final profile = await CapabilityProfile.load(name: capabilityName);
|
||||
final avl = await CapabilityProfile.getAvailableProfiles();
|
||||
// final avl = await CapabilityProfile.getAvailableProfiles(name: "XP-N160I");
|
||||
// print(avl);
|
||||
|
||||
var generator = Generator(PaperSize.mm80, profile);
|
||||
|
||||
bytes += generator.text(
|
||||
"Booth :$boothId",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.right,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
// bytes += generator.text(
|
||||
// "capability :$capabilityName",
|
||||
// styles: const PosStyles(
|
||||
// align: PosAlign.right,
|
||||
// bold: true,
|
||||
// height: PosTextSize.size1,
|
||||
// width: PosTextSize.size1),
|
||||
// );
|
||||
bytes += generator.hr(ch: " ");
|
||||
|
||||
bytes += generator.text(
|
||||
header,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
|
||||
bytes += generator.hr(ch: " ");
|
||||
bytes += generator.text(
|
||||
displayDate,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
bytes += generator.hr(ch: " ");
|
||||
bytes += generator.text("NOMOR ANTRIAN",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
linesAfter: 1);
|
||||
if (isConsult == 'N') {
|
||||
bytes += generator.text("${layananName}",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
linesAfter: 1);
|
||||
}
|
||||
|
||||
if (isConsult == 'Y') {
|
||||
bytes += generator.text("${layananName} ${DoctorName}",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
linesAfter: 1);
|
||||
}
|
||||
|
||||
bytes += generator.text(antrianNumb,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2),
|
||||
linesAfter: 1);
|
||||
// final List<dynamic> barData = "{A$antrianNumb".split("");
|
||||
// bytes += generator.barcode(Barcode.code128(barData),
|
||||
// height: 60, textPos: BarcodeText.none);
|
||||
// bytes += generator.hr(ch: " ");
|
||||
bytes += generator.text(
|
||||
"SIMPAN TIKET INI HINGGA",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
bytes += generator.text(
|
||||
"SELURUH LAYANAN ANDA SELESAI",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
bytes += generator.hr(ch: " ");
|
||||
if (name != "") {
|
||||
bytes += generator.text(
|
||||
name,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
}
|
||||
// bytes += generator.text(
|
||||
// location,
|
||||
// linesAfter: 1,
|
||||
// styles: const PosStyles(
|
||||
// align: PosAlign.center,
|
||||
// bold: false,
|
||||
// height: PosTextSize.size1,
|
||||
// width: PosTextSize.size1),
|
||||
// );
|
||||
// bytes += generator.text(
|
||||
// "LAYANAN LABORATORIUM MEDIS",
|
||||
// styles: const PosStyles(
|
||||
// align: PosAlign.center,
|
||||
// bold: false,
|
||||
// height: PosTextSize.size1,
|
||||
// width: PosTextSize.size1),
|
||||
// );
|
||||
|
||||
// bytes +=
|
||||
// generator.qrcode("$StringqrCode$antrianNumb", size: QRSize.Size8);
|
||||
// bytes += generator.hr(ch: " ");
|
||||
|
||||
bytes += generator.text(
|
||||
footer,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
|
||||
bytes += generator.cut();
|
||||
// final directory = await getApplicationDocumentsDirectory();
|
||||
|
||||
// final file =
|
||||
// File('${directory.path}/$antrianNumb-$date-$month-$year.txt');
|
||||
// await file.writeAsString(bytes.toString());
|
||||
|
||||
PrinterManager.instance.send(type: PrinterType.usb, bytes: bytes);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
Future printTest(
|
||||
{String boothId = "Test Booth",
|
||||
String header = "Test header",
|
||||
String date = "Test Date",
|
||||
String time = "Test time",
|
||||
String antrianNumb = "Test01",
|
||||
String name = "Test name",
|
||||
String location = "Test location",
|
||||
StringqrCode = "Test01",
|
||||
String isConsult = "N",
|
||||
String DoctorName = "-",
|
||||
String layananName = "Test Layanan",
|
||||
String footer = "Test footer"}) async {
|
||||
try {
|
||||
List<int> bytes = [];
|
||||
final dt = DateFormat('yyyy-MM-dd-HH-mm-ss').format(DateTime.now());
|
||||
final splited = dt.split('-');
|
||||
final date = splited[2].toString();
|
||||
final month = splited[1].toString();
|
||||
final year = splited[0].toString();
|
||||
final hour = splited[3].toString();
|
||||
final minute = splited[4].toString();
|
||||
|
||||
final displayDate = "$date/$month/$year - $hour.$minute WIB";
|
||||
|
||||
final profile = await CapabilityProfile.load(name: "XP-N160I");
|
||||
|
||||
var generator = Generator(PaperSize.mm80, profile);
|
||||
|
||||
bytes += generator.text(
|
||||
"Booth :$boothId",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.right,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
bytes += generator.hr(ch: " ");
|
||||
|
||||
bytes += generator.text(
|
||||
header,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
|
||||
bytes += generator.hr(ch: " ");
|
||||
bytes += generator.text(
|
||||
displayDate,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
bytes += generator.hr(ch: " ");
|
||||
bytes += generator.text("NOMOR ANTRIAN",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
linesAfter: 1);
|
||||
if (isConsult == 'N') {
|
||||
bytes += generator.text("${layananName}",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
linesAfter: 1);
|
||||
}
|
||||
|
||||
if (isConsult == 'Y') {
|
||||
bytes += generator.text("${layananName} ${DoctorName}",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
linesAfter: 1);
|
||||
}
|
||||
|
||||
bytes += generator.text(antrianNumb,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: true,
|
||||
height: PosTextSize.size8,
|
||||
width: PosTextSize.size8),
|
||||
linesAfter: 1);
|
||||
final List<dynamic> barData = "{A$antrianNumb".split("");
|
||||
bytes += generator.barcode(Barcode.code128(barData),
|
||||
height: 60, textPos: BarcodeText.none);
|
||||
bytes += generator.hr(ch: " ");
|
||||
bytes += generator.text(
|
||||
"SIMPAN TIKET INI HINGGA",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
bytes += generator.text(
|
||||
"SELURUH LAYANAN ANDA SELESAI",
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
bytes += generator.hr(ch: " ");
|
||||
if (name != "") {
|
||||
bytes += generator.text(
|
||||
name,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
}
|
||||
bytes += generator.text(
|
||||
location,
|
||||
linesAfter: 1,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
// bytes += generator.text(
|
||||
// "LAYANAN LABORATORIUM MEDIS",
|
||||
// styles: const PosStyles(
|
||||
// align: PosAlign.center,
|
||||
// bold: false,
|
||||
// height: PosTextSize.size1,
|
||||
// width: PosTextSize.size1),
|
||||
// );
|
||||
|
||||
// bytes +=
|
||||
// generator.qrcode("$StringqrCode$antrianNumb", size: QRSize.Size8);
|
||||
// bytes += generator.hr(ch: " ");
|
||||
|
||||
bytes += generator.text(
|
||||
footer,
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.center,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1),
|
||||
);
|
||||
|
||||
bytes += generator.cut();
|
||||
// final directory = await getApplicationDocumentsDirectory();
|
||||
|
||||
// final file =
|
||||
// File('${directory.path}/$antrianNumb-$date-$month-$year.txt');
|
||||
// await file.writeAsString(bytes.toString());
|
||||
|
||||
await PrinterManager.instance.send(type: PrinterType.usb, bytes: bytes);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
98
lib/app/route.dart
Normal file
98
lib/app/route.dart
Normal file
@@ -0,0 +1,98 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ticket_booth/screen/initial/initial_screen.dart';
|
||||
import 'package:ticket_booth/screen/queue/queue_screen.dart';
|
||||
import 'package:ticket_booth/screen/settings/setting_screen.dart';
|
||||
import 'package:ticket_booth/screen/splash/splash_screen.dart';
|
||||
|
||||
const splashScreen = "/splashScreen";
|
||||
const settingRoute = "/settingRoute";
|
||||
const displayRoute = "/displayScreenRoute";
|
||||
const queueRoute = "/queueRoute";
|
||||
const tvRoute = "/tvRoute";
|
||||
|
||||
class AppRoute {
|
||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
// initial screen
|
||||
if (settings.name == displayRoute) {
|
||||
return MaterialPageRoute(builder: (context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaleFactor: 1.0,
|
||||
padding: const EdgeInsets.all(0),
|
||||
),
|
||||
child: const InitialScreen());
|
||||
});
|
||||
}
|
||||
if (settings.name == settingRoute) {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
const SettingScreen(),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
const begin = Offset(0.0, 1.0);
|
||||
const end = Offset.zero;
|
||||
const curve = Curves.ease;
|
||||
|
||||
var tween =
|
||||
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
|
||||
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
//Queue screen
|
||||
if (settings.name == queueRoute) {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
const QueueScreen(),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
const begin = Offset(0.0, 1.0);
|
||||
const end = Offset.zero;
|
||||
const curve = Curves.ease;
|
||||
|
||||
var tween =
|
||||
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
|
||||
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
// //Queue screen
|
||||
// if (settings.name == tvRoute) {
|
||||
// return PageRouteBuilder(
|
||||
// pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
// const TvTemplate(),
|
||||
// transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
// const begin = Offset(0.0, 1.0);
|
||||
// const end = Offset.zero;
|
||||
// const curve = Curves.ease;
|
||||
|
||||
// var tween =
|
||||
// Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
|
||||
|
||||
// return SlideTransition(
|
||||
// position: animation.drive(tween),
|
||||
// child: child,
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
//splash screen
|
||||
if (settings.name == splashScreen) {
|
||||
return MaterialPageRoute(builder: (context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaleFactor: 1.0,
|
||||
padding: const EdgeInsets.all(0),
|
||||
),
|
||||
child: const SplashScreen());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user