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