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