Fakultas Ilmu Komputer UI

Commit 02b099bd authored by Ardian Ghifari's avatar Ardian Ghifari
Browse files

Merge branch 'dev-ardian' into 'PBI-15-redesign_menu'

Add shimmer loading effect

See merge request !77
parents 828e3da4 0ec4b120
Pipeline #82078 failed with stages
in 10 minutes and 48 seconds
This diff is collapsed.
......@@ -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,7 +30,8 @@ class Fasilitas extends StatefulWidget {
_FasilitasState createState() => _FasilitasState();
}
class _FasilitasState extends State<Fasilitas> {
class _FasilitasState extends State<Fasilitas>
with AutomaticKeepAliveClientMixin<Fasilitas> {
var kursiRodaVal = true;
var liftVal = true;
var toiletDisabilitasVal = true;
......@@ -45,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() {
......@@ -64,6 +76,7 @@ class _FasilitasState extends State<Fasilitas> {
@override
Widget build(BuildContext context) {
super.build(context);
return DefaultTabController(
length: 2,
child: Scaffold(
......@@ -277,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) {
......@@ -303,6 +318,7 @@ class _FasilitasState extends State<Fasilitas> {
break;
case Status.error:
_enabled = false;
return const Center(
child: Text('Belum ada informasi'),
);
......@@ -401,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) {
......@@ -427,6 +445,7 @@ class _FasilitasState extends State<Fasilitas> {
break;
case Status.error:
_enabled = false;
return const Center(
child: Text('Belum ada informasi'),
);
......@@ -506,4 +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;
}
......@@ -4,7 +4,6 @@ import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/page/filter_fasilitas/postingan/detail_post_kegiatan.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
// import 'package:bisaGo/component/image_holder.dart';
class Kegiatan extends StatefulWidget {
final Lokasi lokasi;
......@@ -17,6 +16,7 @@ class Kegiatan extends StatefulWidget {
}
class _KegiatanState extends State<Kegiatan> {
@override
Widget build(BuildContext context) {
return InkWell(
......@@ -29,16 +29,20 @@ class _KegiatanState extends State<Kegiatan> {
id: widget.kegiatan.id,
placeId: widget.kegiatan.placeId,
creator: widget.kegiatan.creator,
creatorEmail: widget.kegiatan.creatorEmail,
namaKegiatan: widget.kegiatan.namaKegiatan,
penyelenggara: widget.kegiatan.penyelenggara,
narahubung: widget.kegiatan.narahubung,
deskripsi: widget.kegiatan.deskripsi,
namaKontak: widget.kegiatan.namaKontak,
nomorKontak: widget.kegiatan.nomorKontak,
links: widget.kegiatan.links,
timeStart: widget.kegiatan.timeStart,
timeEnd: widget.kegiatan.timeEnd,
image: widget.kegiatan.image,
creatorEmail: widget.kegiatan.creatorEmail,
zonaWaktu: widget.kegiatan.zonaWaktu,
images: widget.kegiatan.images,
),
)));
)
));
},
child: Container(
margin: const EdgeInsets.only(bottom: regularSpace),
......@@ -58,7 +62,8 @@ class _KegiatanState extends State<Kegiatan> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
Flexible(
child: Text(
widget.kegiatan.namaKegiatan,
style: const TextStyle(
fontSize: 16,
......@@ -67,6 +72,7 @@ class _KegiatanState extends State<Kegiatan> {
fontFamily: 'Muli',
),
),
),
],
),
),
......@@ -83,17 +89,13 @@ class _KegiatanState extends State<Kegiatan> {
initialPage: 0,
autoPlay: true,
),
items: widget.kegiatan.image
.map((item) => Container(
items: widget.kegiatan.images.map((item) => Container(
child: Container(
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(20)),
borderRadius: BorderRadius.all(Radius.circular(20)),
child: Stack(
children: <Widget>[
Image.network(item,
fit: BoxFit.cover,
width: 1000.0),
Image.network(item, fit: BoxFit.cover, width: 1000.0),
Positioned(
bottom: 0.0,
left: 0.0,
......@@ -102,37 +104,32 @@ class _KegiatanState extends State<Kegiatan> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(
200, 0, 0, 0),
Color.fromARGB(
0, 0, 0, 0)
Color.fromARGB(200, 0, 0, 0),
Color.fromARGB(0, 0, 0, 0)
],
begin: Alignment
.bottomCenter,
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
),
),
padding: EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 20.0),
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
child: Text(
'#${widget.kegiatan.image.indexOf(item) + 1}',
'#${widget.kegiatan.images.indexOf(item)+1}',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight:
FontWeight.bold,
fontWeight: FontWeight.bold,
),
),
),
),
],
)),
)
),
),
)).toList(),
),
))
.toList(),
)
),
)),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
......
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
class KegiatanImageView extends StatefulWidget {
final String url;
KegiatanImageView(this.url);
@override
_KegiatanImageView createState() => _KegiatanImageView(url);
}
class _KegiatanImageView extends State<KegiatanImageView> {
final String url;
_KegiatanImageView(this.url);
@override
Widget build(BuildContext context) {
return Scaffold(
body: PhotoView(
imageProvider: NetworkImage(url),
)
);
}
}
\ No newline at end of file
import 'package:bisaGo/component/bisago_appbar.dart';
import 'package:bisaGo/page/filter_fasilitas/kegiatan_image_view.dart';
import 'package:flutter/material.dart';
class KegiatanListImages extends StatefulWidget {
final List<String> urls;
final String namaKegiatan;
KegiatanListImages(this.urls, this.namaKegiatan);
@override
_KegiatanListImages createState() => _KegiatanListImages(urls, namaKegiatan);
}
class _KegiatanListImages extends State<KegiatanListImages> {
List<String> urls;
String namaKegiatan;
_KegiatanListImages(this.urls, this.namaKegiatan);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: BisaGoAppBar(
title: namaKegiatan,
),
body: Container(
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 2.0),
child: GridView.count(
crossAxisCount: 2,
padding: EdgeInsets.all(3.0),
children: urls.map<Widget>((url) => renderImage(url)).toList(),
),
),
);
}
Card renderImage(String imageUrl) {
return Card(
elevation: 1.0,
margin: EdgeInsets.all(5.0),
child: Container(
child: InkWell(
onTap: () {
Navigator.push<Widget>(
context,
MaterialPageRoute(
builder: (context) => KegiatanImageView(imageUrl),
),
);
},
child: Image.network(imageUrl, fit: BoxFit.cover),
),
)
);
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ import 'package:bisaGo/network/data/network_model.dart';
import 'package:bisaGo/page/login/login.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;
......@@ -46,6 +47,7 @@ class _DetailPostPageState extends State<DetailPostPage> {
int dislike;
int alreadyLikeFlag;
int alreadyDislikeFlag;
bool _enabled = true;
@override
void initState() {
......@@ -298,14 +300,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) {
......@@ -327,6 +332,7 @@ class _DetailPostPageState extends State<DetailPostPage> {
}
break;
case Status.error:
_enabled = false;
return Center(
child: Text(snapshot.data.data.toString()),
);
......@@ -592,6 +598,30 @@ class _DetailPostPageState extends State<DetailPostPage> {
}
}
// void _navigateToProfilePage(BuildContext context, String email) {
// var route = MaterialPageRoute(builder: (_) => Profile(email: email));
// 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();
......
This diff is collapsed.
......@@ -8,6 +8,7 @@ import 'package:bisaGo/page/informasi/detail_komunitas.dart';
import 'package:bisaGo/page/informasi/detail_sekolah.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:shimmer/shimmer.dart';
class ListSekolah extends StatefulWidget {
const ListSekolah({Key key}) : super(key: key);
......@@ -17,11 +18,21 @@ class ListSekolah extends StatefulWidget {
}
class _ListSekolahState extends State<ListSekolah> {
/// Search Icon for textFormField
Icon searchIcon = const Icon(Icons.search);
LayananBloc layanan_bloc = LayananBloc();
bool _enabled = true;
final mockSekolah = SekolahModel.fromJson({
'name': 'SMA Tanjung Barat',
'alamat': 'Kecamatan Tanjung Barat',
'no_telp': '0213425367',
'website': 'www.tanjungbarat.co.id',
'jumlah_siswa': 200,
'status': 'IT',
'jenis_sekolah': 'IK',
'akreditasi': 'A',
});
@override
Widget build(BuildContext context) {
......@@ -94,14 +105,17 @@ class _ListSekolahState extends State<ListSekolah> {
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: makeSekolahWidget('sekolah', mockSekolah))
]);
break;
case Status.completed:
_enabled = false;
var layanan = snapshot.data.data;
return Column(
children: layanan.map<Widget>((each) {
......@@ -116,6 +130,7 @@ class _ListSekolahState extends State<ListSekolah> {
);
break;
case Status.error:
_enabled = false;
return Center(
child: Text(snapshot.data.data.toString()),
);
......
......@@ -273,6 +273,7 @@ class LoginState extends State<Login> {
});
successDialog(context);
await Future.delayed(const Duration(seconds: 2));
_navigateToDashboard(context);
if (updateUser.disabilitas == '-') {
updateUser.disabilitas = 'Tidak memiliki disabilitas';
......
......@@ -8,6 +8,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 Pencarian page widget with a state
class Pencarian extends StatefulWidget {
......@@ -37,6 +38,21 @@ class PencarianState extends State<Pencarian> {
/// BLoC for pencarian
LokasiResponseBloc bloc = LokasiResponseBloc();
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,
})
];
bool _enabled = true;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
......@@ -131,13 +147,11 @@ class PencarianState extends State<Pencarian> {
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) {
......@@ -150,6 +164,7 @@ class PencarianState extends State<Pencarian> {
return displayWidget;
break;
case Status.error:
_enabled = false;
return Center(
child: Text('${snapshot.data.status}'),
);
......@@ -174,14 +189,11 @@ class PencarianState extends State<Pencarian> {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
return const Center(
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(greenPrimary),
),
);
_enabled = true;
_buildMockLokasiWidget();
break;
case Status.completed:
_enabled = false;
places = snapshot.data.data.listLokasi;
return snapshot.data.data.listLokasi.isEmpty
? Center(
......@@ -197,9 +209,9 @@ class PencarianState extends State<Pencarian> {
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
greenPrimary)
),
backgroundColor:
MaterialStateProperty.all(
greenPrimary)),
onPressed: () {