Fakultas Ilmu Komputer UI

Commit cf13d486 authored by Yoga Pratama's avatar Yoga Pratama
Browse files

[CHORES] Change title and carousel

parent 4993d1cb
...@@ -4,12 +4,12 @@ import 'package:bisaGo/model/kegiatan.dart'; ...@@ -4,12 +4,12 @@ import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/lokasi.dart'; import 'package:bisaGo/model/lokasi.dart';
// import 'package:bisaGo/page/updateInformasi/update_informasi.dart'; // import 'package:bisaGo/page/updateInformasi/update_informasi.dart';
import 'package:bisaGo/utils/validator.dart'; import 'package:bisaGo/utils/validator.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:bisaGo/bloc/komentar_posting_kegiatan_bloc.dart'; import 'package:bisaGo/bloc/komentar_posting_kegiatan_bloc.dart';
import 'package:bisaGo/component/image_holder.dart';
import 'package:bisaGo/component/bisago_appbar.dart'; import 'package:bisaGo/component/bisago_appbar.dart';
import 'package:bisaGo/config/styles.dart'; import 'package:bisaGo/config/styles.dart';
import 'package:bisaGo/model/komentar_posting_kegiatan.dart'; import 'package:bisaGo/model/komentar_posting_kegiatan.dart';
...@@ -18,6 +18,8 @@ import 'package:bisaGo/page/login/login.dart'; ...@@ -18,6 +18,8 @@ import 'package:bisaGo/page/login/login.dart';
import 'package:share/share.dart'; import 'package:share/share.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../fasilitas.dart';
class DetailPostKegiatanPage extends StatefulWidget { class DetailPostKegiatanPage extends StatefulWidget {
final Lokasi lokasi; final Lokasi lokasi;
final KegiatanModel kegiatan; // ganti model x // sudah final KegiatanModel kegiatan; // ganti model x // sudah
...@@ -38,27 +40,32 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -38,27 +40,32 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
@override @override
void initState() { void initState() {
allKomentarPositngKegiatanFromApi = []; allKomentarPositngKegiatanFromApi = [];
_bloc = KomentarPostingKegiatanBloc(widget.lokasi.placeId, widget.kegiatan.id); _bloc =
KomentarPostingKegiatanBloc(widget.lokasi.placeId, widget.kegiatan.id);
super.initState(); super.initState();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return WillPopScope( return WillPopScope(
onWillPop: () => Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (BuildContext context) => Fasilitas(
lokasi: widget.lokasi,
))),
child: Scaffold( child: Scaffold(
appBar: BisaGoAppBar( appBar: BisaGoAppBar(
title: widget.kegiatan.placeId, // ganti widget.x.namalokasi // sudah title: widget.lokasi.name,
key: Key('appbar-text-${widget.kegiatan.placeId}'), key: Key('appbar-text-${widget.kegiatan.placeId}'),
actions: <Widget>[ actions: <Widget>[
InkWell( InkWell(
child: const Icon(Icons.share), onTap: () => Share.share(
onTap: () => Share.share( 'Review kegiatan disabilitas di ${widget.lokasi.name}, '
'Review kegiatan disabilitas di ${widget.lokasi.name}, ' 'oleh: ${widget.kegiatan.creator}\n\"${widget.kegiatan.deskripsi}\"\n\nDapatkan info fasilitas ramah '
'oleh: ${widget.kegiatan.creator}\n\"${widget.kegiatan.deskripsi}\"\n\nDapatkan info fasilitas ramah ' 'disabilitas dari aplikasi bisaGo!\nDownload bisaGo '
'disabilitas dari aplikasi bisaGo!\nDownload bisaGo ' 'sekarang di: https://bit.ly/DownloadbisaGo'),
'sekarang di: https://bit.ly/DownloadbisaGo' child: const Icon(Icons.share),
) // ganti format share // ganti format share
) ),
], ],
), ),
body: SingleChildScrollView( body: SingleChildScrollView(
...@@ -80,7 +87,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -80,7 +87,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
children: <Widget>[ children: <Widget>[
SizedBox(height: regularSpace), SizedBox(height: regularSpace),
Text( Text(
widget.kegiatan.namaKegiatan, // ganti nama kegiatan // sudah widget.kegiatan
.namaKegiatan, // ganti nama kegiatan // sudah
style: const TextStyle( style: const TextStyle(
fontSize: 30, fontSize: 30,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
...@@ -136,10 +144,64 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -136,10 +144,64 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
height: 150, width: MediaQuery.of(context).size.width,
child: ImageHolder( height: 160,
url: null, child: CarouselSlider(
fasilitas: null)), 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(),
),
),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
...@@ -193,7 +255,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -193,7 +255,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
), ),
SizedBox(height: 40), SizedBox(height: 40),
Text( Text(
widget.kegiatan.deskripsi, // ganti format widget.x.deskripsi kegiatan // sudah widget.kegiatan
.deskripsi, // ganti format widget.x.deskripsi kegiatan // sudah
style: const TextStyle(fontSize: 16), style: const TextStyle(fontSize: 16),
key: const Key('Text Deskripsi Kegiatan'), key: const Key('Text Deskripsi Kegiatan'),
), ),
...@@ -209,7 +272,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -209,7 +272,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
), ),
const SizedBox(width: 7.0), const SizedBox(width: 7.0),
Text( Text(
widget.kegiatan.narahubung, // ganti format narahubung // sudah widget.kegiatan
.narahubung, // ganti format narahubung // sudah
style: TextStyle(fontSize: 16), style: TextStyle(fontSize: 16),
key: Key('Text Narahubung'), key: Key('Text Narahubung'),
), ),
...@@ -238,8 +302,10 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -238,8 +302,10 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
maxWidth: maxWidth:
MediaQuery.of(context).size.width * 0.3), MediaQuery.of(context).size.width * 0.3),
child: Text( child: Text(
widget.kegiatan.creator, // ganti format ${widget.x.creator} // sudah widget.kegiatan
key: Key('Creator info kegiatan'), // ganti format key creator-${widget.x.creator} .creator, // ganti format ${widget.x.creator} // sudah
key: Key(
'Creator info kegiatan'), // ganti format key creator-${widget.x.creator}
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
softWrap: false, softWrap: false,
style: const TextStyle( style: const TextStyle(
...@@ -268,12 +334,12 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -268,12 +334,12 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
), ),
Container( Container(
key: const Key('Komentar'), key: const Key('Komentar'),
padding: const EdgeInsets.symmetric(vertical: regularSpace), padding:
const EdgeInsets.symmetric(vertical: regularSpace),
child: const Text( child: const Text(
'Komentar', 'Komentar',
style: TextStyle( style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w800 fontSize: 20, fontWeight: FontWeight.w800),
),
), ),
), ),
StreamBuilder( StreamBuilder(
...@@ -284,24 +350,29 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -284,24 +350,29 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
case Status.loading: case Status.loading:
return const Center( return const Center(
child: CircularProgressIndicator( child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(greenPrimary), valueColor: AlwaysStoppedAnimation<Color>(
greenPrimary),
), ),
); );
break; break;
case Status.completed: case Status.completed:
allKomentarPositngKegiatanFromApi = allKomentarPositngKegiatanFromApi = snapshot
snapshot.data.data.allKomentarKegiatan; // kalo error, brarti allKegiatan .data
.data
.allKomentarKegiatan; // kalo error, brarti allKegiatan
if (allKomentarPositngKegiatanFromApi.isEmpty) { if (allKomentarPositngKegiatanFromApi.isEmpty) {
return const Center( return const Center(
child: Text('Tidak ada komentar')); child: Text('Tidak ada komentar'));
} else { } else {
return Column( return Column(
children: allKomentarPositngKegiatanFromApi.map<Widget>((k) => children:
komentarKegiatanPlaceHolder( allKomentarPositngKegiatanFromApi
k.creator, k.created, k.deskripsi .map<Widget>((k) =>
) komentarKegiatanPlaceHolder(
).toList() k.creator,
); k.created,
k.deskripsi))
.toList());
} }
break; break;
case Status.error: case Status.error:
...@@ -312,8 +383,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -312,8 +383,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
} }
} }
return Container(); return Container();
} }),
),
const SizedBox(height: regularSpace), const SizedBox(height: regularSpace),
Form( Form(
key: _formKey, key: _formKey,
...@@ -429,17 +499,22 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -429,17 +499,22 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
final _namaLokasi = widget.lokasi.placeId; final _namaLokasi = widget.lokasi.placeId;
newKomentarPostingKegiatanData['deskripsi'] = komentarKegiatan; newKomentarPostingKegiatanData['deskripsi'] = komentarKegiatan;
newKomentarPostingKegiatanData['namaLokasi'] = _namaLokasi; newKomentarPostingKegiatanData['namaLokasi'] = _namaLokasi;
newKomentarPostingKegiatanData['id'] = widget.kegiatan.id; // ganti widget.x.id // sudah newKomentarPostingKegiatanData['id'] =
widget.kegiatan.id; // ganti widget.x.id // sudah
_bloc = KomentarPostingKegiatanBloc(_namaLokasi, widget.kegiatan.id); // ganti widget.x.id // sudah _bloc = KomentarPostingKegiatanBloc(
_namaLokasi, widget.kegiatan.id); // ganti widget.x.id // sudah
final response = await _bloc.addKomentarPostingKegiatan( final response = await _bloc.addKomentarPostingKegiatan(
newKomentarPostingKegiatanData, _namaLokasi, widget.kegiatan.id); // ganti widget.x.id // sudah newKomentarPostingKegiatanData,
_namaLokasi,
widget.kegiatan.id); // ganti widget.x.id // sudah
if (response['response'] == 'komentar added') { if (response['response'] == 'komentar added') {
successDialog(context); successDialog(context);
Timer(const Duration(seconds: 2), () { Timer(const Duration(seconds: 2), () {
Navigator.pop(context); Navigator.pop(context);
}); });
await _bloc.fetchKomentarPostingKegiatanList(_namaLokasi, widget.kegiatan.id); // ganti widget.x.id // sudah await _bloc.fetchKomentarPostingKegiatanList(
_namaLokasi, widget.kegiatan.id); // ganti widget.x.id // sudah
komentarKegiatanController.clear(); komentarKegiatanController.clear();
} else { } else {
failedDialog(context); failedDialog(context);
...@@ -470,7 +545,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> { ...@@ -470,7 +545,8 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
}); });
} }
Widget komentarKegiatanPlaceHolder(String name, DateTime created, String description) { Widget komentarKegiatanPlaceHolder(
String name, DateTime created, String description) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment