Fakultas Ilmu Komputer UI

Commit 40d57c81 authored by Ardian Ghifari's avatar Ardian Ghifari
Browse files

[GREEN] Add shimmer loading effect to detail_post.dart

parent 767f09ee
......@@ -24,6 +24,7 @@ import 'package:bisaGo/page/login/login.dart';
import 'package:bisaGo/page/profile/profile.dart';
import 'package:share/share.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart';
class DetailPostPage extends StatefulWidget {
final Lokasi lokasi;
......@@ -47,6 +48,7 @@ class _DetailPostPageState extends State<DetailPostPage> {
int dislike;
int alreadyLikeFlag;
int alreadyDislikeFlag;
bool _enabled = true;
@override
void initState() {
......@@ -299,14 +301,17 @@ class _DetailPostPageState extends State<DetailPostPage> {
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: _buildMockKomentarPostingWidget())
]);
break;
case Status.completed:
_enabled = false;
allKomentarPostingFromApi =
snapshot.data.data.allKomentar;
if (allKomentarPostingFromApi.isEmpty) {
......@@ -328,6 +333,7 @@ class _DetailPostPageState extends State<DetailPostPage> {
}
break;
case Status.error:
_enabled = false;
return Center(
child: Text(snapshot.data.data.toString()),
);
......@@ -598,6 +604,25 @@ class _DetailPostPageState extends State<DetailPostPage> {
Navigator.of(context).push(route);
}
Widget _buildMockKomentarPostingWidget() {
final k = KomentarPostingModel.fromJson({
'id': 119,
'creator': 'Ardian Ghifari',
'created': '12-12-2021 06:30:00',
'deskripsi': 'loremipsum ipsmum',
'creatorEmail': 'ardianghi@gmail.com',
'creatorPicture': 'static/img/2669211407.jpg',
});
return Container(
child: komentarPlaceHolder(
k.creator,
k.created,
k.deskripsi,
k.creatorEmail,
k.creatorPicture,
));
}
@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