first commit
This commit is contained in:
241
lib/pages/riwayat/component/item-history.dart
Normal file
241
lib/pages/riwayat/component/item-history.dart
Normal file
@@ -0,0 +1,241 @@
|
||||
import 'package:bbm_tracking/model/bensin_m.dart';
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/pages/home.dart';
|
||||
import 'package:bbm_tracking/pages/riwayat/riwayat-detail/riwayat-detail.dart';
|
||||
import 'package:bbm_tracking/resource/resource.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ItemHistory extends StatefulWidget {
|
||||
TransaksiModel data;
|
||||
KendaraanModel kendaraan;
|
||||
ItemHistory({super.key, required this.data, required this.kendaraan});
|
||||
|
||||
@override
|
||||
State<ItemHistory> createState() => _ItemHistoryState();
|
||||
}
|
||||
|
||||
class _ItemHistoryState extends State<ItemHistory> {
|
||||
TransaksiModel? data;
|
||||
List<BensinModel> dataBensin = listBensin;
|
||||
KendaraanModel? kendaraan;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
data = widget.data;
|
||||
kendaraan = widget.kendaraan;
|
||||
}
|
||||
|
||||
String reformatDate(DateTime date) {
|
||||
String data = "";
|
||||
for (int i = 0; i < bulan.length; i++) {
|
||||
if (i + 1 == date.month) {
|
||||
data += "${bulan[i].substring(0, 3)}, ${date.day} ${date.year}";
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RiwayatDetail(
|
||||
data: data!,
|
||||
key: UniqueKey(),
|
||||
kendaraan: kendaraan!,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 1, color: Color(0xFF677D81)),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(color: Color(0xFFE1E1E1)),
|
||||
height: 42,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
top: 5,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Pengisian",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 11,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
dataBensin[int.parse(data!.bensinId) - 1]
|
||||
.text
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 10,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(
|
||||
"Data : ${reformatDate(data!.tanggalTransaksi)}",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 10,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Image.asset(
|
||||
"assets/images/${dataBensin[int.parse(data!.bensinId) - 1].perusahaan.toLowerCase()}.png"),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.all(5),
|
||||
padding: EdgeInsets.only(top: 6),
|
||||
width: 50,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
color: data?.status == 1
|
||||
? Color(0xFF58D68D)
|
||||
: Color(0XFFFC8D05),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
// alignment: Alignment.topRight,
|
||||
child: Text(
|
||||
data?.status == 1 ? "selesai" : "draft",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 35,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
top: 5,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Total Harga:",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
CurrencyFormat.convertToIdr(data?.totalBayar, 0),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
top: 5,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Lokasi SPBU:",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${data?.lokasiPertamina}",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF3B3C48),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
413
lib/pages/riwayat/component/makePdf.dart
Normal file
413
lib/pages/riwayat/component/makePdf.dart
Normal file
@@ -0,0 +1,413 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:bbm_tracking/model/kendaraan_m.dart';
|
||||
import 'package:bbm_tracking/model/photo_m.dart';
|
||||
import 'package:bbm_tracking/model/transaksi_m.dart';
|
||||
import 'package:bbm_tracking/repository/transaksi/transaksi_repository.dart';
|
||||
import 'package:bbm_tracking/resource/convert_money/convert_money.dart';
|
||||
import 'package:bbm_tracking/resource/data-bensin/data-bensin.dart';
|
||||
import 'package:bbm_tracking/resource/data-tanggal/bulan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
import 'package:printing/printing.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class MakePdf extends StatelessWidget {
|
||||
TransaksiModel transaksi;
|
||||
KendaraanModel kendaraan;
|
||||
MakePdf({super.key, required this.transaksi, required this.kendaraan});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("PDF Preview"),
|
||||
),
|
||||
body: PdfPreview(
|
||||
build: (context) => makePdf(transaksi, kendaraan),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<PhotoModel> photos = [];
|
||||
List<Uint8List> imagesUint8list = [];
|
||||
List<pw.Widget> pdfImagesWidget = [];
|
||||
|
||||
Future<List<PhotoModel>> loadPhoto(param) async {
|
||||
List<PhotoModel> photo = await TransaksiRepository().getPhoto(param);
|
||||
return photo;
|
||||
}
|
||||
|
||||
String reformatDate(DateTime date) {
|
||||
String data = "";
|
||||
for (int i = 0; i < bulan.length; i++) {
|
||||
if (i + 1 == date.month) {
|
||||
data += "${date.day} ${bulan[i]} ${date.year}";
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Future<Uint8List> makePdf(
|
||||
TransaksiModel transaksi,
|
||||
KendaraanModel kendaraan,
|
||||
) async {
|
||||
final pdf = pw.Document();
|
||||
photos = await loadPhoto(transaksi.kodeTransaksi);
|
||||
|
||||
photos.forEach((element) async {
|
||||
var replace = "/storage/emulated/0/Pictures/" +
|
||||
element.namePhoto.replaceAll(RegExp(':'), '_') +
|
||||
".jpg";
|
||||
Uri myUri = Uri.parse(replace);
|
||||
File imageFile = new File.fromUri(myUri);
|
||||
// final ByteData bytes = await imageFile.readAsBytes();
|
||||
final Uint8List byteList = imageFile.readAsBytesSync();
|
||||
|
||||
imagesUint8list.add(byteList);
|
||||
});
|
||||
|
||||
pdfImagesWidget = imagesUint8list.map(
|
||||
(image) {
|
||||
return pw.Padding(
|
||||
padding: pw.EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
||||
child: pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||
mainAxisSize: pw.MainAxisSize.max,
|
||||
children: [
|
||||
pw.SizedBox(height: 10),
|
||||
pw.Image(
|
||||
pw.MemoryImage(
|
||||
image,
|
||||
),
|
||||
height: 400,
|
||||
fit: pw.BoxFit.fitHeight),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
).toList();
|
||||
|
||||
|
||||
final fontData = await rootBundle.load("assets/fonts/Poppins-Medium.ttf");
|
||||
final ttf = pw.Font.ttf(fontData.buffer.asByteData());
|
||||
pdf.addPage(
|
||||
pw.Page(
|
||||
margin: pw.EdgeInsets.all(10),
|
||||
pageFormat: PdfPageFormat.a4,
|
||||
build: (context) {
|
||||
return pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.start,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Detail Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 16,
|
||||
color: PdfColor.fromInt(0xff3B3C48),
|
||||
),
|
||||
),
|
||||
pw.Divider(borderStyle: pw.BorderStyle.dashed),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Kode Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
transaksi.kodeTransaksi,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Divider(borderStyle: pw.BorderStyle.dashed),
|
||||
pw.Text(
|
||||
"Tipe Kendaraan",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 16,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
kendaraan.namaKendaraan,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
kendaraan.nomorPlat,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Divider(borderStyle: pw.BorderStyle.dashed),
|
||||
pw.Text(
|
||||
"Detail",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 16,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Padding(
|
||||
padding: pw.EdgeInsets.symmetric(horizontal: 50),
|
||||
child: pw.Column(
|
||||
children: [
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Center(
|
||||
child: pw.Text(
|
||||
"Tipe Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.Center(
|
||||
child: pw.Text(
|
||||
"Pengisian Bahan Bakar",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Align(
|
||||
alignment: pw.Alignment.topLeft,
|
||||
child: pw.Text(
|
||||
"Data Transaksi",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.Align(
|
||||
alignment: pw.Alignment.topRight,
|
||||
child: pw.Text(
|
||||
reformatDate(transaksi.tanggalTransaksi),
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Waktu",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${transaksi.tanggalTransaksi.hour}:${transaksi.tanggalTransaksi.minute} WIB",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Jenis Bahan Bakar",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
listBensin[int.parse(transaksi.bensinId) - 1].text,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Alamat SPBU",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
transaksi.lokasiPertamina,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Total Liter",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${transaksi.totalLiter} Liter",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Harga / Liter",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${CurrencyFormat.convertToIdr(listBensin[int.parse(transaksi.bensinId) - 1].harga, 0)}",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Total Pembayaran",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
CurrencyFormat.convertToIdr(transaksi.totalBayar, 0),
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Odometer",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
"${transaksi.odometer} KM",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
"Catatan",
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
pw.Text(
|
||||
transaksi.catatan,
|
||||
style: pw.TextStyle(
|
||||
font: ttf,
|
||||
fontSize: 13,
|
||||
color: PdfColor.fromInt(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||
mainAxisSize: pw.MainAxisSize.max,
|
||||
children: pdfImagesWidget,
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return pdf.save();
|
||||
}
|
||||
}
|
||||
138
lib/pages/riwayat/component/viewImage.dart
Normal file
138
lib/pages/riwayat/component/viewImage.dart
Normal file
@@ -0,0 +1,138 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class ViewImage extends StatefulWidget {
|
||||
final List<String> imagePath;
|
||||
const ViewImage({super.key, required this.imagePath});
|
||||
|
||||
@override
|
||||
State<ViewImage> createState() => _ViewImageState();
|
||||
}
|
||||
|
||||
class _ViewImageState extends State<ViewImage> {
|
||||
late List<String> dataPhoto;
|
||||
bool loading = false;
|
||||
// List<FileModel> _files = new List<FileModel>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
load();
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> load() async {
|
||||
dataPhoto = widget.imagePath;
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
}
|
||||
Future<bool> _onWillPop() async {
|
||||
Navigator.pop(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onWillPop(),
|
||||
child: Scaffold(
|
||||
backgroundColor: Color(0xffE3EAEA),
|
||||
body: loading
|
||||
? Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 50,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: BackButton(),
|
||||
margin: EdgeInsets.only(
|
||||
left: 10,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
child: Expanded(
|
||||
child: ListView.builder(
|
||||
// shrinkWrap: true,
|
||||
itemCount: dataPhoto.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var replace = "/storage/emulated/0/Pictures/" +
|
||||
dataPhoto[index].replaceAll(RegExp(':'), '_')+".jpg";
|
||||
print("counting ${dataPhoto.length.toString()}, path = ${replace}");
|
||||
return ScreenImage(
|
||||
replace,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget ScreenImage(param) {
|
||||
print("counting data ${param}");
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5,
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
color: Colors.amber),
|
||||
child: Image.file(
|
||||
File(param),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget BackButton() {
|
||||
return InkWell(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Container(
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
size: 15,
|
||||
),
|
||||
Text(
|
||||
"Kembali",
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Poppins',
|
||||
color: Color(0xff1A0F0F),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user