Browse Source

perbaikan bug list peti, penambahan refresh page home

master
unknown 1 year ago
parent
commit
9bd0b1a505
  1. 173
      lib/pages/home/home_page.dart
  2. 92
      lib/pages/peminjaman_barang/create-finish.dart
  3. 92
      lib/pages/pengembalian_barang/edit-finish.dart
  4. 92
      lib/pages/transfer_peti/edit-finish.dart
  5. 46
      lib/pages/transfer_peti/index.dart

173
lib/pages/home/home_page.dart

@ -78,7 +78,15 @@ class _HomePageState extends State<HomePage> {
}); });
} }
Future.wait([ // Memanggil _refreshPage untuk menginisialisasi dan memuat data
_refreshPage();
_data = <AssetStatusModel>[];
}
Future<void> _refreshPage() async {
// Menggunakan Future.wait untuk menunggu hasil dari semua tugas selesai
await Future.wait([
_initData(), _initData(),
warehouseListAPI(), warehouseListAPI(),
typePetiListAPI(), typePetiListAPI(),
@ -90,15 +98,14 @@ class _HomePageState extends State<HomePage> {
datatablesCustomerList(), datatablesCustomerList(),
datatablesWarehouseList(), datatablesWarehouseList(),
initializeDateFormatting('id_ID', null), initializeDateFormatting('id_ID', null),
]).then((_) { ]);
// Mengatur _isLoading ke false setelah semua tugas selesai
if (mounted) { // Mengatur _isLoading ke false setelah semua tugas selesai
setState(() { if (mounted) {
_isLoading = false; setState(() {
}); _isLoading = false;
} });
}); }
_data = <AssetStatusModel>[];
} }
@override @override
@ -895,77 +902,101 @@ class _HomePageState extends State<HomePage> {
); );
} }
return AbsorbPointer( return WillPopScope(
absorbing: _isFetchingData, onWillPop: () async {
child: Scaffold( // Mencegah kembali ke halaman sebelumnya
backgroundColor: Colors.grey[200], return false;
appBar: AppBar( },
elevation: 0, child: AbsorbPointer(
automaticallyImplyLeading: false, absorbing: _isFetchingData,
backgroundColor: Colors.indigo[700], child: Scaffold(
centerTitle: true, backgroundColor: Colors.grey[200],
title: Row( appBar: AppBar(
children: [ elevation: 0,
SizedBox(width: 10), automaticallyImplyLeading: false,
Expanded( backgroundColor: Colors.indigo[700],
child: Center( centerTitle: true,
child: Column( title: Row(
children: [
Text(
'SIOPAS-ISTW',
textAlign: TextAlign.center,
),
Text(
'${user.fullname}',
style: TextStyle(
fontSize: 10,
),
),
],
),
),
),
],
),
),
body: ListView(
children: [
cardMenuSync(),
SizedBox(height: 10),
Container(
padding: EdgeInsets.all(10),
child: Text(
'Menu Aplikasi',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
SizedBox(width: 10),
Expanded( Expanded(
child: cardMenuPeminjaman(), child: Center(
), child: Column(
Expanded( children: [
child: cardMenuPengembalian(), Text(
'SIOPAS-ISTW',
textAlign: TextAlign.center,
),
Text(
'${user.fullname}',
style: TextStyle(
fontSize: 10,
),
),
],
),
),
), ),
], ],
), ),
SizedBox(height: 10), // Add some space between rows ),
Row( body: RefreshIndicator(
color: Colors.white,
backgroundColor: Colors.indigo[700],
onRefresh: () async {
// Tampilkan Shimmer loading selama proses refresh
setState(() {
_isLoading = true;
});
// Selesaikan proses refresh
await _refreshPage();
// Sembunyikan Shimmer loading setelah selesai
setState(() {
_isLoading = false;
});
},
child: ListView(
children: [ children: [
Expanded( cardMenuSync(),
child: cardMenuTransfer(), SizedBox(height: 10),
Container(
padding: EdgeInsets.all(10),
child: Text(
'Menu Aplikasi',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
), ),
Expanded( Row(
child: Container(), mainAxisAlignment: MainAxisAlignment.spaceBetween,
// child: cardMenuPengembalian(), children: [
Expanded(
child: cardMenuPeminjaman(),
),
Expanded(
child: cardMenuPengembalian(),
),
],
),
SizedBox(height: 10), // Add some space between rows
Row(
children: [
Expanded(
child: cardMenuTransfer(),
),
Expanded(
child: Container(),
// child: cardMenuPengembalian(),
),
],
), ),
], ],
), ),
], ),
), ),
), ),
); );

92
lib/pages/peminjaman_barang/create-finish.dart

@ -414,58 +414,56 @@ class _CreateFinishPeminjamanState extends State<CreateFinishPeminjaman> {
color: Colors.grey[100], color: Colors.grey[100],
), ),
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: Expanded( child: ListView.builder(
child: ListView.builder( itemCount: widget.temporaryDataList.length,
itemCount: widget.temporaryDataList.length, itemBuilder: (context, index) {
itemBuilder: (context, index) { int? petiId =
int? petiId = widget.temporaryDataList[index].peti_id;
widget.temporaryDataList[index].peti_id; PetiAssetModel? petiSqfliteApi =
PetiAssetModel? petiSqfliteApi = _valpeti?.firstWhereOrNull(
_valpeti?.firstWhereOrNull( (peti) => peti.id == petiId,
(peti) => peti.id == petiId, );
);
return ConstrainedBox(
return ConstrainedBox( constraints: BoxConstraints(
constraints: BoxConstraints( maxHeight:
maxHeight: 100, // Set your desired height here
100, // Set your desired height here ),
), child: Card(
child: Card( elevation: 1,
elevation: 1, shape: RoundedRectangleBorder(
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(8), side: BorderSide(
side: BorderSide( color: Colors.grey.withOpacity(0.5),
color: Colors.grey.withOpacity(0.5), width: 1,
width: 1,
),
), ),
margin: EdgeInsets.symmetric(vertical: 4), ),
child: Padding( margin: EdgeInsets.symmetric(vertical: 4),
padding: const EdgeInsets.all(16.0), child: Padding(
child: SingleChildScrollView( padding: const EdgeInsets.all(16.0),
child: Row( child: SingleChildScrollView(
children: [ child: Row(
Text( children: [
'${index + 1}.', Text(
style: TextStyle( '${index + 1}.',
fontSize: 14, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 14,
), fontWeight: FontWeight.bold,
),
SizedBox(width: 16),
Text(
' ${petiSqfliteApi?.fix_lot ?? ''}',
style: TextStyle(fontSize: 13),
), ),
// Tambahkan properti lainnya sesuai kebutuhan ),
], SizedBox(width: 16),
), Text(
' ${petiSqfliteApi?.fix_lot ?? ''}',
style: TextStyle(fontSize: 13),
),
// Tambahkan properti lainnya sesuai kebutuhan
],
), ),
), ),
), ),
); ),
}, );
), },
), ),
), ),
SizedBox(height: 16), SizedBox(height: 16),

92
lib/pages/pengembalian_barang/edit-finish.dart

@ -397,58 +397,56 @@ class _EditFinishPengembalianState extends State<EditFinishPengembalian> {
color: Colors.grey[100], color: Colors.grey[100],
), ),
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: Expanded( child: ListView.builder(
child: ListView.builder( itemCount: widget.temporaryDataList.length,
itemCount: widget.temporaryDataList.length, itemBuilder: (context, index) {
itemBuilder: (context, index) { int? petiId =
int? petiId = widget.temporaryDataList[index].peti_id;
widget.temporaryDataList[index].peti_id; PetiAssetModel? petiSqfliteApi =
PetiAssetModel? petiSqfliteApi = _valpeti?.firstWhereOrNull(
_valpeti?.firstWhereOrNull( (peti) => peti.id == petiId,
(peti) => peti.id == petiId, );
);
return ConstrainedBox(
return ConstrainedBox( constraints: BoxConstraints(
constraints: BoxConstraints( maxHeight:
maxHeight: 100, // Set your desired height here
100, // Set your desired height here ),
), child: Card(
child: Card( elevation: 1,
elevation: 1, shape: RoundedRectangleBorder(
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(8), side: BorderSide(
side: BorderSide( color: Colors.grey.withOpacity(0.5),
color: Colors.grey.withOpacity(0.5), width: 1,
width: 1,
),
), ),
margin: EdgeInsets.symmetric(vertical: 4), ),
child: Padding( margin: EdgeInsets.symmetric(vertical: 4),
padding: const EdgeInsets.all(16.0), child: Padding(
child: SingleChildScrollView( padding: const EdgeInsets.all(16.0),
child: Row( child: SingleChildScrollView(
children: [ child: Row(
Text( children: [
'${index + 1}.', Text(
style: TextStyle( '${index + 1}.',
fontSize: 14, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 14,
), fontWeight: FontWeight.bold,
),
SizedBox(width: 16),
Text(
' ${petiSqfliteApi?.fix_lot ?? ''}',
style: TextStyle(fontSize: 13),
), ),
// Tambahkan properti lainnya sesuai kebutuhan ),
], SizedBox(width: 16),
), Text(
' ${petiSqfliteApi?.fix_lot ?? ''}',
style: TextStyle(fontSize: 13),
),
// Tambahkan properti lainnya sesuai kebutuhan
],
), ),
), ),
), ),
); ),
}, );
), },
), ),
), ),
SizedBox(height: 16), SizedBox(height: 16),

92
lib/pages/transfer_peti/edit-finish.dart

@ -415,58 +415,56 @@ class _EditFinishTransferPetiState extends State<EditFinishTransferPeti> {
color: Colors.grey[100], color: Colors.grey[100],
), ),
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: Expanded( child: ListView.builder(
child: ListView.builder( itemCount: widget.temporaryDataList.length,
itemCount: widget.temporaryDataList.length, itemBuilder: (context, index) {
itemBuilder: (context, index) { int? petiId =
int? petiId = widget.temporaryDataList[index].peti_id;
widget.temporaryDataList[index].peti_id; PetiAssetModel? petiSqfliteApi =
PetiAssetModel? petiSqfliteApi = _valpeti?.firstWhereOrNull(
_valpeti?.firstWhereOrNull( (peti) => peti.id == petiId,
(peti) => peti.id == petiId, );
);
return ConstrainedBox(
return ConstrainedBox( constraints: BoxConstraints(
constraints: BoxConstraints( maxHeight:
maxHeight: 100, // Set your desired height here
100, // Set your desired height here ),
), child: Card(
child: Card( elevation: 1,
elevation: 1, shape: RoundedRectangleBorder(
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(8), side: BorderSide(
side: BorderSide( color: Colors.grey.withOpacity(0.5),
color: Colors.grey.withOpacity(0.5), width: 1,
width: 1,
),
), ),
margin: EdgeInsets.symmetric(vertical: 4), ),
child: Padding( margin: EdgeInsets.symmetric(vertical: 4),
padding: const EdgeInsets.all(16.0), child: Padding(
child: SingleChildScrollView( padding: const EdgeInsets.all(16.0),
child: Row( child: SingleChildScrollView(
children: [ child: Row(
Text( children: [
'${index + 1}.', Text(
style: TextStyle( '${index + 1}.',
fontSize: 14, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 14,
), fontWeight: FontWeight.bold,
),
SizedBox(width: 16),
Text(
' ${petiSqfliteApi?.fix_lot ?? ''}',
style: TextStyle(fontSize: 13),
), ),
// Tambahkan properti lainnya sesuai kebutuhan ),
], SizedBox(width: 16),
), Text(
' ${petiSqfliteApi?.fix_lot ?? ''}',
style: TextStyle(fontSize: 13),
),
// Tambahkan properti lainnya sesuai kebutuhan
],
), ),
), ),
), ),
); ),
}, );
), },
), ),
), ),
SizedBox(height: 16), SizedBox(height: 16),

46
lib/pages/transfer_peti/index.dart

@ -249,27 +249,33 @@ class TransferPetiPageState extends State<TransferPetiPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DefaultTabController( return WillPopScope(
length: 1, onWillPop: () async {
child: Scaffold( // Mencegah kembali ke halaman sebelumnya
appBar: appBar(context), return false;
body: _isLoading },
? Column( child: DefaultTabController(
children: [ length: 1,
// shimmerSearch(), child: Scaffold(
Expanded( appBar: appBar(context),
child: ListView.builder( body: _isLoading
itemCount: ? Column(
4, // Set the number of shimmer cards based on your data count children: [
itemBuilder: (context, index) { // shimmerSearch(),
return ShimmerLoadingAssetStatusCard(); Expanded(
}, child: ListView.builder(
itemCount:
4, // Set the number of shimmer cards based on your data count
itemBuilder: (context, index) {
return ShimmerLoadingAssetStatusCard();
},
),
), ),
), ],
], )
) : bodyTransferPeti(),
: bodyTransferPeti(), bottomNavigationBar: bottomAppBar(context),
bottomNavigationBar: bottomAppBar(context), ),
), ),
); );
} }

Loading…
Cancel
Save