Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
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
6549e425
Commit
6549e425
authored
May 16, 2021
by
jovi_013
Browse files
[GREEN] Implement carousel for kegiatan & bug fix
parent
667b0d72
Pipeline
#77152
failed with stages
in 2 minutes and 20 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/config/custom_serializer.dart
View file @
6549e425
...
...
@@ -2,6 +2,6 @@ import 'package:intl/intl.dart';
class
CustomSerializer
{
static
DateTime
stringToDateTime
(
String
date
)
{
return
DateFormat
(
'
dd-MM-yyyy
hh:mm
:ss
'
).
parse
(
date
);
return
DateFormat
(
'
yyyy-MM-dd
hh:mm'
).
parse
(
date
);
}
}
lib/model/kegiatan.dart
View file @
6549e425
...
...
@@ -20,10 +20,11 @@ class KegiatanModel {
final
String
penyelenggara
;
final
String
narahubung
;
final
String
deskripsi
;
// @JsonKey(name: 'time_start', fromJson: CustomSerializer.stringToDateTime)
// final DateTime timeStart;
// @JsonKey(name: 'time_end', fromJson: CustomSerializer.stringToDateTime)
// final DateTime timeEnd;
@JsonKey
(
name:
'time_start'
,
fromJson:
CustomSerializer
.
stringToDateTime
)
final
DateTime
timeStart
;
@JsonKey
(
name:
'time_end'
,
fromJson:
CustomSerializer
.
stringToDateTime
)
final
DateTime
timeEnd
;
List
<
String
>
image
;
KegiatanModel
(
{
...
...
@@ -34,8 +35,9 @@ class KegiatanModel {
this
.
penyelenggara
,
this
.
narahubung
,
this
.
deskripsi
,
// this.timeStart,
// this.timeEnd
this
.
timeStart
,
this
.
timeEnd
,
this
.
image
,
}
);
...
...
lib/model/kegiatan.g.dart
View file @
6549e425
...
...
@@ -30,6 +30,9 @@ KegiatanModel _$KegiatanModelFromJson(Map<String, dynamic> json) {
penyelenggara:
json
[
'penyelenggara'
]
as
String
,
narahubung:
json
[
'narahubung'
]
as
String
,
deskripsi:
json
[
'deskripsi'
]
as
String
,
timeStart:
CustomSerializer
.
stringToDateTime
(
json
[
'time_start'
]
as
String
),
timeEnd:
CustomSerializer
.
stringToDateTime
(
json
[
'time_end'
]
as
String
),
image:
(
json
[
'image'
]
as
List
)?.
map
((
e
)
=>
e
as
String
)?.
toList
(),
);
}
...
...
@@ -42,4 +45,7 @@ Map<String, dynamic> _$KegiatanModelToJson(KegiatanModel instance) =>
'penyelenggara'
:
instance
.
penyelenggara
,
'narahubung'
:
instance
.
narahubung
,
'deskripsi'
:
instance
.
deskripsi
,
'time_start'
:
instance
.
timeStart
?.
toIso8601String
(),
'time_end'
:
instance
.
timeEnd
?.
toIso8601String
(),
'image'
:
instance
.
image
,
};
lib/model/komentar_posting_kegiatan.g.dart
View file @
6549e425
...
...
@@ -29,7 +29,7 @@ KomentarPostingKegiatanModel _$KomentarPostingKegiatanModelFromJson(
id:
json
[
'id'
]
as
int
,
creator:
json
[
'creator'
]
as
String
,
deskripsi:
json
[
'deskripsi'
]
as
String
,
created:
CustomSerializer
.
stringToDateTime
(
json
[
'created'
]
as
String
)
created:
CustomSerializer
.
stringToDateTime
(
json
[
'created'
]
as
String
)
,
);
}
...
...
lib/page/filter_fasilitas/kegiatan.dart
View file @
6549e425
...
...
@@ -2,6 +2,7 @@ import 'package:bisaGo/config/styles.dart';
import
'package:bisaGo/model/lokasi.dart'
;
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';
...
...
@@ -33,8 +34,9 @@ class _KegiatanState extends State<Kegiatan> {
penyelenggara:
widget
.
kegiatan
.
penyelenggara
,
narahubung:
widget
.
kegiatan
.
narahubung
,
deskripsi:
widget
.
kegiatan
.
deskripsi
,
// timeStart: widget.kegiatan.timeStart,
// timeEnd: widget.kegiatan.timeEnd,
timeStart:
widget
.
kegiatan
.
timeStart
,
timeEnd:
widget
.
kegiatan
.
timeEnd
,
image:
widget
.
kegiatan
.
image
,
),
)
));
...
...
@@ -72,12 +74,55 @@ class _KegiatanState extends State<Kegiatan> {
Container
(
margin:
const
EdgeInsets
.
only
(
bottom:
regularSpace
),
child:
SizedBox
(
width:
MediaQuery
.
of
(
context
).
size
.
width
,
height:
160
,
// child: ImageHolder(
// url: widget.kegiatan.image,
// fasilitas: widget.kegiatan.tag
// )
child:
Text
(
'Image here'
),
child:
CarouselSlider
(
options:
CarouselOptions
(
aspectRatio:
1.0
,
enlargeCenterPage:
true
,
enableInfiniteScroll:
false
,
initialPage:
0
,
autoPlay:
true
,
),
items:
widget
.
kegiatan
.
image
.
map
((
item
)
=>
Container
(
child:
Container
(
child:
ClipRRect
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
child:
Stack
(
children:
<
Widget
>[
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
),
child:
Text
(
'#
${widget.kegiatan.image.indexOf(item)+1}
'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
20.0
,
fontWeight:
FontWeight
.
bold
,
),
),
),
),
],
)
),
),
)).
toList
(),
),
)
),
Row
(
...
...
@@ -103,5 +148,5 @@ class _KegiatanState extends State<Kegiatan> {
],
),
));
}
}
}
}
\ No newline at end of file
lib/repository/kegiatan_repository.dart
View file @
6549e425
import
'package:bisaGo/flavor/flavor.dart'
;
import
'package:bisaGo/model/kegiatan.dart'
;
import
'package:bisaGo/network/network_interface.dart'
;
abstract
class
BaseKegiatanRepository
{
Future
<
KegiatanList
>
fetchKegiatan
(
String
placeId
);
Future
<
List
<
String
>>
fetchImages
(
String
placeId
,
int
id
);
}
class
KegiatanRepository
implements
BaseKegiatanRepository
{
...
...
@@ -13,8 +15,28 @@ class KegiatanRepository implements BaseKegiatanRepository {
final
url
=
'/informasi-fasilitas/lokasi/list-kegiatan/
$placeId
'
;
final
response
=
await
_network
.
get
(
url:
url
,
isLogin:
false
);
final
data
=
response
.
values
.
toList
().
reversed
.
toList
();
return
KegiatanList
(
data
.
map
<
KegiatanModel
>((
kegiatan
)
=>
KegiatanModel
.
fromJson
(
kegiatan
))
.
toList
());
var
allKegiatan
=
[];
for
(
var
_index
=
0
;
_index
<
data
.
length
;
_index
++)
{
var
kegiatan
=
KegiatanModel
.
fromJson
(
data
[
_index
]);
kegiatan
.
image
=
await
fetchImages
(
kegiatan
.
placeId
,
kegiatan
.
id
);
allKegiatan
.
add
(
kegiatan
);
}
allKegiatan
=
allKegiatan
.
cast
<
KegiatanModel
>();
return
KegiatanList
(
allKegiatan
);
}
@override
Future
<
List
<
String
>>
fetchImages
(
String
placeId
,
int
id
)
async
{
final
url
=
'/informasi-fasilitas/lokasi/list-foto-kegiatan/
$placeId
/
$id
'
;
final
response
=
await
_network
.
get
(
url:
url
,
isLogin:
false
);
var
allImages
=
[];
for
(
var
_index
=
0
;
_index
<
response
.
length
;
_index
++)
{
var
fotoUrl
=
ApiFlavor
.
getBaseUrl
()
+
response
.
values
.
toList
()[
_index
][
'foto'
];
allImages
.
add
(
fotoUrl
);
}
allImages
=
allImages
.
cast
<
String
>();
return
allImages
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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