Browse Source

perbaikan bug list peti, penambahan refresh page home

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

43
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(),
warehouseListAPI(),
typePetiListAPI(),
@ -90,15 +98,14 @@ class _HomePageState extends State<HomePage> {
datatablesCustomerList(),
datatablesWarehouseList(),
initializeDateFormatting('id_ID', null),
]).then((_) {
]);
// Mengatur _isLoading ke false setelah semua tugas selesai
if (mounted) {
setState(() {
_isLoading = false;
});
}
});
_data = <AssetStatusModel>[];
}
@override
@ -895,7 +902,12 @@ class _HomePageState extends State<HomePage> {
);
}
return AbsorbPointer(
return WillPopScope(
onWillPop: () async {
// Mencegah kembali ke halaman sebelumnya
return false;
},
child: AbsorbPointer(
absorbing: _isFetchingData,
child: Scaffold(
backgroundColor: Colors.grey[200],
@ -928,7 +940,24 @@ class _HomePageState extends State<HomePage> {
],
),
),
body: ListView(
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: [
cardMenuSync(),
SizedBox(height: 10),
@ -968,6 +997,8 @@ class _HomePageState extends State<HomePage> {
],
),
),
),
),
);
}
}

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

@ -414,7 +414,6 @@ class _CreateFinishPeminjamanState extends State<CreateFinishPeminjaman> {
color: Colors.grey[100],
),
padding: EdgeInsets.all(8),
child: Expanded(
child: ListView.builder(
itemCount: widget.temporaryDataList.length,
itemBuilder: (context, index) {
@ -467,7 +466,6 @@ class _CreateFinishPeminjamanState extends State<CreateFinishPeminjaman> {
},
),
),
),
SizedBox(height: 16),
Container(
child: Column(

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

@ -397,7 +397,6 @@ class _EditFinishPengembalianState extends State<EditFinishPengembalian> {
color: Colors.grey[100],
),
padding: EdgeInsets.all(8),
child: Expanded(
child: ListView.builder(
itemCount: widget.temporaryDataList.length,
itemBuilder: (context, index) {
@ -450,7 +449,6 @@ class _EditFinishPengembalianState extends State<EditFinishPengembalian> {
},
),
),
),
SizedBox(height: 16),
Container(
child: Column(

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

@ -415,7 +415,6 @@ class _EditFinishTransferPetiState extends State<EditFinishTransferPeti> {
color: Colors.grey[100],
),
padding: EdgeInsets.all(8),
child: Expanded(
child: ListView.builder(
itemCount: widget.temporaryDataList.length,
itemBuilder: (context, index) {
@ -468,7 +467,6 @@ class _EditFinishTransferPetiState extends State<EditFinishTransferPeti> {
},
),
),
),
SizedBox(height: 16),
Container(
child: Column(

8
lib/pages/transfer_peti/index.dart

@ -249,7 +249,12 @@ class TransferPetiPageState extends State<TransferPetiPage> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
return WillPopScope(
onWillPop: () async {
// Mencegah kembali ke halaman sebelumnya
return false;
},
child: DefaultTabController(
length: 1,
child: Scaffold(
appBar: appBar(context),
@ -271,6 +276,7 @@ class TransferPetiPageState extends State<TransferPetiPage> {
: bodyTransferPeti(),
bottomNavigationBar: bottomAppBar(context),
),
),
);
}

Loading…
Cancel
Save