Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL Sosial
bisago
bisago-fe
Commits
4c84cb30
Commit
4c84cb30
authored
Jun 06, 2021
by
Putri Salsabila
Browse files
[REFACTOR] Edit Ubah Kegiatan form n Kegiatan bloc & repo
parent
3464f6b8
Changes
9
Hide whitespace changes
Inline
Side-by-side
lib/bloc/kegiatan_bloc.dart
View file @
4c84cb30
...
...
@@ -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
)));
...
...
lib/page/dashboard/dashboard.dart
View file @
4c84cb30
...
...
@@ -61,7 +61,7 @@ class DashboardState extends State<Dashboard> {
void
_showTurnOnLocationDialog
(
BuildContext
context
)
{
bloc
.
isLocationServiceTurnedOn
()
.
then
(
(
value
)
{
(
value
)
{
if
(
!
value
)
{
showDialog
(
context:
context
,
...
...
@@ -108,7 +108,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
)
{
...
...
@@ -118,9 +118,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
;
...
...
@@ -130,14 +130,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
();
...
...
@@ -267,8 +267,8 @@ class DashboardState extends State<Dashboard> {
Row
(
children:
lokasilistresponse
.
map
<
Widget
>((
k
)
=
>
LocationIconButton
(
location:
k
,
))
location:
k
,
))
.
toList
()),
],
),
...
...
@@ -287,7 +287,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
;
},
...
...
@@ -338,20 +338,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
);
}
...
...
@@ -394,8 +394,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}
'
);
});
}
...
...
lib/page/filter_fasilitas/add_kegiatan.dart
View file @
4c84cb30
...
...
@@ -121,18 +121,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
();
...
...
@@ -146,9 +137,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
);
...
...
lib/page/filter_fasilitas/kegiatan.dart
View file @
4c84cb30
...
...
@@ -61,13 +61,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'
,
),
),
),
],
...
...
lib/page/filter_fasilitas/postingan/detail_post_kegiatan.dart
View file @
4c84cb30
...
...
@@ -160,8 +160,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
initialPage:
0
,
autoPlay:
true
,
),
items:
widget
.
kegiatan
.
images
.
map
((
item
)
=
>
Container
(
items:
widget
.
kegiatan
.
images
.
map
((
item
)
=
>
Container
(
child:
Container
(
child:
ClipRRect
(
borderRadius:
BorderRadius
.
all
(
...
...
@@ -217,8 +216,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
],
)),
),
))
.
toList
(),
))
.
toList
(),
),
),
SizedBox
(
height:
10
),
...
...
@@ -310,7 +308,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
(()
{
...
...
lib/page/filter_fasilitas/update_kegiatan.dart
View file @
4c84cb30
import
'dart:async'
;
import
'package:bisaGo/bloc/kegiatan_bloc.dart'
;
import
'package:bisaGo/component/bisago_appbar.dart'
;
import
'package:bisaGo/config/strings.dart'
;
import
'package:bisaGo/config/styles.dart'
;
import
'package:bisaGo/model/kegiatan.dart'
;
import
'package:bisaGo/model/lokasi.dart'
;
import
'package:bisaGo/page/filter_fasilitas/postingan/detail_post_kegiatan.dart'
;
import
'package:bisaGo/utils/custom_button.dart'
;
import
'package:bisaGo/utils/custom_text_field.dart'
;
import
'package:bisaGo/utils/validator.dart'
;
import
'package:carousel_slider/carousel_slider.dart'
;
import
'package:dio/dio.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_datetime_picker/flutter_datetime_picker.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'package:http_parser/http_parser.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:intl/intl.dart'
;
import
'package:material_design_icons_flutter/material_design_icons_flutter.dart'
;
...
...
@@ -50,16 +56,18 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
@override
void
initState
()
{
super
.
initState
();
// TODO: write init state i guess
namaKegiatanController
=
TextEditingController
(
text:
widget
.
kegiatan
.
namaKegiatan
);
penyelenggaraController
=
TextEditingController
(
text:
widget
.
kegiatan
.
penyelenggara
);
deskripsiController
=
TextEditingController
(
text:
widget
.
kegiatan
.
deskripsi
);
namaKontakController
=
TextEditingController
(
text:
widget
.
kegiatan
.
namaKontak
);
nomorKontakController
=
TextEditingController
(
text:
widget
.
kegiatan
.
nomorKontak
);
linkController
=
TextEditingController
(
text:
widget
.
kegiatan
.
links
);
// tanggalKegiatan = '${DateFormat('${widget.kegiatan.timeStart}').format(DateTime.now())}';
tanggalKegiatan
=
'
${widget.kegiatan.timeStart}
'
;
tanggalKegiatan
=
'
${DateFormat('yyyy-MM-dd HH:mm').format(widget.kegiatan.timeStart)}
'
;
zonaCurrent
=
widget
.
kegiatan
.
zonaWaktu
;
// TODO: write init images
// images = MultiImagePicker.pickImages(widget.kegiatan.images) as List<Asset>;
// images = widget.kegiatan.images as List<Asset>;
// images = images.map<Asset>(widget.kegiatan.images).toList();
}
@override
...
...
@@ -114,10 +122,73 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
Future
<
void
>
_submitData
()
async
{
// TODO: implement submit data
// final form = _formKey.currentState;
// if (_formKey.currentState.validate()) {
// form.save();
// }
final
form
=
_formKey
.
currentState
;
if
(
_formKey
.
currentState
.
validate
())
{
form
.
save
();
final
newKegiatan
=
KegiatanModel
(
namaKegiatan:
namaKegiatanController
.
text
,
penyelenggara:
penyelenggaraController
.
text
,
deskripsi:
deskripsiController
.
text
,
namaKontak:
namaKontakController
.
text
,
nomorKontak:
nomorKontakController
.
text
,
links:
linkController
.
text
,
timeStart:
DateTime
.
parse
(
tanggalKegiatan
),
timeEnd:
DateTime
.
parse
(
tanggalKegiatan
)
.
add
(
Duration
(
days:
1
),
),
zonaWaktu:
zonaCurrent
,
);
var
newKegiatanData
=
newKegiatan
.
toJson
();
newKegiatanData
[
'place_id'
]
=
widget
.
lokasi
;
// var multipartImageList = <MultipartFile>[];
// if (images != null) {
// for (var asset in images) {
// var byteData = await asset.getByteData();
// var imageData = byteData.buffer.asUint8List();
// var multipartFile = MultipartFile.fromBytes(
// imageData,
// filename: asset.name,
// contentType: MediaType('image', 'jpeg'),
// );
// multipartImageList.add(multipartFile);
// }
// 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
.
lokasi
.
placeId
);
// tdnya widget.placeId
await
_bloc
.
updateKegiatan
(
newKegiatanData
,
widget
.
lokasi
.
placeId
,
widget
.
kegiatan
.
id
);
final
kegiatan
=
await
_bloc
.
fetchDetailKegiatan
(
widget
.
lokasi
.
placeId
,
widget
.
kegiatan
.
id
);
final
route
=
MaterialPageRoute
(
builder:
(
_
)
=
>
DetailPostKegiatanPage
(
kegiatan:
widget
.
kegiatan
,
lokasi:
widget
.
lokasi
)
);
successDialog
(
context
);
await
Future
.
delayed
(
Duration
(
seconds:
2
));
await
Navigator
.
pushAndRemoveUntil
(
context
,
route
,
(
route
)
=
>
route
.
isFirst
);
// successDialog(context);
// Timer(const Duration(seconds: 2), () {
// Navigator.pop(context);
// Navigator.pop(context);
// }
}
else
{
failedDialog
(
context
,
'default'
);
}
}
void
successDialog
(
BuildContext
context
)
{
...
...
lib/page/updateInformasi/update_informasi.dart
View file @
4c84cb30
...
...
@@ -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),
// crossAxisSpacing: 10,
// crossAxisCount: 2,
// children: <Widget>[
// GestureDetector(
// onTap: _getImage,
// child: Container(
// padding: const EdgeInsets.symmetric(
// horizontal: 20.0, vertical: 2.0),
// decoration: const BoxDecoration(
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(20.0),
// topRight: Radius.circular(20.0),
// bottomLeft: Radius.circular(20.0),
// bottomRight: Radius.circular(20.0),
// ),
// color: Colors.black12,
// ),
// child: _image == null
// ? const Icon(FontAwesomeIcons.plus)
// : Image.file(_image),
// ),
// )
// ],
// ),
const
Text
(
'Jenis fasilitas / layanan'
,
style:
TextStyle
(
fontSize:
18
),
...
...
lib/repository/kegiatan_repository.dart
View file @
4c84cb30
...
...
@@ -7,6 +7,8 @@ abstract class BaseKegiatanRepository {
Future
<
List
<
String
>>
fetchImages
(
String
placeId
,
int
id
);
Future
<
dynamic
>
createKegiatan
(
Map
<
String
,
dynamic
>
newKegiatanData
);
Future
<
dynamic
>
updateKegiatan
(
Map
<
String
,
dynamic
>
newKegiatanData
,
String
placeId
,
int
kegiatanId
);
Future
<
KegiatanModel
>
fetchDetailKegiatan
(
String
placeId
,
int
kegiatanId
);
}
...
...
@@ -54,6 +56,18 @@ class KegiatanRepository implements BaseKegiatanRepository {
);
return
response
;
}
@override
Future
<
dynamic
>
updateKegiatan
(
Map
<
String
,
dynamic
>
newKegiatanData
,
String
placeId
,
int
kegiatanId
)
async
{
final
response
=
await
_network
.
put
(
url:
'/informasi-fasilitas/lokasi/update-kegiatan/
$placeId
/
$kegiatanId
/'
,
bodyParams:
newKegiatanData
,
isLogin:
true
,
);
return
response
;
}
@override
Future
<
KegiatanModel
>
fetchDetailKegiatan
(
String
placeId
,
int
kegiatanId
)
async
{
...
...
lib/utils/custom_kegiatan_terdekat_button.dart
View file @
4c84cb30
...
...
@@ -60,12 +60,16 @@ class _KegiatanTerdekatButtonState extends State<KegiatanTerdekatButton> {
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
widget
.
kegiatan
.
namaKegiatan
,
//+widget.kegiatan.deskripsi,
style:
const
TextStyle
(
color:
greenPrimary
,
fontSize:
16
,
fontFamily:
'Muli'
,
)),
Flexible
(
child:
Text
(
widget
.
kegiatan
.
namaKegiatan
,
//+widget.kegiatan.deskripsi,
overflow:
TextOverflow
.
ellipsis
,
style:
const
TextStyle
(
color:
greenPrimary
,
fontSize:
16
,
fontFamily:
'Muli'
,
)
),
),
Text
(
'more info>'
,
style:
TextStyle
(
color:
Colors
.
grey
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment