upload file & revisi ui
This commit is contained in:
@@ -19,6 +19,9 @@ class Constant {
|
|||||||
|
|
||||||
static String baseUrlDevone =
|
static String baseUrlDevone =
|
||||||
"https://devone.aplikasi.web.id/one-api-pettycash/pettycash/";
|
"https://devone.aplikasi.web.id/one-api-pettycash/pettycash/";
|
||||||
|
// "http://devone.aplikasi.web.id/one-api-pettycash/pettycash/";
|
||||||
|
static String baseUrlFile =
|
||||||
|
"https://devone.aplikasi.web.id/pettycash-media/attachment/";
|
||||||
|
|
||||||
// static String baseUrl_appdoctor =
|
// static String baseUrl_appdoctor =
|
||||||
// "http://devbandungraya.aplikasi.web.id/one-api/app_doctor/";
|
// "http://devbandungraya.aplikasi.web.id/one-api/app_doctor/";
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:app_petty_cash/model/list_type_model.dart';
|
import 'package:app_petty_cash/model/list_type_model.dart';
|
||||||
|
|
||||||
import '../app/constant.dart';
|
import '../app/constant.dart';
|
||||||
@@ -57,34 +59,68 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
String catatan,
|
String catatan,
|
||||||
String userid,
|
String userid,
|
||||||
String sender,
|
String sender,
|
||||||
|
String base64file,
|
||||||
|
String fileName,
|
||||||
|
String fileSize,
|
||||||
|
String fileExtension,
|
||||||
String url) async {
|
String url) async {
|
||||||
String paramPostInUrl = "";
|
// String paramPostInUrl = "";
|
||||||
|
Map<String, dynamic> prm = {};
|
||||||
String M_CompanyID = await getCompanyID();
|
String M_CompanyID = await getCompanyID();
|
||||||
if (tipe == "DEBIT") {
|
if (tipe == "DEBIT") {
|
||||||
sender = "";
|
sender = "";
|
||||||
paramPostInUrl =
|
prm = {
|
||||||
"?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
'tanggal': tanggal,
|
||||||
|
'tipe': tipe,
|
||||||
|
'kategoriid': kategoriid,
|
||||||
|
'jumlah': jumlah,
|
||||||
|
'catatan': catatan,
|
||||||
|
'url': url,
|
||||||
|
'userid': userid,
|
||||||
|
'sender': sender,
|
||||||
|
'companyid': M_CompanyID,
|
||||||
|
'base64File': base64file,
|
||||||
|
'fileName': fileName,
|
||||||
|
'fileSize': fileSize,
|
||||||
|
'fileEkstension': fileExtension
|
||||||
|
};
|
||||||
|
|
||||||
|
// paramPostInUrl =
|
||||||
|
// "?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
||||||
} else {
|
} else {
|
||||||
if (tipe == "KREDIT") {
|
if (tipe == "KREDIT") {
|
||||||
kategoriid = "0";
|
kategoriid = "0";
|
||||||
paramPostInUrl =
|
prm = {
|
||||||
"?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
'tanggal': tanggal,
|
||||||
|
'tipe': tipe,
|
||||||
|
'kategoriid': kategoriid,
|
||||||
|
'jumlah': jumlah,
|
||||||
|
'catatan': catatan,
|
||||||
|
'url': url,
|
||||||
|
'userid': userid,
|
||||||
|
'sender': sender,
|
||||||
|
'companyid': M_CompanyID,
|
||||||
|
'fileName': fileName,
|
||||||
|
'fileSize': fileSize,
|
||||||
|
'fileEkstension': fileExtension
|
||||||
|
};
|
||||||
|
// paramPostInUrl =
|
||||||
|
// "?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paramPostInUrl += "&companyid=$M_CompanyID";
|
// paramPostInUrl += "&companyid=$M_CompanyID";
|
||||||
// /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender=
|
// /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender=
|
||||||
|
|
||||||
final service =
|
final service = "${Constant.baseUrlDevone}transaction/addtransaction";
|
||||||
"${Constant.baseUrlDevone}transaction/addtransaction/$paramPostInUrl";
|
final resp = await post(
|
||||||
final resp = await get(
|
// param: {
|
||||||
// param: {
|
// "": "",
|
||||||
// "": "",
|
// },
|
||||||
// },
|
service: service,
|
||||||
service: service,
|
param: prm);
|
||||||
);
|
|
||||||
|
|
||||||
print("url insert transaksi : $service");
|
print("prm insert transaksi : ${jsonEncode(prm)}");
|
||||||
|
|
||||||
// final result = List<ListCategory>.empty(growable: true);
|
// final result = List<ListCategory>.empty(growable: true);
|
||||||
// resp['data'].forEach((e) {
|
// resp['data'].forEach((e) {
|
||||||
@@ -127,7 +163,6 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
String id,
|
String id,
|
||||||
String userid,
|
String userid,
|
||||||
) async {
|
) async {
|
||||||
|
|
||||||
final service =
|
final service =
|
||||||
"${Constant.baseUrlDevone}transaction/deletetransaction/?id=$id&userid=$userid";
|
"${Constant.baseUrlDevone}transaction/deletetransaction/?id=$id&userid=$userid";
|
||||||
final resp = await get(
|
final resp = await get(
|
||||||
@@ -145,7 +180,7 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
// result.add(model);
|
// result.add(model);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
if(resp['status'] != "OK"){
|
if (resp['status'] != "OK") {
|
||||||
return resp['message'];
|
return resp['message'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,15 +43,18 @@ class InsertTransaksiNotifier extends StateNotifier<InsertTransaksiState> {
|
|||||||
}) : super(InsertTransaksiStateInit());
|
}) : super(InsertTransaksiStateInit());
|
||||||
|
|
||||||
void insertTransaksi(
|
void insertTransaksi(
|
||||||
String tanggal,
|
{required String tanggal,
|
||||||
String tipe,
|
required String tipe,
|
||||||
String kategoriid,
|
required String kategoriid,
|
||||||
String jumlah,
|
required String jumlah,
|
||||||
String catatan,
|
required String catatan,
|
||||||
String userid,
|
required String userid,
|
||||||
String sender,
|
required String sender,
|
||||||
String url,
|
required String url,
|
||||||
) async {
|
required String base64file,
|
||||||
|
required String fileName,
|
||||||
|
required String fileSize,
|
||||||
|
required String fileExtension}) async {
|
||||||
try {
|
try {
|
||||||
state = InsertTransaksiStateLoading();
|
state = InsertTransaksiStateLoading();
|
||||||
final dio = ref.read(dioProvider);
|
final dio = ref.read(dioProvider);
|
||||||
@@ -63,6 +66,10 @@ class InsertTransaksiNotifier extends StateNotifier<InsertTransaksiState> {
|
|||||||
catatan,
|
catatan,
|
||||||
userid,
|
userid,
|
||||||
sender,
|
sender,
|
||||||
|
base64file,
|
||||||
|
fileName,
|
||||||
|
fileSize,
|
||||||
|
fileExtension,
|
||||||
url,
|
url,
|
||||||
);
|
);
|
||||||
state = InsertTransaksiStateDone(resp: resp);
|
state = InsertTransaksiStateDone(resp: resp);
|
||||||
|
|||||||
@@ -3,16 +3,17 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class TransaksiPickDateWidget extends StatelessWidget {
|
class TransaksiPickDateWidget extends StatelessWidget {
|
||||||
const TransaksiPickDateWidget({
|
const TransaksiPickDateWidget(
|
||||||
super.key,
|
{super.key,
|
||||||
required this.ctrlTglAwal,
|
required this.ctrlTglAwal,
|
||||||
required this.tglAwal,
|
required this.tglAwal,
|
||||||
required this.tglAwalTmp,
|
required this.tglAwalTmp,
|
||||||
});
|
required this.isLoading});
|
||||||
|
|
||||||
final TextEditingController ctrlTglAwal;
|
final TextEditingController ctrlTglAwal;
|
||||||
final ValueNotifier<DateTime> tglAwal;
|
final ValueNotifier<DateTime> tglAwal;
|
||||||
final ValueNotifier<String> tglAwalTmp;
|
final ValueNotifier<String> tglAwalTmp;
|
||||||
|
final ValueNotifier<bool> isLoading;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -63,35 +64,38 @@ class TransaksiPickDateWidget extends StatelessWidget {
|
|||||||
// color: Constant.colorIconDate,
|
// color: Constant.colorIconDate,
|
||||||
// ),
|
// ),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: !isLoading.value
|
||||||
final selectedDateAwal = await showDatePicker(
|
? () async {
|
||||||
keyboardType: TextInputType.none,
|
final selectedDateAwal = await showDatePicker(
|
||||||
// locale: const Locale("en-CA"),
|
keyboardType: TextInputType.none,
|
||||||
// locale: ,
|
// locale: const Locale("en-CA"),
|
||||||
context: context,
|
// locale: ,
|
||||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
context: context,
|
||||||
firstDate: DateTime(2000),
|
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||||
lastDate: DateTime(2100),
|
firstDate: DateTime(2000),
|
||||||
|
lastDate: DateTime(2100),
|
||||||
|
|
||||||
initialDate:
|
initialDate: (ctrlTglAwal.text.isEmpty)
|
||||||
(ctrlTglAwal.text.isEmpty) ? DateTime.now() : tglAwal.value,
|
? DateTime.now()
|
||||||
);
|
: tglAwal.value,
|
||||||
|
);
|
||||||
|
|
||||||
if (selectedDateAwal != null) {
|
if (selectedDateAwal != null) {
|
||||||
String formattedDate =
|
String formattedDate =
|
||||||
DateFormat('dd-MM-yyyy').format(selectedDateAwal);
|
DateFormat('dd-MM-yyyy').format(selectedDateAwal);
|
||||||
// ctrlTglAwal.text =
|
// ctrlTglAwal.text =
|
||||||
// selectedDateAwal.toString().split(' ')[0];
|
// selectedDateAwal.toString().split(' ')[0];
|
||||||
ctrlTglAwal.text = formattedDate;
|
ctrlTglAwal.text = formattedDate;
|
||||||
tglAwal.value = selectedDateAwal;
|
tglAwal.value = selectedDateAwal;
|
||||||
tglAwalTmp.value = selectedDateAwal.toString();
|
tglAwalTmp.value = selectedDateAwal.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedDateAwal == null) {
|
if (selectedDateAwal == null) {
|
||||||
print('cancel button');
|
print('cancel button');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'dart:convert';
|
|||||||
import 'dart:io' as io;
|
import 'dart:io' as io;
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:app_petty_cash/app/app_extension.dart';
|
|
||||||
import 'package:app_petty_cash/app/route.dart';
|
import 'package:app_petty_cash/app/route.dart';
|
||||||
import 'package:app_petty_cash/model/list_type_model.dart';
|
import 'package:app_petty_cash/model/list_type_model.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/insert_transaksi_provider.dart';
|
import 'package:app_petty_cash/screen/transaksi/insert_transaksi_provider.dart';
|
||||||
@@ -11,7 +10,6 @@ import 'package:app_petty_cash/screen/transaksi/list_type_provider.dart';
|
|||||||
import 'package:app_petty_cash/screen/transaksi/transaksi_pick_date_widget.dart';
|
import 'package:app_petty_cash/screen/transaksi/transaksi_pick_date_widget.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/transaksi_select_kategori_widget.dart';
|
import 'package:app_petty_cash/screen/transaksi/transaksi_select_kategori_widget.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/transaksi_upload_area_widget.dart';
|
import 'package:app_petty_cash/screen/transaksi/transaksi_upload_area_widget.dart';
|
||||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -19,14 +17,12 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:mime/mime.dart';
|
|
||||||
|
|
||||||
import '../../app/constant.dart';
|
import '../../app/constant.dart';
|
||||||
import '../../model/list_category_model.dart';
|
import '../../model/list_category_model.dart';
|
||||||
import '../../provider/current_user_provider.dart';
|
import '../../provider/current_user_provider.dart';
|
||||||
import '../../widget/custom_drawer.dart';
|
import '../../widget/custom_drawer.dart';
|
||||||
import '../../widget/sankbar_widget.dart';
|
import '../../widget/sankbar_widget.dart';
|
||||||
import '../login/custom_text_field.dart';
|
|
||||||
|
|
||||||
class DummyDropdownTipe {
|
class DummyDropdownTipe {
|
||||||
final String options;
|
final String options;
|
||||||
@@ -58,6 +54,8 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
final fileDataBase64 = useState<String>("");
|
final fileDataBase64 = useState<String>("");
|
||||||
final isImage = useState(false);
|
final isImage = useState(false);
|
||||||
final fileEkstension = useState("");
|
final fileEkstension = useState("");
|
||||||
|
final fileSize = useState(0);
|
||||||
|
final fileName = useState("");
|
||||||
|
|
||||||
String formattedDate = DateFormat('dd-MM-yyyy').format(DateTime.now());
|
String formattedDate = DateFormat('dd-MM-yyyy').format(DateTime.now());
|
||||||
|
|
||||||
@@ -200,15 +198,16 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
// List<int> imageBytes = await fileData.value?.readAsBytes();
|
// List<int> imageBytes = await fileData.value?.readAsBytes();
|
||||||
if (fileData.value != null) {
|
if (fileData.value != null) {
|
||||||
final bytes = io.File(fileData.value!.path).readAsBytesSync();
|
final bytes = io.File(fileData.value!.path).readAsBytesSync();
|
||||||
String base64Image = base64Encode(bytes);
|
String base64Image = base64Encode(await fileData.value!.readAsBytes());
|
||||||
fileDataBase64.value = base64Image;
|
fileDataBase64.value = base64Image;
|
||||||
final file = File(fileData.value!.path);
|
final file = File(fileData.value!.path);
|
||||||
print(file.lengthSync() / 1000000);
|
print(file.lengthSync() / 1000000);
|
||||||
print(await fileData.value!.length());
|
print(await fileData.value!.length());
|
||||||
|
fileSize.value = await fileData.value!.length();
|
||||||
|
|
||||||
// await getExternalStorageDirectory();
|
// await getExternalStorageDirectory();
|
||||||
// print(await fileData.value!.saveTo(path));
|
// print(await fileData.value!.saveTo(path));
|
||||||
print(base64Image);
|
print(fileDataBase64.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,13 +217,25 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
source: ImageSource.camera,
|
source: ImageSource.camera,
|
||||||
);
|
);
|
||||||
if (pickedFile != null) {
|
if (pickedFile != null) {
|
||||||
|
final tmpFile = FilePickerResult([
|
||||||
|
PlatformFile(
|
||||||
|
name: pickedFile.name,
|
||||||
|
size: await pickedFile.length(),
|
||||||
|
path: pickedFile.path,
|
||||||
|
)
|
||||||
|
]);
|
||||||
if (await pickedFile.length() > 10000000) {
|
if (await pickedFile.length() > 10000000) {
|
||||||
SanckbarWidget(context, "File tidak boleh lebih dari 10 MB",
|
SanckbarWidget(context, "File tidak boleh lebih dari 10 MB",
|
||||||
snackbarType.warning);
|
snackbarType.warning);
|
||||||
} else {
|
} else {
|
||||||
fileData.value = pickedFile;
|
fileData.value = pickedFile;
|
||||||
isImage.value = true;
|
isImage.value = true;
|
||||||
|
fileEkstension.value = tmpFile.files.single.extension ?? "";
|
||||||
|
DateTime now = new DateTime.now();
|
||||||
|
fileName.value =
|
||||||
|
"IMG-${now.year}${now.month}${now.day}.${tmpFile.files.single.extension ?? ''}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// final Directory appDocumentsDir =
|
// final Directory appDocumentsDir =
|
||||||
// await getApplicationDocumentsDirectory();
|
// await getApplicationDocumentsDirectory();
|
||||||
// print(appDocumentsDir);
|
// print(appDocumentsDir);
|
||||||
@@ -269,13 +280,14 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
SanckbarWidget(context, "File tidak boleh lebih dari 10 MB",
|
SanckbarWidget(context, "File tidak boleh lebih dari 10 MB",
|
||||||
snackbarType.warning);
|
snackbarType.warning);
|
||||||
} else {
|
} else {
|
||||||
File files = File(result.files.single.path!);
|
// File files = File(result.files.single.path!);
|
||||||
print(result.files.single.extension);
|
print(result.files.single.extension);
|
||||||
XFile fl = XFile(result.files.single.path!);
|
XFile fl = XFile(result.files.single.path!);
|
||||||
|
fileName.value = result.files.single.name;
|
||||||
|
|
||||||
isImage.value = imgExt.contains(result.files.single.extension);
|
isImage.value = imgExt.contains(result.files.single.extension);
|
||||||
|
|
||||||
print("ini xfile");
|
print(result.files.single.name);
|
||||||
fileData.value = fl;
|
fileData.value = fl;
|
||||||
await getBase64();
|
await getBase64();
|
||||||
fileEkstension.value = result.files.single.extension ?? "";
|
fileEkstension.value = result.files.single.extension ?? "";
|
||||||
@@ -285,6 +297,69 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insertTransaksi() {
|
||||||
|
if (selectedListTypeData.value.typeid.toString() == "DEBIT") {
|
||||||
|
ctrlNamaPengirim.text = "";
|
||||||
|
// validasi form
|
||||||
|
if (ctrlJumlah.text.isEmpty || ctrlCatatan.text.trim().isEmpty) {
|
||||||
|
SanckbarWidget(
|
||||||
|
context, "Jumlah dan catatan harus diisi", snackbarType.warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (selectedListTypeData.value.typeid.toString() == "KREDIT") {
|
||||||
|
selectedListCategory.value.categoryid = "0";
|
||||||
|
// validasi form
|
||||||
|
if (ctrlNamaPengirim.text.trim().isEmpty ||
|
||||||
|
ctrlJumlah.text.isEmpty ||
|
||||||
|
ctrlCatatan.text.trim().isEmpty) {
|
||||||
|
SanckbarWidget(
|
||||||
|
context,
|
||||||
|
"Nama pengirim, jumlah dan catatan harus diisi",
|
||||||
|
snackbarType.warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime parsedDate = DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateTransaksi =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDate);
|
||||||
|
var param = {
|
||||||
|
"tgltransaksi": formattedDateTransaksi,
|
||||||
|
"typeid": selectedListTypeData.value.typeid.toString(),
|
||||||
|
"categoryid": selectedListCategory.value.categoryid.toString(),
|
||||||
|
"jumlah": ctrlJumlah.value.text.toString(),
|
||||||
|
"catatan": ctrlCatatan.value.text.toString(),
|
||||||
|
// "userid": "1",
|
||||||
|
"userid": userIDLogin,
|
||||||
|
"namapengirim": ctrlNamaPengirim.value.text.toString(),
|
||||||
|
"url": "",
|
||||||
|
// "base64file": fileDataBase64.value,
|
||||||
|
"fileName": fileName.value,
|
||||||
|
"fileExtension": fileEkstension.value,
|
||||||
|
"fileSize": fileSize.value.toString()
|
||||||
|
};
|
||||||
|
print(param);
|
||||||
|
// return;
|
||||||
|
ref.read(insertTransaksiProvider.notifier).insertTransaksi(
|
||||||
|
tanggal: formattedDateTransaksi,
|
||||||
|
tipe: selectedListTypeData.value.typeid.toString(),
|
||||||
|
kategoriid: selectedListCategory.value.categoryid.toString(),
|
||||||
|
jumlah: ctrlJumlah.value.text.toString(),
|
||||||
|
catatan: ctrlCatatan.value.text.toString(),
|
||||||
|
// "1",
|
||||||
|
userid: userIDLogin,
|
||||||
|
sender: ctrlNamaPengirim.value.text.toString(),
|
||||||
|
url: "",
|
||||||
|
base64file: fileDataBase64.value,
|
||||||
|
fileName: fileData.value?.name ?? "",
|
||||||
|
fileExtension: fileEkstension.value,
|
||||||
|
fileSize: fileSize.value.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: Constant.getActualYPhone(context: context, y: 30),
|
top: Constant.getActualYPhone(context: context, y: 30),
|
||||||
@@ -307,7 +382,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: MediaQuery.of(context).size.height - 10,
|
// height: MediaQuery.of(context).size.height - 10,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -363,9 +438,11 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
// Tanggal Transaksi
|
// Tanggal Transaksi
|
||||||
TransaksiPickDateWidget(
|
TransaksiPickDateWidget(
|
||||||
ctrlTglAwal: ctrlTglAwal,
|
ctrlTglAwal: ctrlTglAwal,
|
||||||
tglAwal: tglAwal,
|
tglAwal: tglAwal,
|
||||||
tglAwalTmp: tglAwalTmp),
|
tglAwalTmp: tglAwalTmp,
|
||||||
|
isLoading: transaksiIsLoading,
|
||||||
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Constant.getActualYPhone(context: context, y: 20),
|
height: Constant.getActualYPhone(context: context, y: 20),
|
||||||
@@ -413,14 +490,16 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
value: listTypeData.value[i],
|
value: listTypeData.value[i],
|
||||||
groupValue:
|
groupValue:
|
||||||
selectedListTypeData.value,
|
selectedListTypeData.value,
|
||||||
onChanged: (ListType? index) {
|
onChanged: !transaksiIsLoading.value
|
||||||
if (isMounted()) {
|
? (ListType? index) {
|
||||||
selectedListTypeData.value =
|
if (isMounted()) {
|
||||||
index!;
|
selectedListTypeData
|
||||||
} else {
|
.value = index!;
|
||||||
return;
|
} else {
|
||||||
}
|
return;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
listTypeData.value[i].typename ??
|
listTypeData.value[i].typename ??
|
||||||
@@ -468,6 +547,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: TransaksiSelectKategoriWidget(
|
: TransaksiSelectKategoriWidget(
|
||||||
|
isLoading: transaksiIsLoading,
|
||||||
listCategoryData: listCategoryData,
|
listCategoryData: listCategoryData,
|
||||||
selectedListCategory: selectedListCategory),
|
selectedListCategory: selectedListCategory),
|
||||||
|
|
||||||
@@ -491,6 +571,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
TextField(
|
TextField(
|
||||||
controller: ctrlNamaPengirim,
|
controller: ctrlNamaPengirim,
|
||||||
|
readOnly: transaksiIsLoading.value,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintStyle:
|
hintStyle:
|
||||||
Constant.body2_400(context: context).copyWith(
|
Constant.body2_400(context: context).copyWith(
|
||||||
@@ -534,6 +615,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
TextField(
|
TextField(
|
||||||
controller: ctrlJumlah,
|
controller: ctrlJumlah,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
|
readOnly: transaksiIsLoading.value,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintStyle:
|
hintStyle:
|
||||||
Constant.body2_400(context: context).copyWith(
|
Constant.body2_400(context: context).copyWith(
|
||||||
@@ -576,6 +658,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
|
readOnly: transaksiIsLoading.value,
|
||||||
controller: ctrlCatatan,
|
controller: ctrlCatatan,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -610,6 +693,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
// Upload File
|
// Upload File
|
||||||
TransaksiUploadAreaWidget(
|
TransaksiUploadAreaWidget(
|
||||||
|
isLoading: transaksiIsLoading,
|
||||||
isImage: isImage,
|
isImage: isImage,
|
||||||
fileData: fileData,
|
fileData: fileData,
|
||||||
fileDataBase64: fileDataBase64,
|
fileDataBase64: fileDataBase64,
|
||||||
@@ -619,7 +703,11 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
// Spacer(),
|
// Spacer(),
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
top: Constant.getActualYPhone(
|
||||||
|
context: context, y: 24)),
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
width: Constant.getActualXPhone(context: context, x: 390),
|
||||||
|
height: Constant.getActualY(context: context, y: 64),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
@@ -642,7 +730,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
(transaksiIsLoading.value)
|
(transaksiIsLoading.value)
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: Constant.getActualXPhone(
|
width: Constant.getActualXPhone(
|
||||||
context: context, x: 24),
|
context: context, x: 32),
|
||||||
height: Constant.getActualYPhone(
|
height: Constant.getActualYPhone(
|
||||||
context: context, y: 32),
|
context: context, y: 32),
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
@@ -658,54 +746,12 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: !transaksiIsLoading.value
|
||||||
if (selectedListTypeData.value.typeid.toString() ==
|
? () {
|
||||||
"DEBIT") {
|
// transaksiIsLoading.value = true;
|
||||||
ctrlNamaPengirim.text = "";
|
insertTransaksi();
|
||||||
// validasi form
|
}
|
||||||
} else {
|
: null,
|
||||||
if (selectedListTypeData.value.typeid.toString() ==
|
|
||||||
"KREDIT") {
|
|
||||||
selectedListCategory.value.categoryid = "0";
|
|
||||||
// validasi form
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime parsedDate = DateFormat('dd-MM-yyyy').parse(
|
|
||||||
ctrlTglAwal.value.text.toString(),
|
|
||||||
);
|
|
||||||
String formattedDateTransaksi =
|
|
||||||
DateFormat('yyyy-MM-dd').format(parsedDate);
|
|
||||||
var param = {
|
|
||||||
"tgltransaksi": formattedDateTransaksi,
|
|
||||||
"typeid":
|
|
||||||
selectedListTypeData.value.typeid.toString(),
|
|
||||||
"categoryid": selectedListCategory.value.categoryid
|
|
||||||
.toString(),
|
|
||||||
"jumlah": ctrlJumlah.value.text.toString(),
|
|
||||||
"catatan": ctrlCatatan.value.text.toString(),
|
|
||||||
// "userid": "1",
|
|
||||||
"userid": userIDLogin,
|
|
||||||
"namapengirim":
|
|
||||||
ctrlNamaPengirim.value.text.toString(),
|
|
||||||
"url": "",
|
|
||||||
};
|
|
||||||
print(param);
|
|
||||||
ref
|
|
||||||
.read(insertTransaksiProvider.notifier)
|
|
||||||
.insertTransaksi(
|
|
||||||
formattedDateTransaksi,
|
|
||||||
selectedListTypeData.value.typeid.toString(),
|
|
||||||
selectedListCategory.value.categoryid
|
|
||||||
.toString(),
|
|
||||||
ctrlJumlah.value.text.toString(),
|
|
||||||
ctrlCatatan.value.text.toString(),
|
|
||||||
// "1",
|
|
||||||
userIDLogin,
|
|
||||||
ctrlNamaPengirim.value.text.toString(),
|
|
||||||
"",
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ class TransaksiSelectKategoriWidget extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.listCategoryData,
|
required this.listCategoryData,
|
||||||
required this.selectedListCategory,
|
required this.selectedListCategory,
|
||||||
|
required this.isLoading,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ValueNotifier<List<ListCategory>> listCategoryData;
|
final ValueNotifier<List<ListCategory>> listCategoryData;
|
||||||
final ValueNotifier<ListCategory> selectedListCategory;
|
final ValueNotifier<ListCategory> selectedListCategory;
|
||||||
|
final ValueNotifier<bool> isLoading;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -45,12 +47,14 @@ class TransaksiSelectKategoriWidget extends StatelessWidget {
|
|||||||
style: Constant.body1(context: context)
|
style: Constant.body1(context: context)
|
||||||
.copyWith(color: Constant.textBlack, fontWeight: FontWeight.w400),
|
.copyWith(color: Constant.textBlack, fontWeight: FontWeight.w400),
|
||||||
value: selectedListCategory.value,
|
value: selectedListCategory.value,
|
||||||
onChanged: (ListCategory? newValue) {
|
onChanged: !isLoading.value
|
||||||
// if (newValue) {
|
? (ListCategory? newValue) {
|
||||||
selectedListCategory.value = newValue!;
|
// if (newValue) {
|
||||||
print(selectedListCategory.value.categoryid);
|
selectedListCategory.value = newValue!;
|
||||||
// }
|
print(selectedListCategory.value.categoryid);
|
||||||
},
|
// }
|
||||||
|
}
|
||||||
|
: null,
|
||||||
buttonStyleData: ButtonStyleData(
|
buttonStyleData: ButtonStyleData(
|
||||||
height: Constant.getActualY(context: context, y: 80),
|
height: Constant.getActualY(context: context, y: 80),
|
||||||
width: Constant.getActualX(context: context, x: 320),
|
width: Constant.getActualX(context: context, x: 320),
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ class TransaksiUploadAreaWidget extends StatelessWidget {
|
|||||||
required this.fileDataBase64,
|
required this.fileDataBase64,
|
||||||
required this.pickFile,
|
required this.pickFile,
|
||||||
required this.pickImage,
|
required this.pickImage,
|
||||||
|
required this.isLoading,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ValueNotifier<bool> isImage;
|
final ValueNotifier<bool> isImage;
|
||||||
|
final ValueNotifier<bool> isLoading;
|
||||||
final ValueNotifier<XFile?> fileData;
|
final ValueNotifier<XFile?> fileData;
|
||||||
final ValueNotifier<String> fileDataBase64;
|
final ValueNotifier<String> fileDataBase64;
|
||||||
final Function pickImage;
|
final Function pickImage;
|
||||||
@@ -24,60 +26,63 @@ class TransaksiUploadAreaWidget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: !isLoading.value
|
||||||
print("tapped");
|
? () {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: Constant.getActualY(context: context, y: 200),
|
height: Constant.getActualY(context: context, y: 200),
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
pickFile();
|
pickFile();
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.folder_copy_rounded,
|
Icons.folder_copy_rounded,
|
||||||
size: 50,
|
size: 50,
|
||||||
color: Constant.pcBtnBackgroundColor,
|
color: Constant.pcBtnBackgroundColor,
|
||||||
)),
|
)),
|
||||||
Text("Browse a file",
|
Text("Browse a file",
|
||||||
style: Constant.body1(context: context).copyWith(
|
style: Constant.body1(context: context)
|
||||||
fontWeight: FontWeight.w600,
|
.copyWith(
|
||||||
color: Constant.textBlack))
|
fontWeight: FontWeight.w600,
|
||||||
],
|
color: Constant.textBlack))
|
||||||
),
|
],
|
||||||
Column(
|
),
|
||||||
children: [
|
Column(
|
||||||
IconButton(
|
children: [
|
||||||
onPressed: () {
|
IconButton(
|
||||||
Navigator.pop(context);
|
onPressed: () {
|
||||||
pickImage();
|
Navigator.pop(context);
|
||||||
},
|
pickImage();
|
||||||
icon: Icon(
|
},
|
||||||
Icons.add_a_photo_rounded,
|
icon: Icon(
|
||||||
size: 50,
|
Icons.add_a_photo_rounded,
|
||||||
color: Constant.pcBtnBackgroundColor,
|
size: 50,
|
||||||
)),
|
color: Constant.pcBtnBackgroundColor,
|
||||||
Text("Take a picture",
|
)),
|
||||||
style: Constant.body1(context: context).copyWith(
|
Text("Take a picture",
|
||||||
fontWeight: FontWeight.w600,
|
style: Constant.body1(context: context)
|
||||||
color: Constant.textBlack))
|
.copyWith(
|
||||||
],
|
fontWeight: FontWeight.w600,
|
||||||
),
|
color: Constant.textBlack))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
},
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: AlignmentDirectional.topEnd,
|
alignment: AlignmentDirectional.topEnd,
|
||||||
children: [
|
children: [
|
||||||
@@ -147,7 +152,7 @@ class TransaksiUploadAreaWidget extends StatelessWidget {
|
|||||||
)));
|
)));
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
if (fileData.value != null)
|
if (fileData.value != null && !isLoading.value)
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
fileData.value = null;
|
fileData.value = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user