Fakultas Ilmu Komputer UI

Commit 92d38a6a authored by Ardian Ghifari's avatar Ardian Ghifari
Browse files

Merge branch 'PBI-15-redesign_menu' into 'development'

Pbi 15 redesign menu

See merge request !78
parents 025958f6 92273a80
Pipeline #82083 failed with stages
in 38 minutes and 3 seconds
3.5.1:
3.5.2:
- Tersedia nama dan foto profil pada drawer
- Pengguna dapat mengganti foto profil
- Pengguna dapat mengubah informasi kegiatan yang sudah ada
......
import 'dart:convert';
import 'package:bisaGo/model/user.dart';
import 'package:bisaGo/page/informasi/list_sekolah.dart';
import 'package:bisaGo/page/profile/profile.dart';
import 'package:bisaGo/page/tentang_disabilitas/tentang_disabilitas.dart';
import 'package:flutter/material.dart';
import 'package:bisaGo/config/styles.dart';
import 'package:bisaGo/page/login/login.dart';
import 'package:bisaGo/page/profile/profile_picture.dart';
import 'package:bisaGo/page/riwayat_pencarian/riwayat_pencarian.dart';
import 'package:bisaGo/page/aboutUs/about_us.dart';
import 'package:shared_preferences/shared_preferences.dart';
......@@ -14,7 +16,6 @@ class BisaGoDrawer extends StatelessWidget {
BisaGoDrawer({Key key}) : super(key: key);
final List<Map<String, dynamic>> drawerList = [
{'title': 'Profile', 'icon': Icons.person},
{'title': 'Beranda', 'icon': Icons.home},
{'title': 'Riwayat Pencarian', 'icon': Icons.history},
{'title': 'Layanan Disabilitas', 'icon': Icons.group},
......@@ -45,8 +46,68 @@ class BisaGoDrawer extends StatelessWidget {
future: changeNameDrawer(),
builder: (BuildContext context,
AsyncSnapshot<String> snapshot) {
if (snapshot.hasData) {
return Padding(
if (snapshot.hasData &&
snapshot.data != 'Selamat datang ke BisaGo!') {
return Container(
child: InkWell(
onTap: () {
_navigateToProfilePage(context, jsonDecode(snapshot.data)['email']);
},
child: ListView(
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
border: Border.all(color: Colors.white)
),
child: ProfilePicture(DetailUserModel.fromJson(jsonDecode(snapshot.data)),
radius: 30, fontSize: 25, previewAble: true),
),
Expanded(
child: Container(
padding: const EdgeInsets.all(doubleSpace),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
jsonDecode(snapshot.data)['name'].split(' ')[0],
style: TextStyle(
fontSize: 30,
color: Colors.white,
fontFamily: 'Muli',
fontWeight: FontWeight.w900,
),
overflow: TextOverflow.ellipsis,
),
Text(
'Lihat Profil',
style: TextStyle(
fontSize: 13,
color: Colors.white,
fontFamily: 'Muli',
fontWeight: FontWeight.w500,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
),
],
),
),
],
),
),
);
}
else if (snapshot.hasData &&
snapshot.data == 'Selamat datang ke BisaGo!') {
return Padding(
padding: EdgeInsets.all(smallSpace),
child: Text(
snapshot.data,
......@@ -60,7 +121,10 @@ class BisaGoDrawer extends StatelessWidget {
);
}
return Container();
}))),
}
)
)
),
],
),
),
......@@ -170,8 +234,9 @@ class BisaGoDrawer extends StatelessWidget {
if (sharedPreferences.getString('token') == null) {
return 'Selamat datang ke BisaGo!';
} else {
final userJson = jsonDecode(sharedPreferences.getString('user'));
return userJson['email'];
//final userJson = jsonDecode(sharedPreferences.getString('user'));
final userJson = sharedPreferences.getString('user');
return userJson;
}
}
......
import 'package:bisaGo/config/styles.dart';
import 'package:bisaGo/flavor/flavor.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
class ImageHolder extends StatelessWidget {
final String url;
......@@ -76,10 +76,12 @@ class ImageHolder extends StatelessWidget {
fit: BoxFit.cover,
)),
),
placeholder: (context, _) => const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(greenPrimary),
)),
placeholder: (context, _) => Container(
child: Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
enabled: true,
child: Container())),
errorWidget: (context, url, error) =>
const Center(child: Icon(Icons.broken_image, color: Colors.black38)),
);
......
......@@ -26,6 +26,7 @@ import 'package:bisaGo/config/styles.dart';
import 'package:bisaGo/page/pencarian/pencarian.dart';
import 'package:google_maps_webservice/places.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart';
import '../filter_fasilitas/postingan/detail_post.dart';
......@@ -41,6 +42,7 @@ class DashboardState extends State<Dashboard> {
Geolocator geolocator;
LatLng currentLocation;
Set<Marker> markers = {};
bool _enabled = true;
LokasiResponseBloc bloc = LokasiResponseBloc();
KegiatanTerdekatBloc blocKegiatanTerdekat = KegiatanTerdekatBloc();
......@@ -140,7 +142,7 @@ class DashboardState extends State<Dashboard> {
void _showTurnOnLocationDialog(BuildContext context) {
bloc.isLocationServiceTurnedOn().then(
(value) {
(value) {
if (!value) {
showDialog(
context: context,
......@@ -187,36 +189,35 @@ class DashboardState extends State<Dashboard> {
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: doubleSpace),
const EdgeInsets.symmetric(horizontal: doubleSpace),
child: StreamBuilder<NetworkModel>(
stream: blocKegiatanTerdekat.kegiatanTerdekatStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
_enabled = true;
return Container(
child: const Center(
child: LinearProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
)));
child: _buildMockKegiatanTerdekatWidget());
break;
case Status.completed:
_enabled = false;
final kegiatanTerdekat = snapshot.data.data;
return _buildKegiatanTerdekatWidget(
kegiatanTerdekat);
break;
case Status.error:
_enabled = false;
return Container(
child: const Center(
child: Text(
'Tidak ada kegiatan dalam waktu dekat',
style: TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)),
));
child: Text(
'Tidak ada kegiatan dalam waktu dekat',
style: TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)),
));
break;
}
return Container();
......@@ -286,21 +287,17 @@ class DashboardState extends State<Dashboard> {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.loading:
_enabled = true;
return Container(
height: 130,
child: const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
),
),
);
height: 130, child: _buildMockLokasiWidget());
break;
case Status.completed:
_enabled = false;
final places = snapshot.data.data.listLokasi;
return _buildLokasiWidget(places);
break;
case Status.error:
_enabled = false;
return Container(
height: 130,
child: const Center(
......@@ -346,8 +343,56 @@ class DashboardState extends State<Dashboard> {
Row(
children: lokasilistresponse
.map<Widget>((k) => LocationIconButton(
location: k,
))
location: k,
))
.toList()),
],
),
);
}
Widget _buildMockLokasiWidget() {
final mockLokasi = [
Lokasi.fromJson({
'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,
}),
Lokasi.fromJson({
'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,
}),
Lokasi.fromJson({
'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,
}),
];
return Container(
key: Key('Shimmer loading'),
height: 130,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
Row(
children: mockLokasi
.map<Widget>((k) => Shimmer.fromColors(
baseColor: Colors.grey[300],
highlightColor: Colors.grey[100],
enabled: _enabled,
child: LocationIconButton(
location: k,
)))
.toList()),
],
),
......@@ -358,6 +403,22 @@ class DashboardState extends State<Dashboard> {
return Container(child: KegiatanTerdekatButton(kegiatan: kegiatanModel));
}
Widget _buildMockKegiatanTerdekatWidget() {
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: KegiatanTerdekatButton(kegiatan: mockKegiatan));
}
Widget _buildGoogleMap(BuildContext context) {
if (currentLocation == null) {
return const Center(
......@@ -366,7 +427,7 @@ class DashboardState extends State<Dashboard> {
} else {
return GoogleMap(
initialCameraPosition:
CameraPosition(target: currentLocation, zoom: cameraZoom),
CameraPosition(target: currentLocation, zoom: cameraZoom),
onMapCreated: (GoogleMapController controller) {
mapController = controller;
},
......@@ -417,20 +478,20 @@ class DashboardState extends State<Dashboard> {
..name = namaLokasi;
final fasilitasRoute = MaterialPageRoute(
builder: (BuildContext context) => DetailPostPage(
lokasi: lokasi,
komentar: KomentarModel(
creator: fasilitas.creator,
dateTime: fasilitas.dateTime,
deskripsi: fasilitas.deskripsi,
id: fasilitas.id,
image: fasilitas.image,
isVerified: fasilitas.isVerified,
namaLokasi: lokasi.name,
tag: fasilitas.tag,
disabilitas: fasilitas.disabilitas,
jumlah: fasilitas.jumlah,
),
));
lokasi: lokasi,
komentar: KomentarModel(
creator: fasilitas.creator,
dateTime: fasilitas.dateTime,
deskripsi: fasilitas.deskripsi,
id: fasilitas.id,
image: fasilitas.image,
isVerified: fasilitas.isVerified,
namaLokasi: lokasi.name,
tag: fasilitas.tag,
disabilitas: fasilitas.disabilitas,
jumlah: fasilitas.jumlah,
),
));
await Navigator.of(context).push(fasilitasRoute);
}
......@@ -447,23 +508,23 @@ class DashboardState extends State<Dashboard> {
..name = namaLokasi;
final fasilitasRoute = MaterialPageRoute(
builder: (BuildContext context) => DetailPostKegiatanPage(
lokasi: lokasi,
kegiatan: KegiatanModel(
id: kegiatan.id,
placeId: lokasi.placeId,
creator: kegiatan.creator,
namaKegiatan: kegiatan.namaKegiatan,
penyelenggara: kegiatan.penyelenggara,
deskripsi: kegiatan.deskripsi,
namaKontak: kegiatan.namaKontak,
nomorKontak: kegiatan.nomorKontak,
links: kegiatan.links,
timeStart: kegiatan.timeStart,
timeEnd: kegiatan.timeEnd,
zonaWaktu: kegiatan.zonaWaktu,
images: kegiatan.images,
),
));
lokasi: lokasi,
kegiatan: KegiatanModel(
id: kegiatan.id,
placeId: lokasi.placeId,
creator: kegiatan.creator,
namaKegiatan: kegiatan.namaKegiatan,
penyelenggara: kegiatan.penyelenggara,
deskripsi: kegiatan.deskripsi,
namaKontak: kegiatan.namaKontak,
nomorKontak: kegiatan.nomorKontak,
links: kegiatan.links,
timeStart: kegiatan.timeStart,
timeEnd: kegiatan.timeEnd,
zonaWaktu: kegiatan.zonaWaktu,
images: kegiatan.images,
),
));
await Navigator.of(context).push(fasilitasRoute);
}
......@@ -473,8 +534,8 @@ class DashboardState extends State<Dashboard> {
_handleDeepLink(data);
FirebaseDynamicLinks.instance.onLink(
onSuccess: (PendingDynamicLinkData dynamicLink) async {
_handleDeepLink(dynamicLink);
}, onError: (OnLinkErrorException e) async {
_handleDeepLink(dynamicLink);
}, onError: (OnLinkErrorException e) async {
print('Link Failed: ${e.message}');
});
}
......
......@@ -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;
}
......@@ -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(