Fakultas Ilmu Komputer UI

Commit 3cf2abbf authored by Putri Salsabila's avatar Putri Salsabila
Browse files

Merge branch 'dev-putsal' into 'PBI-12-info_kegiatan'

Create Ubah Kegiatan form to update kegiatan post

See merge request !70
parents 190369a8 8df32916
Pipeline #81732 passed with stages
in 15 minutes and 11 seconds
......@@ -44,6 +44,30 @@ class KegiatanBloc {
}
}
Future<dynamic> updateKegiatan(
Map<String, dynamic> newKegiatanData,
String placeId,
int id
) async {
try {
return await _kegiatanRepository.updateKegiatan(
newKegiatanData, placeId, id);
} catch (e) {
return {'response': 'FAILED'};
}
}
Future<KegiatanModel> fetchDetailKegiatan(String placeId, int kegiatanId) async {
try {
return await _kegiatanRepository.fetchDetailKegiatan(
placeId,
kegiatanId
);
} catch (e) {
return KegiatanModel();
}
}
void resetKegiatanList() {
kegiatanListSink
.add(NetworkModel.completed(KegiatanList(allKegiatanFromApi)));
......
......@@ -67,7 +67,7 @@ class BisaGoDrawer extends StatelessWidget {
),
Container(
decoration:
BoxDecoration(border: Border(top: BorderSide(color: Colors.white))),
BoxDecoration(border: Border(top: BorderSide(color: Colors.white))),
),
];
menus.forEach((element) => drawerItem.add(element));
......
......@@ -140,7 +140,7 @@ class DashboardState extends State<Dashboard> {
void _showTurnOnLocationDialog(BuildContext context) {
bloc.isLocationServiceTurnedOn().then(
(value) {
(value) {
if (!value) {
showDialog(
context: context,
......@@ -187,7 +187,7 @@ 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) {
......@@ -197,9 +197,9 @@ class DashboardState extends State<Dashboard> {
return Container(
child: const Center(
child: LinearProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
)));
valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
)));
break;
case Status.completed:
final kegiatanTerdekat = snapshot.data.data;
......@@ -209,14 +209,14 @@ class DashboardState extends State<Dashboard> {
case Status.error:
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();
......@@ -346,8 +346,8 @@ class DashboardState extends State<Dashboard> {
Row(
children: lokasilistresponse
.map<Widget>((k) => LocationIconButton(
location: k,
))
location: k,
))
.toList()),
],
),
......@@ -366,7 +366,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 +417,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);
}
......@@ -473,8 +473,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}');
});
}
......
......@@ -120,18 +120,9 @@ class _AddKegiatanState extends State<AddKegiatan> {
);
var newKegiatanData = newKegiatan.toJson();
if (newKegiatanData['zona_waktu'] == 'WIT') {
newKegiatanData['time_start'] = newKegiatanData['time_start']+'+0900';
}
else if (newKegiatanData['zona_waktu'] == 'WITA') {
newKegiatanData['time_start'] = newKegiatanData['time_start']+'+0800';
}
else {
newKegiatanData['time_start'] = newKegiatanData['time_start']+'+0700';
}
var multipartImageList = <MultipartFile>[];
newKegiatanData['place_id'] = widget.placeId;
var multipartImageList = <MultipartFile>[];
if (images != null) {
for (var asset in images) {
var byteData = await asset.getByteData();
......@@ -145,9 +136,18 @@ class _AddKegiatanState extends State<AddKegiatan> {
}
newKegiatanData['images'] = multipartImageList;
}
newKegiatanData['images'] ??= [''];
if (newKegiatanData['zona_waktu'] == 'WIT') {
newKegiatanData['time_start'] = newKegiatanData['time_start']+'+0900';
}
else if (newKegiatanData['zona_waktu'] == 'WITA') {
newKegiatanData['time_start'] = newKegiatanData['time_start']+'+0800';
}
else {
newKegiatanData['time_start'] = newKegiatanData['time_start']+'+0700';
}
final _bloc = KegiatanBloc(widget.placeId);
await _bloc.addNewKegiatan(newKegiatanData);
......@@ -291,7 +291,7 @@ class _AddKegiatanState extends State<AddKegiatan> {
validator: FieldValidator.validateInfo,
controller: deskripsiController,
style: const TextStyle(
fontSize: 18,
fontSize: 15,
),
decoration: InputDecoration(
hintStyle: const TextStyle(
......
......@@ -62,13 +62,15 @@ class _KegiatanState extends State<Kegiatan> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
widget.kegiatan.namaKegiatan,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
color: Colors.black,
fontFamily: 'Muli',
Flexible(
child: Text(
widget.kegiatan.namaKegiatan,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
color: Colors.black,
fontFamily: 'Muli',
),
),
),
],
......
......@@ -24,6 +24,8 @@ import 'package:share/share.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
import '../update_kegiatan.dart';
class DetailPostKegiatanPage extends StatefulWidget {
final Lokasi lokasi;
final KegiatanModel kegiatan;
......@@ -73,129 +75,127 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
),
],
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
key: const Key('Text Judul Kegiatan'),
margin: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 15.0),
alignment: Alignment.centerLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: MediaQuery.of(context).size.width * 0.8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: regularSpace),
Text(
'${widget.kegiatan.namaKegiatan}',
style: const TextStyle(
fontSize: 30,
fontWeight: FontWeight.w800,
letterSpacing: 0.3,
fontFamily: 'Muli',
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
key: const Key('Text Judul Kegiatan'),
margin: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 15.0),
alignment: Alignment.centerLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: MediaQuery.of(context).size.width * 0.7,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: regularSpace),
Text(
'${widget.kegiatan.namaKegiatan}',
style: const TextStyle(
fontSize: 30,
fontWeight: FontWeight.w800,
letterSpacing: 0.3,
fontFamily: 'Muli',
),
),
),
Text(
'oleh ${widget.kegiatan.penyelenggara}',
style: TextStyle(fontSize: 16),
textAlign: TextAlign.left,
)
],
Text(
'oleh ${widget.kegiatan.penyelenggara}',
style: TextStyle(fontSize: 16),
textAlign: TextAlign.left,
)
],
),
),
),
// PopupMenuButton(
// key: const Key('Button Ubah Informasi'),
// elevation: 4.0,
// offset: const Offset(0.0, 40.0),
// itemBuilder: (BuildContext context) {
// final choices = ['Ubah Informasi'];
// return choices.map((String choice) {
// return PopupMenuItem(
// key: Key(choice),
// child: ElevatedButton(
// style: ButtonStyle(
// padding: MaterialStateProperty.all(
// EdgeInsets.symmetric(
// vertical: 0, horizontal: 0)),
// backgroundColor:
// MaterialStateProperty.all(Colors.white),
// foregroundColor:
// MaterialStateProperty.all(Colors.black),
// elevation: MaterialStateProperty.all(0)),
// onPressed: _updateInformasi,
// child: SizedBox(
// width: double.infinity,
// child: Text(choice),
// ),
// ),
// );
// }).toList();
// },
// ),
],
PopupMenuButton(
key: const Key('Button Ubah Kegiatan'),
elevation: 4.0,
offset: const Offset(0.0, 40.0),
itemBuilder: (BuildContext context) {
final choices = ['Ubah Kegiatan'];
return choices.map((String choice) {
return PopupMenuItem(
key: Key(choice),
child: ElevatedButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
EdgeInsets.symmetric(
vertical: 0, horizontal: 0)),
backgroundColor:
MaterialStateProperty.all(Colors.white),
foregroundColor:
MaterialStateProperty.all(Colors.black),
elevation: MaterialStateProperty.all(0)),
onPressed: updateKegiatan,
child: SizedBox(
width: double.infinity,
child: Text(choice),
),
),
);
}).toList();
},
),
],
),
),
),
Container(
margin: const EdgeInsets.all(doubleSpace),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width,
height: 160,
child: CarouselSlider(
options: CarouselOptions(
aspectRatio: 1.0,
enlargeCenterPage: true,
enableInfiniteScroll: false,
initialPage: 0,
autoPlay: true,
),
items: widget.kegiatan.images
.map((item) => Container(
child: Container(
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(20)),
child: Stack(
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.push<Widget>(
context,
MaterialPageRoute(
builder:
(context) =>
KegiatanListImages(
widget.kegiatan.images,
widget.kegiatan.namaKegiatan
),
)
);
},
child: Image.network(item, fit: BoxFit.cover, width: 1000.0),
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(
200, 0, 0, 0),
Color.fromARGB(0, 0, 0, 0)
],
begin:
Alignment.bottomCenter,
end: Alignment.topCenter,
Container(
margin: const EdgeInsets.all(doubleSpace),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width,
height: 160,
child: CarouselSlider(
options: CarouselOptions(
aspectRatio: 1.0,
enlargeCenterPage: true,
enableInfiniteScroll: false,
initialPage: 0,
autoPlay: true),
items: widget.kegiatan.images.map((item) => Container(
child: Container(
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(20)),
child: Stack(
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.push<Widget>(
context,
MaterialPageRoute(
builder:
(context) =>
KegiatanListImages(
widget.kegiatan.images,
widget.kegiatan.namaKegiatan
),
)
);
},
child: Image.network(item, fit: BoxFit.cover, width: 1000.0),
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(
200, 0, 0, 0),
Color.fromARGB(0, 0, 0, 0)
],
begin:
Alignment.bottomCenter,
end: Alignment.topCenter,
),
),
),
padding: EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 20.0),
......@@ -208,14 +208,13 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
),
),
),
),
],
)),
),
))
.toList(),
),
],
)),
),
)).toList(),
),
),
),
SizedBox(height: 10),
Container(
key: const Key('desc'),
......@@ -305,7 +304,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
color: Colors.green,
),
SizedBox(width: 7.0),
Expanded(
Flexible(
child: TextButton(
key: const Key('Text Link Kegiatan'),
onPressed: () => setState(() {
......@@ -325,9 +324,6 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
),
],
),
// ),
// ],
// ),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
......@@ -665,20 +661,31 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
);
}
// Future<void> _updateInformasi() async {
// final sharedPreferences = await SharedPreferences.getInstance();
// if (sharedPreferences.getString('token') == null) {
// await Navigator.of(context).pushAndRemoveUntil(
// MaterialPageRoute(builder: (BuildContext context) => const Login()),
// (Route<dynamic> route) => false);
// } else {
// await Navigator.of(context).push(MaterialPageRoute(
// builder: (BuildContext context) => UpdateInformasi(
// komentar: widget.komentar, lokasi: widget.lokasi) // ganti modelnya di update_informasi.dart
// ));
// String _creatorInitials(String name) {
// if (name.isEmpty) return '';
// var initials = '';
// for (final i in name.split(' ')) {
// initials += '${i[0].toUpperCase()}';
// }
// if (initials.length > 2) return initials.substring(0, 2);
// return initials;
// }
Future<void> updateKegiatan() async {
final sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getString('token') == null) {
await Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (BuildContext context) => const Login()),
(Route<dynamic> route) => false);
} else {
await Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => UpdateKegiatan(
kegiatan: widget.kegiatan, lokasi: widget.lokasi
)
));
}
}
@override
void dispose() {
_bloc.dispose();
......
......@@ -93,40 +93,6 @@ class UpdateInformasiState extends State<UpdateInformasi> {
),
),
const SizedBox(height: doubleSpace),
// const Text(
// 'Foto Fasilitas',
// style: TextStyle(fontSize: 18),
// textAlign: TextAlign.left,
// ),
// GridView.count(
// key: const Key('Input Gambar'),
// shrinkWrap: true,
// primary: false,
// padding: const EdgeInsets.all(10),