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
48bcc111
Commit
48bcc111
authored
Jun 07, 2021
by
Jovi Handono Hutama
Browse files
Merge branch 'dev-jovi' into 'PBI-12-info_kegiatan'
Implement update image See merge request
!71
parents
3cf2abbf
4a75da29
Pipeline
#81865
passed with stages
in 17 minutes and 23 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
android/fastlane/metadata/android/id/changelogs/changelogs.txt
View file @
48bcc111
3.5.1:
- Pengguna dapat mengubah informasi kegiatan yang sudah ada
3.5.0:
- Pengguna dapat mengganti foto profil
...
...
lib/page/filter_fasilitas/update_kegiatan.dart
View file @
48bcc111
...
...
@@ -11,12 +11,12 @@ 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: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: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'
;
...
...
@@ -46,7 +46,9 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
TextEditingController
namaKontakController
=
TextEditingController
();
TextEditingController
nomorKontakController
=
TextEditingController
();
TextEditingController
linkController
=
TextEditingController
();
List
<
String
>
oldKegiatanImages
;
List
<
String
>
newKegiatanImages
;
List
<
dynamic
>
allKegiatanImages
=
[];
String
tanggalKegiatan
=
'
${DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now())}
'
;
String
zonaCurrent
=
'WIB'
;
...
...
@@ -64,10 +66,8 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
linkController
=
TextEditingController
(
text:
widget
.
kegiatan
.
links
);
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();
oldKegiatanImages
=
widget
.
kegiatan
.
images
;
allKegiatanImages
.
addAll
(
oldKegiatanImages
);
}
@override
...
...
@@ -117,11 +117,9 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
),
),
);
// throw UnimplementedError();
}
Future
<
void
>
_submitData
()
async
{
// TODO: implement submit data
final
form
=
_formKey
.
currentState
;
if
(
_formKey
.
currentState
.
validate
())
{
form
.
save
();
...
...
@@ -141,23 +139,25 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
);
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'
]
=
[];
newKegiatanData
[
'place_id'
]
=
widget
.
lokasi
.
placeId
;
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
);
}
allKegiatanImages
.
addAll
(
multipartImageList
);
newKegiatanData
[
'images'
]
=
multipartImageList
;
}
newKegiatanData
[
'images'
]
??=
[];
if
(
newKegiatanData
[
'zona_waktu'
]
==
'WIT'
)
{
newKegiatanData
[
'time_start'
]
=
newKegiatanData
[
'time_start'
]
+
'+0900'
;
...
...
@@ -169,10 +169,9 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
newKegiatanData
[
'time_start'
]
=
newKegiatanData
[
'time_start'
]
+
'+0700'
;
}
final
_bloc
=
KegiatanBloc
(
widget
.
lokasi
.
placeId
);
// tdnya widget.placeId
final
_bloc
=
KegiatanBloc
(
widget
.
lokasi
.
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
)
...
...
@@ -181,11 +180,6 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
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'
);
}
...
...
@@ -234,7 +228,7 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
enableCamera:
true
,
selectedAssets:
images
,
materialOptions:
MaterialOptions
(
actionBarTitle:
widget
.
lokasi
.
name
,
// tdnya widget.nama
actionBarTitle:
widget
.
lokasi
.
name
,
actionBarColor:
'#ff3A903A'
,
statusBarColor:
'#ff347D34'
,
useDetailsView:
true
,
...
...
@@ -244,6 +238,7 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
);
setState
(()
{
images
=
resultList
;
allKegiatanImages
.
addAll
(
images
);
});
}
else
{
await
openAppSettings
();
...
...
@@ -416,8 +411,6 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
),
),
Row
(
children:
<
Widget
>[
// SizedBox(
// width: 186.0,
Expanded
(
child:
TextButton
(
key:
const
Key
(
'Button Tanggal & Waktu Kegiatan'
),
...
...
@@ -505,7 +498,6 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
await
pickImages
();
},
child:
Container
(
// width: MediaQuery.of(context).size.width * 0.35,
padding:
const
EdgeInsets
.
all
(
9.0
),
alignment:
Alignment
.
centerLeft
,
decoration:
BoxDecoration
(
...
...
@@ -546,10 +538,29 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
}
Widget
_showImagePreview
()
{
return
images
.
isEmpty
?
const
SizedBox
(
height:
0
)
:
carousel
();
if
(
oldKegiatanImages
.
isEmpty
)
{
return
SizedBox
(
height:
0
);
}
else
{
return
carousel
(
allKegiatanImages
);
}
}
Widget
_showImage
(
dynamic
item
)
{
if
(
item
is
Asset
)
{
print
(
item
.
runtimeType
);
return
AssetThumb
(
asset:
item
,
width:
MediaQuery
.
of
(
context
)
.
size
.
height
.
toInt
(),
height:
MediaQuery
.
of
(
context
)
.
size
.
width
.
toInt
(),
);
}
else
if
(
item
is
String
)
{
return
Image
.
network
(
item
,
fit:
BoxFit
.
cover
,
width:
1000.0
);
}
else
{
return
SizedBox
(
height:
0
);
}
}
Widget
carousel
()
{
Widget
carousel
(
List
<
dynamic
>
_images
)
{
return
SizedBox
(
width:
MediaQuery
.
of
(
context
)
.
size
.
width
,
height:
160
,
...
...
@@ -561,18 +572,14 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
initialPage:
0
,
autoPlay:
true
,
),
items:
images
items:
_
images
.
map
(
(
item
)
=
>
Container
(
child:
ClipRRect
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
child:
Stack
(
children:
<
Widget
>[
AssetThumb
(
asset:
item
,
width:
MediaQuery
.
of
(
context
)
.
size
.
height
.
toInt
(),
height:
MediaQuery
.
of
(
context
)
.
size
.
width
.
toInt
(),
),
_showImage
(
item
),
Positioned
(
bottom:
0.0
,
left:
0.0
,
...
...
@@ -591,7 +598,7 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
padding:
EdgeInsets
.
symmetric
(
vertical:
10.0
,
horizontal:
20.0
),
child:
Text
(
'#
${images.indexOf(item) + 1}
'
,
'#
${
_
images.indexOf(item) + 1}
'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
20.0
,
...
...
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