Fakultas Ilmu Komputer UI

Commit 767f09ee authored by Ardian Ghifari's avatar Ardian Ghifari
Browse files

[GREEN] Add shimmer loading effect to fasilitas.dart

parent a531703a
......@@ -15,6 +15,7 @@ import 'package:bisaGo/page/filter_fasilitas/komentar.dart';
import 'package:bisaGo/model/komentar.dart';
import 'package:bisaGo/page/login/login.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart';
import 'kegiatan.dart';
......@@ -29,8 +30,8 @@ class Fasilitas extends StatefulWidget {
_FasilitasState createState() => _FasilitasState();
}
class _FasilitasState extends State<Fasilitas>
with AutomaticKeepAliveClientMixin<Fasilitas> {
class _FasilitasState extends State<Fasilitas>
with AutomaticKeepAliveClientMixin<Fasilitas> {
var kursiRodaVal = true;
var liftVal = true;
var toiletDisabilitasVal = true;
......@@ -46,11 +47,21 @@ class _FasilitasState extends State<Fasilitas>
var runningTextVal = true;
var sortKomentar = -1;
var showUrutan = true;
var _enabled = true;
List<KegiatanModel> allKegiatanFromApi;
List<KomentarModel> allKomentarFromApi;
KegiatanBloc _kegiatanBloc;
KomentarBloc _komentarBloc;
LokasiResponseBloc _lokasiBloc;
final mockLokasi = Lokasi.fromJson({
'placeId': 'lKHBIUnKLJnKjnKLN',
'name': 'Margo City',
'alamat':
'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'static/img/2669211407.jpg',
'no_telp': '02178870888',
'counter': 69,
});
@override
void initState() {
......@@ -279,16 +290,18 @@ class _FasilitasState extends State<Fasilitas>
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
return const Center(
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(
greenPrimary),
),
);
_enabled = true;
return Column(children: [
Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
enabled: _enabled,
child: _buildMockKomentarWidget())
]);
break;
case Status.completed:
_enabled = false;
allKomentarFromApi =
snapshot.data.data.allKomentar;
if (allKomentarFromApi.isEmpty) {
......@@ -305,6 +318,7 @@ class _FasilitasState extends State<Fasilitas>
break;
case Status.error:
_enabled = false;
return const Center(
child: Text('Belum ada informasi'),
);
......@@ -403,16 +417,18 @@ class _FasilitasState extends State<Fasilitas>
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
return const Center(
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(
greenPrimary),
),
);
_enabled = true;
return Column(children: [
Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
enabled: _enabled,
child: _buildMockKegiatanWidget())
]);
break;
case Status.completed:
_enabled = false;
allKegiatanFromApi =
snapshot.data.data.allKegiatan;
if (allKegiatanFromApi.isEmpty) {
......@@ -429,6 +445,7 @@ class _FasilitasState extends State<Fasilitas>
break;
case Status.error:
_enabled = false;
return const Center(
child: Text('Belum ada informasi'),
);
......@@ -508,7 +525,43 @@ class _FasilitasState extends State<Fasilitas>
await _lokasiBloc.postSearchHistory(widget.lokasi.placeId, token);
}
}
Widget _buildMockKomentarWidget() {
final mockKomentar = KomentarModel.fromJson({
'id': 119,
'nama_lokasi': 'Margo City',
'deskripsi': 'loremipsum ipsmum',
'creator': 'Ardian Ghifari',
'email': 'ardianghi@gmail.com',
'date_time': '12-11-2020 02:56:49',
'tag': 'JI',
'disabilitas': ['DS'],
'image': 'static/img/2669211407.jpg',
'is_verified': false,
'jumlah': 2,
'rating': 5
});
return Container(
child: Komentar(lokasi: mockLokasi, komentar: mockKomentar));
}
Widget _buildMockKegiatanWidget() {
final mockKegiatan = KegiatanModel.fromJson({
'id': 1,
'place_id': 'asdfghjkl',
'creator': 'Jovi',
'nama_kegiatan': 'Jalan Sehat',
'penyelenggara': 'Gubernur',
'narahubung': 'Rafif (0880123456123456)',
'deskripsi': 'Jalan sehat keliling kota',
'time_start': '2021-05-15 06:00:00',
'time_end': '2021-05-15 10:00:00',
'image': ['a', 'b', 'c'],
});
return Container(
child: Kegiatan(lokasi: mockLokasi, kegiatan: mockKegiatan));
}
@override
bool get wantKeepAlive => true;
}
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