Implement printing status card and fix transaction screen issues
parent
9fe79d5ab7
commit
a2eedc8efc
|
@ -5,6 +5,35 @@ plugins {
|
|||
id "dev.flutter.flutter-gradle-plugin"
|
||||
}
|
||||
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||
localProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||
if (flutterRoot == null) {
|
||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||
}
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '1'
|
||||
}
|
||||
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
def keystorePropertiesFile = rootProject.file('key.properties')
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.cashumit"
|
||||
compileSdk = 35
|
||||
|
@ -26,15 +55,22 @@ android {
|
|||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||
minSdk = flutter.minSdkVersion
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = flutter.versionCode
|
||||
versionCode = flutter.versionCode.toInteger()
|
||||
versionName = flutter.versionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
|
||||
storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig = signingConfigs.debug
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:cashumit/services/firefly_api_service.dart';
|
|||
import 'package:bluetooth_print/bluetooth_print.dart';
|
||||
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||
import 'package:cashumit/utils/currency_format.dart';
|
||||
import 'package:cashumit/widgets/printing_status_card.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class TransactionScreen extends StatefulWidget {
|
||||
|
@ -40,6 +41,9 @@ class _TransactionScreenState extends State<TransactionScreen> {
|
|||
String? _destinationAccountName;
|
||||
bool _isLoadingAccounts = false;
|
||||
|
||||
// Printing status
|
||||
bool _isPrinting = false;
|
||||
|
||||
// Controllers for manual account input
|
||||
final TextEditingController _sourceAccountController = TextEditingController();
|
||||
final TextEditingController _destinationAccountController = TextEditingController();
|
||||
|
@ -451,6 +455,11 @@ class _TransactionScreenState extends State<TransactionScreen> {
|
|||
|
||||
if (confirmed != true) return;
|
||||
|
||||
// Tampilkan status printing
|
||||
setState(() {
|
||||
_isPrinting = true;
|
||||
});
|
||||
|
||||
// Cetak struk
|
||||
final printService = PrintService();
|
||||
final printed = await printService.printTransaction(
|
||||
|
@ -459,6 +468,11 @@ class _TransactionScreenState extends State<TransactionScreen> {
|
|||
'Jl. Merdeka No. 123, Jakarta',
|
||||
);
|
||||
|
||||
// Sembunyikan status printing
|
||||
setState(() {
|
||||
_isPrinting = false;
|
||||
});
|
||||
|
||||
if (!printed) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
@ -507,7 +521,9 @@ class _TransactionScreenState extends State<TransactionScreen> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
return Stack(
|
||||
children: [
|
||||
Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Aplikasi Kasir'),
|
||||
actions: [
|
||||
|
@ -725,6 +741,16 @@ class _TransactionScreenState extends State<TransactionScreen> {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
PrintingStatusCard(
|
||||
isVisible: _isPrinting,
|
||||
onDismiss: () {
|
||||
setState(() {
|
||||
_isPrinting = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ class PrintingStatusCard extends StatefulWidget {
|
|||
final VoidCallback? onDismiss;
|
||||
|
||||
const PrintingStatusCard({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.isVisible,
|
||||
this.onDismiss,
|
||||
}) : super(key: key);
|
||||
}) : super();
|
||||
|
||||
@override
|
||||
State<PrintingStatusCard> createState() => _PrintingStatusCardState();
|
||||
|
@ -71,12 +71,14 @@ class _PrintingStatusCardState extends State<PrintingStatusCard>
|
|||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
return Positioned(
|
||||
return Visibility(
|
||||
visible: widget.isVisible,
|
||||
child: Positioned(
|
||||
top: 100,
|
||||
left: MediaQuery.of(context).size.width * 0.1,
|
||||
right: MediaQuery.of(context).size.width * 0.1,
|
||||
child: IgnorePointer(
|
||||
ignoring: !widget.isVisible,
|
||||
ignoring: !_fadeAnimation.value.isNaN && _fadeAnimation.value < 0.5,
|
||||
child: Opacity(
|
||||
opacity: _fadeAnimation.value,
|
||||
child: Transform.scale(
|
||||
|
@ -151,6 +153,7 @@ class _PrintingStatusCardState extends State<PrintingStatusCard>
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue