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
3464f6b8
Commit
3464f6b8
authored
Jun 06, 2021
by
Putri Salsabila
Browse files
[WIP] Create Ubah Kegiatan form
parent
9e6a6916
Pipeline
#81474
passed with stages
in 13 minutes and 28 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/page/filter_fasilitas/add_kegiatan.dart
View file @
3464f6b8
...
...
@@ -314,7 +314,7 @@ class _AddKegiatanState extends State<AddKegiatan> {
validator:
FieldValidator
.
validateInfo
,
controller:
deskripsiController
,
style:
const
TextStyle
(
fontSize:
1
8
,
fontSize:
1
5
,
),
decoration:
InputDecoration
(
hintStyle:
const
TextStyle
(
...
...
lib/page/filter_fasilitas/postingan/detail_post_kegiatan.dart
View file @
3464f6b8
...
...
@@ -22,6 +22,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import
'package:url_launcher/url_launcher.dart'
;
import
'../fasilitas.dart'
;
import
'../update_kegiatan.dart'
;
class
DetailPostKegiatanPage
extends
StatefulWidget
{
final
Lokasi
lokasi
;
...
...
@@ -89,7 +90,7 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Container
(
width:
MediaQuery
.
of
(
context
)
.
size
.
width
*
0.
8
,
width:
MediaQuery
.
of
(
context
)
.
size
.
width
*
0.
7
,
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
...
...
@@ -111,35 +112,35 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
],
),
),
//
PopupMenuButton(
//
key: const Key('Button Ubah
Informasi
'),
//
elevation: 4.0,
//
offset: const Offset(0.0, 40.0),
//
itemBuilder: (BuildContext context) {
//
final choices = ['Ubah
Informasi
'];
//
return choices.map((String choice) {
//
return PopupMenuItem(
//
key: Key(choice),
//
child: ElevatedButton(
//
style: ButtonStyle(
//
padding: MaterialStateProperty.all(
//
EdgeInsets.symmetric(
//
vertical: 0, horizontal: 0)),
//
backgroundColor:
//
MaterialStateProperty.all(Colors.white),
//
foregroundColor:
//
MaterialStateProperty.all(Colors.black),
//
elevation: MaterialStateProperty.all(0)),
//
onPressed:
_
update
Informasi
,
//
child: SizedBox(
//
width: double.infinity,
//
child: Text(choice),
//
),
//
),
//
);
//
}).toList();
//
},
//
),
PopupMenuButton
(
key:
const
Key
(
'Button Ubah
Kegiatan
'
),
elevation:
4.0
,
offset:
const
Offset
(
0.0
,
40.0
),
itemBuilder:
(
BuildContext
context
)
{
final
choices
=
[
'Ubah
Kegiatan
'
];
return
choices
.
map
((
String
choice
)
{
return
PopupMenuItem
(
key:
Key
(
choice
),
child:
ElevatedButton
(
style:
ButtonStyle
(
padding:
MaterialStateProperty
.
all
(
EdgeInsets
.
symmetric
(
vertical:
0
,
horizontal:
0
)),
backgroundColor:
MaterialStateProperty
.
all
(
Colors
.
white
),
foregroundColor:
MaterialStateProperty
.
all
(
Colors
.
black
),
elevation:
MaterialStateProperty
.
all
(
0
)),
onPressed:
update
Kegiatan
,
child:
SizedBox
(
width:
double
.
infinity
,
child:
Text
(
choice
),
),
),
);
})
.
toList
();
},
),
],
),
),
...
...
@@ -659,19 +660,20 @@ class _DetailPostKegiatanPageState extends State<DetailPostKegiatanPage> {
return
initials
;
}
// Future<void> _updateInformasi() async {
// final sharedPreferences = await SharedPreferences.getInstance();
// if (sharedPreferences.getString('token') == null) {
// await Navigator.of(context).pushAndRemoveUntil(
// MaterialPageRoute(builder: (BuildContext context) => const Login()),
// (Route<dynamic> route) => false);
// } else {
// await Navigator.of(context).push(MaterialPageRoute(
// builder: (BuildContext context) => UpdateInformasi(
// komentar: widget.komentar, lokasi: widget.lokasi) // ganti modelnya di update_informasi.dart
// ));
// }
// }
Future
<
void
>
updateKegiatan
()
async
{
final
sharedPreferences
=
await
SharedPreferences
.
getInstance
();
if
(
sharedPreferences
.
getString
(
'token'
)
==
null
)
{
await
Navigator
.
of
(
context
)
.
pushAndRemoveUntil
(
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=
>
const
Login
()),
(
Route
<
dynamic
>
route
)
=
>
false
);
}
else
{
await
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=
>
UpdateKegiatan
(
kegiatan:
widget
.
kegiatan
,
lokasi:
widget
.
lokasi
)
));
}
}
@override
void
dispose
()
{
...
...
lib/page/filter_fasilitas/update_kegiatan.dart
View file @
3464f6b8
import
'package:bisaGo/component/bisago_appbar.dart'
;
import
'package:bisaGo/config/strings.dart'
;
import
'package:bisaGo/config/styles.dart'
;
import
'package:bisaGo/model/kegiatan.dart'
;
import
'package:bisaGo/model/lokasi.dart'
;
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: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:image_picker/image_picker.dart'
;
import
'package:intl/intl.dart'
;
import
'package:material_design_icons_flutter/material_design_icons_flutter.dart'
;
import
'package:multi_image_picker/multi_image_picker.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
class
UpdateKegiatan
extends
StatefulWidget
{
UpdateKegiatan
({
Key
key
,
@required
this
.
kegiatan
,
@required
this
.
placeId
,
@required
this
.
lokasi
,
})
:
super
(
key:
key
);
final
KegiatanModel
kegiatan
;
final
Lokasi
placeId
;
final
Lokasi
lokasi
;
@override
_UpdateKegiatanState
createState
()
=
>
_UpdateKegiatanState
();
}
class
_UpdateKegiatanState
extends
State
<
UpdateKegiatan
>
{
//
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final
GlobalKey
<
FormState
>
_formKey
=
GlobalKey
<
FormState
>();
TextEditingController
namaKegiatanController
=
TextEditingController
();
TextEditingController
penyelenggaraController
=
TextEditingController
();
...
...
@@ -38,11 +51,489 @@ class _UpdateKegiatanState extends State<UpdateKegiatan> {
void
initState
()
{
super
.
initState
();
// TODO: write init state i guess
namaKegiatanController
=
TextEditingController
(
text:
widget
.
kegiatan
.
namaKegiatan
);
penyelenggaraController
=
TextEditingController
(
text:
widget
.
kegiatan
.
penyelenggara
);
deskripsiController
=
TextEditingController
(
text:
widget
.
kegiatan
.
deskripsi
);
namaKontakController
=
TextEditingController
(
text:
widget
.
kegiatan
.
namaKontak
);
nomorKontakController
=
TextEditingController
(
text:
widget
.
kegiatan
.
nomorKontak
);
linkController
=
TextEditingController
(
text:
widget
.
kegiatan
.
links
);
// tanggalKegiatan = '${DateFormat('${widget.kegiatan.timeStart}').format(DateTime.now())}';
tanggalKegiatan
=
'
${widget.kegiatan.timeStart}
'
;
zonaCurrent
=
widget
.
kegiatan
.
zonaWaktu
;
}
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
throw
UnimplementedError
();
return
Scaffold
(
appBar:
PreferredSize
(
preferredSize:
const
Size
.
fromHeight
(
55
),
child:
BisaGoAppBar
(
title:
'Ubah Kegiatan'
,
leading:
InkWell
(
onTap:
()
=
>
Navigator
.
pop
(
context
,
'Take me back'
),
child:
const
Icon
(
Icons
.
arrow_back_ios
),
),
),
),
body:
SingleChildScrollView
(
child:
Form
(
key:
_formKey
,
child:
Stack
(
children:
<
Widget
>[
Container
(
key:
const
Key
(
'Body Add Kegiatan Page'
),
alignment:
Alignment
.
topCenter
,
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
)
.
size
.
height
*
.
04
,
left:
tripleSpace
,
right:
tripleSpace
,
bottom:
tripleSpace
),
child:
ListBody
(
children:
<
Widget
>[
namaLokasi
(),
namaKegiatanField
(),
deskripsiField
(),
penyelenggaraField
(),
namaKontakField
(),
nomorKontakField
(),
linkField
(),
tanggalKegiatanField
(),
fotoField
(),
_showImagePreview
(),
simpanButton
(),
],
),
),
],
),
),
),
);
// throw UnimplementedError();
}
Future
<
void
>
_submitData
()
async
{
// TODO: implement submit data
// final form = _formKey.currentState;
// if (_formKey.currentState.validate()) {
// form.save();
// }
}
void
successDialog
(
BuildContext
context
)
{
const
alertDialog
=
AlertDialog
(
title:
Text
(
'Ubah kegiatan berhasil'
),
content:
Icon
(
FontAwesomeIcons
.
checkCircle
),
);
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
alertDialog
;
});
}
void
failedDialog
(
BuildContext
context
,
String
message
)
{
var
newMessage
=
message
;
if
(
message
==
'default'
)
{
newMessage
=
'Gagal mengubah kegiatan'
;
}
final
alertDialog
=
AlertDialog
(
title:
Text
(
newMessage
),
content:
const
Icon
(
FontAwesomeIcons
.
exclamationCircle
,
),
);
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
alertDialog
;
});
}
final
picker
=
ImagePicker
();
Future
<
void
>
pickImages
()
async
{
var
resultList
=
<
Asset
>[];
await
_getStoragePermission
();
await
_getCameraPermission
();
try
{
if
(
permissionGranted
)
{
resultList
=
await
MultiImagePicker
.
pickImages
(
maxImages:
50
,
enableCamera:
true
,
selectedAssets:
images
,
materialOptions:
MaterialOptions
(
actionBarTitle:
widget
.
lokasi
.
name
,
// tdnya widget.nama
actionBarColor:
'#ff3A903A'
,
statusBarColor:
'#ff347D34'
,
useDetailsView:
true
,
startInAllView:
true
,
textOnNothingSelected:
'Tidak ada gambar yang dipilih'
,
),
);
setState
(()
{
images
=
resultList
;
});
}
else
{
await
openAppSettings
();
}
}
on
Exception
catch
(
e
)
{
print
(
e
);
}
}
Future
_getStoragePermission
()
async
{
if
(
await
Permission
.
storage
.
request
()
.
isGranted
)
{
setState
(()
{
permissionGranted
=
true
;
});
}
else
if
(
await
Permission
.
storage
.
request
()
.
isPermanentlyDenied
)
{
await
openAppSettings
();
}
else
if
(
await
Permission
.
storage
.
request
()
.
isDenied
)
{
setState
(()
{
permissionGranted
=
false
;
});
}
}
Future
_getCameraPermission
()
async
{
if
(
await
Permission
.
camera
.
request
()
.
isGranted
)
{
setState
(()
{
permissionGranted
=
true
;
});
}
else
if
(
await
Permission
.
camera
.
request
()
.
isPermanentlyDenied
)
{
await
openAppSettings
();
}
else
if
(
await
Permission
.
camera
.
request
()
.
isDenied
)
{
setState
(()
{
permissionGranted
=
false
;
});
}
}
Widget
namaLokasi
()
{
return
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
doubleSpace
),
child:
Text
(
widget
.
lokasi
.
name
,
style:
const
TextStyle
(
fontSize:
28
,
fontWeight:
FontWeight
.
w800
,
color:
Colors
.
black
,
fontFamily:
'Comfortaa'
,
),
),
);
}
Widget
namaKegiatanField
()
{
return
CustomTextField
(
title:
'Nama Kegiatan'
,
hint:
'Masukkan nama kegiatan'
,
required
:
true
,
key:
const
Key
(
'Text Field Nama'
),
validator:
FieldValidator
.
validateName
,
controller:
namaKegiatanController
,
);
}
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:
15
,
),
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
()
{
return
CustomTextField
(
title:
'Penyelenggara'
,
hint:
'Masukkan nama penyelenggara'
,
required
:
true
,
key:
const
Key
(
'Text Field Penyelenggara'
),
validator:
FieldValidator
.
validateName
,
controller:
penyelenggaraController
,
);
}
Widget
namaKontakField
()
{
return
CustomTextField
(
title:
'Nama Narahubung'
,
hint:
'Masukkan nama narahubung'
,
required
:
false
,
key:
const
Key
(
'Text Field Nama Narahubung'
),
controller:
namaKontakController
,
);
}
Widget
nomorKontakField
()
{
return
CustomTextField
(
title:
'Nomor Telepon Narahubung'
,
hint:
'Masukkan nomor telepon narahubung'
,
required
:
true
,
key:
const
Key
(
'Text Field Nomor Telepon Narahubung'
),
validator:
FieldValidator
.
validateInfo
,
controller:
nomorKontakController
,
);
}
Widget
linkField
()
{
return
CustomTextField
(
title:
'Link Kegiatan'
,
hint:
'Masukkan link kegiatan (jika ada)'
,
required
:
false
,
key:
const
Key
(
'Text Field Link Kegiatan'
),
controller:
linkController
,
);
}
Widget
tanggalKegiatanField
()
{
return
Container
(
padding:
const
EdgeInsets
.
only
(
bottom:
16
),
child:
Column
(
children:
<
Widget
>[
SizedBox
(
height:
10.0
),
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
0
,
70
,
10
),
child:
const
Text
(
'Tanggal & Waktu Kegiatan'
,
style:
TextStyle
(
fontSize:
18
),
textAlign:
TextAlign
.
left
,
),
),
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
),
),
])
),
),
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
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
only
(
right:
doubleSpace
),
child:
const
Text
(
'Foto'
,
style:
TextStyle
(
fontSize:
18
),
textAlign:
TextAlign
.
left
,
),
),
TextButton
(
key:
const
Key
(
'Button Input Foto Gallery'
),
style:
TextButton
.
styleFrom
(
padding:
EdgeInsets
.
zero
),
onPressed:
()
async
{
await
pickImages
();
},
child:
Container
(
// width: MediaQuery.of(context).size.width * 0.35,
padding:
const
EdgeInsets
.
all
(
9.0
),
alignment:
Alignment
.
centerLeft
,
decoration:
BoxDecoration
(
boxShadow:
regularShadow
,
borderRadius:
BorderRadius
.
circular
(
10.0
),
color:
greenPrimary
),
child:
Row
(
children:
[
const
Icon
(
MdiIcons
.
imagePlus
,
color:
Colors
.
white
,
size:
14.0
,
),
const
SizedBox
(
width:
regularSpace
),
const
Text
(
'Tambah foto '
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
14.0
),
),
],
),
),
),
],
),
);
}
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
),
));
}
Widget
_showImagePreview
()
{