Fakultas Ilmu Komputer UI

Commit f9a04a8f authored by Putri Salsabila's avatar Putri Salsabila
Browse files

Merge branch 'dev-putsal' into 'PBI-12-info_kegiatan'

Finishing Add Kegiatan

See merge request !65
parents fd26348b 9e6a6916
Pipeline #81446 passed with stages
in 13 minutes and 39 seconds
......@@ -3,6 +3,5 @@ import 'package:intl/intl.dart';
class CustomSerializer {
static DateTime stringToDateTime(String date) {
return DateFormat('yyyy-MM-dd HH:mm').parse(date);
// return DateFormat('%Y-%m-%dT%H:%M').parse(date);
}
}
......@@ -99,11 +99,11 @@ const fasilitas = {
'TB': 'Tempat Parkir Biasa',
};
const zonaWaktu = {
'WIB': 'WIB',
'WITA': 'WITA',
'WIT': 'WIT',
};
const zonaWaktu = [
'WIB',
'WITA',
'WIT',
];
String getTag(String tag) {
return tags[tag];
......
......@@ -422,7 +422,6 @@ class AddInformasiState extends State<AddInformasi> {
.asUint8List();
newKomentarData['image'] =
MultipartFile.fromBytes(bytes, filename: 'kursiroda.jpg');
print('Fasilitas null dalem addinfo adalah: ' + _jenisFasilitas);
break;
case 'LF':
var bytes =
......@@ -520,7 +519,6 @@ class AddInformasiState extends State<AddInformasi> {
.asUint8List();
newKomentarData['image'] =
MultipartFile.fromBytes(bytes, filename: 'defaultDisable.png');
print('Fasilitas null default addinfo adalah: ' + _jenisFasilitas);
break;
}
} else {
......
......@@ -3,16 +3,16 @@ 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/strings.dart';
import 'package:bisaGo/config/styles.dart';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/utils/custom_button.dart';
// import 'package:bisaGo/utils/custom_dropdown.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/material.dart';
import 'package:flutter/widgets.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';
......@@ -47,8 +47,8 @@ class _AddKegiatanState extends State<AddKegiatan> {
TextEditingController linkController = TextEditingController();
String tanggalKegiatan =
'${DateFormat('yyyy-MM-ddTHH:mm').format(DateTime.now())}';
'${DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now())}';
String zonaCurrent = 'WIB';
List<Asset> images = <Asset>[];
bool permissionGranted = false;
......@@ -117,12 +117,21 @@ class _AddKegiatanState extends State<AddKegiatan> {
timeEnd: DateTime.parse(tanggalKegiatan).add(
Duration(days: 1),
),
zonaWaktu: zonaCurrent,
);
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;
newKegiatanData['zona_waktu'] = 'WIB';
if (images != null) {
for (var asset in images) {
......@@ -139,7 +148,7 @@ class _AddKegiatanState extends State<AddKegiatan> {
}
newKegiatanData['images'] ??= [''];
final _bloc = KegiatanBloc(widget.placeId);
await _bloc.addNewKegiatan(newKegiatanData);
......@@ -149,13 +158,13 @@ class _AddKegiatanState extends State<AddKegiatan> {
Navigator.pop(context);
});
} else {
failedDialog(context, '');
failedDialog(context, 'default');
}
}
void successDialog(BuildContext context) {
const alertDialog = AlertDialog(
title: Text('Tambah informasi berhasil'),
title: Text('Tambah kegiatan berhasil'),
content: Icon(FontAwesomeIcons.checkCircle),
);
showDialog(
......@@ -168,7 +177,7 @@ class _AddKegiatanState extends State<AddKegiatan> {
void failedDialog(BuildContext context, String message) {
var newMessage = message;
if (message == 'default') {
newMessage = 'Gagal menambahkan informasi';
newMessage = 'Gagal menambahkan kegiatan';
}
final alertDialog = AlertDialog(
title: Text(newMessage),
......@@ -223,7 +232,7 @@ class _AddKegiatanState extends State<AddKegiatan> {
}
}
Future _getStoragePermission() async {
Future _getStoragePermission() async {
if (await Permission.storage.request().isGranted) {
setState(() {
permissionGranted = true;
......@@ -279,56 +288,54 @@ class _AddKegiatanState extends State<AddKegiatan> {
Widget deskripsiField() {
return Container(
margin: const EdgeInsets.symmetric(vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: RichText(
key: Key('Deskripsi Kegiatan'),
text: TextSpan(
text: 'Deskripsi Kegiatan',
style: const TextStyle(
fontSize: 18, color: Colors.black, fontFamily: 'Muli'),
children: <TextSpan>[
const TextSpan(text: '*', style: TextStyle(color: red)),
],
),
),
),
TextFormField(
key: const Key('Text Field Deskripsi'),
keyboardType: TextInputType.multiline,
maxLines: null,
minLines: 3,
validator: FieldValidator.validateInfo,
controller: deskripsiController,
style: const TextStyle(
fontSize: 18,
),
decoration: InputDecoration(
hintStyle: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 15),
hintText: 'Tulis deskripsi...',
contentPadding: const EdgeInsets.all(8.0),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Theme.of(context).primaryColor,
margin: const EdgeInsets.symmetric(vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: RichText(
key: Key('Deskripsi Kegiatan'),
text: TextSpan(
text: 'Deskripsi Kegiatan',
style: const TextStyle(
fontSize: 18, color: Colors.black, fontFamily: 'Muli'),
children: <TextSpan>[
const TextSpan(text: '*', style: TextStyle(color: red)),
],
),
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Theme.of(context).primaryColor,
TextFormField(
key: const Key('Text Field Deskripsi'),
keyboardType: TextInputType.multiline,
maxLines: null,
minLines: 3,
validator: FieldValidator.validateInfo,
controller: deskripsiController,
style: const TextStyle(
fontSize: 18,
),
decoration: InputDecoration(
hintStyle: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 15),
hintText: 'Tulis deskripsi...',
contentPadding: const EdgeInsets.all(8.0),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Theme.of(context).primaryColor,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Theme.of(context).primaryColor,
),
),
),
),
),
),
]
)
);
]));
}
Widget penyelenggaraField() {
......@@ -346,9 +353,8 @@ class _AddKegiatanState extends State<AddKegiatan> {
return CustomTextField(
title: 'Nama Narahubung',
hint: 'Masukkan nama narahubung',
required: true,
required: false,
key: const Key('Text Field Nama Narahubung'),
validator: FieldValidator.validateName,
controller: namaKontakController,
);
}
......@@ -359,7 +365,7 @@ class _AddKegiatanState extends State<AddKegiatan> {
hint: 'Masukkan nomor telepon narahubung',
required: true,
key: const Key('Text Field Nomor Telepon Narahubung'),
validator: FieldValidator.validateName,
validator: FieldValidator.validateInfo,
controller: nomorKontakController,
);
}
......@@ -375,61 +381,88 @@ class _AddKegiatanState extends State<AddKegiatan> {
}
Widget tanggalKegiatanField() {
return Padding(
return Container(
padding: const EdgeInsets.only(bottom: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Column(
children: <Widget>[
SizedBox(height: 10.0),
Padding(
padding: const EdgeInsets.fromLTRB(0,0,20,10),
padding: const EdgeInsets.fromLTRB(0, 0, 70, 10),
child: const Text(
'Tanggal Kegiatan',
'Tanggal & Waktu Kegiatan',
style: TextStyle(fontSize: 18),
textAlign: TextAlign.left,
),
),
TextButton(
key: const Key('Button Tanggal Kegiatan'),
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
padding: const EdgeInsets.all(13.0),
backgroundColor: greenPrimary,
),
onPressed: () {
DatePicker.showDateTimePicker(
context,
currentTime: DateTime.parse(tanggalKegiatan),
onChanged: (date) {
setState(() {
tanggalKegiatan =
'${DateFormat('yyyy-MM-ddTHH:mm').format(date)}';
});
},
);
},
child: Text(
tanggalKegiatan,
style: const TextStyle(
fontSize: 15.0, color: Colors.white),
Row(children: <Widget>[
// SizedBox(
// width: 186.0,
Expanded(
child: TextButton(
key: const Key('Button Tanggal & Waktu Kegiatan'),
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
padding: const EdgeInsets.all(13.0),
backgroundColor: Colors.transparent,
side: BorderSide(color: greenPrimary),
),
onPressed: () {
DatePicker.showDateTimePicker(
context,
currentTime: DateTime.parse(tanggalKegiatan),
onChanged: (date) {
setState(() {
tanggalKegiatan =
'${DateFormat('yyyy-MM-dd HH:mm').format(date)}';
});
},
);
},
child: Row(children: <Widget>[
Icon(
Icons.calendar_today,
size: 20,
color: Colors.green,
),
SizedBox(width: 10.0),
Text(
tanggalKegiatan,
style:
const TextStyle(fontSize: 15.0, color: Colors.black),
),
])
),
),
),
// CustomDropdown(
// title: 'Fasilitas / Layanan',
// key: const Key('Dropdown Fasilitas Layanan'),
// dropdownList: zonaWaktu,
// validator: FieldValidator.validateDropdown,
// hint: 'Pilih fasilitas / layanan',
// onChanged: (value) {
// setState(() {
// _blombikinstringnya = value;
// });
// }),
SizedBox(width: 15.0),
zonaWaktuChoice(),
]),
],
),
);
}
Widget zonaWaktuChoice() {
return DropdownButton<String>(
value: zonaCurrent,
underline: Container(
height: 1,
color: Colors.green,
),
items: zonaWaktu.map((String zona) {
return DropdownMenuItem<String>(
value: zona,
child: Text(zona),
);
}).toList(),
onChanged: (String zonaSelected) {
setState(() {
zonaCurrent = zonaSelected;
});
},
);
}
Widget fotoField() {
return Padding(
padding: const EdgeInsets.only(bottom: 16),
......@@ -450,7 +483,6 @@ class _AddKegiatanState extends State<AddKegiatan> {
onPressed: () async {
await pickImages();
},
child: Container(
// width: MediaQuery.of(context).size.width * 0.35,
padding: const EdgeInsets.all(9.0),
......@@ -469,8 +501,7 @@ class _AddKegiatanState extends State<AddKegiatan> {
const SizedBox(width: regularSpace),
const Text(
'Tambah foto ',
style: TextStyle(
color: Colors.white, fontSize: 14.0),
style: TextStyle(color: Colors.white, fontSize: 14.0),
),
],
),
......@@ -483,21 +514,18 @@ class _AddKegiatanState extends State<AddKegiatan> {
Widget simpanButton() {
return Container(
margin: const EdgeInsets.only(top: doubleSpace),
alignment: Alignment.center,
child: ButtonTheme(
key: const Key('Button Simpan'),
minWidth: double.infinity,
height: 40,
child: submitButton('Simpan', _submitData),
)
);
margin: const EdgeInsets.only(top: doubleSpace),
alignment: Alignment.center,
child: ButtonTheme(
key: const Key('Button Simpan'),
minWidth: double.infinity,
height: 40,
child: submitButton('Simpan', _submitData),
));
}
Widget _showImagePreview() {
return images.isEmpty
? const SizedBox(height: 0)
: carousel();
return images.isEmpty ? const SizedBox(height: 0) : carousel();
}
Widget carousel() {
......@@ -505,58 +533,57 @@ class _AddKegiatanState extends State<AddKegiatan> {
width: MediaQuery.of(context).size.width,
height: 160,
child: CarouselSlider(
options: CarouselOptions(
aspectRatio: 1.0,
enlargeCenterPage: true,
enableInfiniteScroll: false,
initialPage: 0,
autoPlay: true,
),
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(),
),
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)
options: CarouselOptions(
aspectRatio: 1.0,
enlargeCenterPage: true,
enableInfiniteScroll: false,
initialPage: 0,
autoPlay: true,
),
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(),
),
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(
'#${images.indexOf(item) + 1}',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
),
],
begin:
Alignment.bottomCenter,
end: Alignment.topCenter,
),
),
padding: EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 20.0),
child: Text(
'#${images.indexOf(item) + 1}',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
)),
),
],
)
),
),
).toList()),
)
.toList()),
);
}
}
......@@ -89,7 +89,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: MediaQuery.of(context).size.width * 0.6,
width: MediaQuery.of(context).size.width * 0.8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
......@@ -220,7 +220,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
.toList(),
),
),
const SizedBox(height: 10),
SizedBox(height: 10),
Container(
key: const Key('desc'),
padding: const EdgeInsets.all(doubleSpace),
......@@ -237,12 +237,12 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
SizedBox(height: 20),
Row(
children: [
const Icon(
Icon(
Icons.calendar_today,
size: 20,
color: Colors.green,
),
const SizedBox(width: 15),
SizedBox(width: 15),
Text(
'${DateFormat('EEEEEE, dd MMM yyy').format(widget.kegiatan.timeStart)}',
style: TextStyle(fontSize: 16),
......@@ -253,41 +253,49 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
SizedBox(height: 15),
Row(
children: [
const Icon(
Icon(
Icons.access_time,
size: 20,
color: Colors.green,
),
const SizedBox(width: 15),
SizedBox(width: 15),
Text(
'${DateFormat('hh:mm').format(widget.kegiatan.timeStart)}',
'${DateFormat('HH:mm').format(widget.kegiatan.timeStart)}',
style: TextStyle(fontSize: 16),
key: Key('Text Waktu Pelaksanaan'),
),
SizedBox(width: 3.0),
Text(
widget.kegiatan.zonaWaktu,
style: TextStyle(fontSize: 16),
key: Key('Text Zona Waktu Pelaksanaan'),
)
],
),
Row(
children: [
const Icon(
Icon(