Fakultas Ilmu Komputer UI

Commit 8a10282c authored by Ardian Ghifari's avatar Ardian Ghifari
Browse files

[GREEN] Add shimmer loading effect to riwayat_pencarian.dart

parent fb63469f
......@@ -7,6 +7,7 @@ import 'package:bisaGo/config/styles.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/network/data/network_model.dart';
import 'package:bisaGo/page/filter_fasilitas/fasilitas.dart';
import 'package:shimmer/shimmer.dart';
/// Create Riwayat Pencarian page widget with a state
class RiwayatPencarian extends StatefulWidget {
......@@ -20,6 +21,7 @@ class RiwayatPencarian extends StatefulWidget {
class _RiwayatPencarianState extends State<RiwayatPencarian> {
/// List for places from API
List<Lokasi> places = [];
var _enabled = true;
/// BLoC for pencarian
LokasiResponseBloc bloc = LokasiResponseBloc();
......@@ -55,13 +57,11 @@ class _RiwayatPencarianState extends State<RiwayatPencarian> {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
return const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(greenPrimary),
),
);
_enabled = true;
_buildMockHistoryWidget();
break;
case Status.completed:
_enabled = false;
final recentSearch = snapshot.data.data;
Widget displayWidget;
if (recentSearch.listLokasi.isEmpty) {
......@@ -74,6 +74,7 @@ class _RiwayatPencarianState extends State<RiwayatPencarian> {
return displayWidget;
break;
case Status.error:
_enabled = false;
return Center(
child: Text('${snapshot.data.status}'),
);
......@@ -167,6 +168,27 @@ class _RiwayatPencarianState extends State<RiwayatPencarian> {
);
}
Widget _buildMockHistoryWidget() {
final mockLokasi = [
Lokasi.fromJson({
'id': 3,
'name': 'Coolidge',
'latitude': -23.7169139,
'longitude': -46.8498038,
'alamat': '74809 Hooker Drive',
'image': 'static/img/2669211407.jpg',
'telepon': '+55 956 836 5799',
'counter': 69,
})
];
return Container(
child: Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
enabled: _enabled,
child: makeHistoryWidget(mockLokasi)));
}
@override
void dispose() {
bloc.dispose();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment