Fakultas Ilmu Komputer UI

Commit 3c0a7702 authored by Usman Sidiq's avatar Usman Sidiq
Browse files

[CHORES] Fix conflict

parents 80780510 7997ad24
Pipeline #42392 failed with stages
in 11 minutes and 59 seconds
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}]}
\ No newline at end of file
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}]}
\ No newline at end of file
......@@ -41,5 +41,12 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<!-- image picker -->
<key>NSPhotoLibraryUsageDescription</key>
<string>Need to upload image</string>
<key>NSCameraUsageDescription</key>
<string>Need to upload image</string>
<key>NSMicrophoneUsageDescription</key>
<string>Need to upload image</string>
</dict>
</plist>
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/page/dashboard/dashboard.dart';
//import 'package:ppl_disabilitas/page/addInformasi/addInfromasi.dart';
class BisaGo extends StatelessWidget {
@override
......
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/page/filter_fasilitas/fasilitas.dart';
import 'package:ppl_disabilitas/utils/customDeskripsiField.dart';
import 'package:ppl_disabilitas/utils/customButton.dart';
import 'package:ppl_disabilitas/utils/validator.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smooth_star_rating/smooth_star_rating.dart';
import 'package:image_picker/image_picker.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class AddInformasi extends StatefulWidget{
final String nama;
AddInformasiState createState() => AddInformasiState();
AddInformasi({this.nama});
}
class AddInformasiState extends State<AddInformasi> {
File _image;
TextEditingController deskripsiController = TextEditingController();
var rating = 0.0;
var tag = '';
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Map<String, bool> fasilitas = {
'Kursi Roda': false,
'Lift Disabilitas': false,
'Toilet Disabilitas': false,
'Masjid/Mushola': false,
'Guiding Block': false,
'Bidang Miring': false,
'Teman Disabilitas': false,
'Juru Bahasa Isyarat': false,
'Tongkat Disabilitas Netra':false,
'Kursi Umum Disabilitas': false,
'Tempat Parkir Disabilitas': false,
'Running Text': false,
'Tempat Parkir Biasa' : false,
};
Map<String, String> tags = {
'Kursi Roda': 'KD',
'Lift Disabilitas': 'LF',
'Toilet Disabilitas': 'TD',
'Masjid/Mushola': 'MM',
'Guiding Block': 'GB',
'Bidang Miring': 'BM',
'Teman Disabilitas': 'CP',
'Juru Bahasa Isyarat': 'JI',
'Tongkat Disabilitas Netra':'TN',
'Kursi Umum Disabilitas': 'KD',
'Tempat Parkir Disabilitas': 'PK',
'Running Text': 'RT',
'Tempat Parkir Biasa' : 'TB',
};
Future _getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
setState(() {
_image = image;
print('_image : $_image');
});
}
Future _clearImage() async {
setState(() {
_image = null;
print('_image : $_image');
});
}
Future _clearCheckBox() async{
fasilitas.forEach((k, v) {
var key = k;
fasilitas[key]=false;
});
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Tambah Informasi'),
centerTitle: true,
backgroundColor: Color(0xff3A903A),
),
body: SingleChildScrollView(
child: Form(
key: _formKey,
child: Container(
margin: EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: 20),
Text("Foto Fasilitas",style: TextStyle(fontSize: 18),textAlign: TextAlign.left,),
GridView.count(
key: Key('Input Gambar'),
shrinkWrap: true,
primary: false,
padding: const EdgeInsets.all(10),
crossAxisSpacing: 10,
crossAxisCount: 2,
children: <Widget>[
GestureDetector(
onTap: _getImage,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 2.0),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(20.0),
topRight: const Radius.circular(20.0),
bottomLeft: const Radius.circular(20.0),
bottomRight: const Radius.circular(20.0),
),
color: Colors.black12,
),
child: _image == null ? Icon(FontAwesomeIcons.plus) : Image.file(_image),
),
)
],
),
CustomDeskripsiField(
title: 'Informasi Fasilitas',
key: Key('Text Field Informasi'),
onSaved: (input) {
},
validator: FieldValidator.validateInfo,
controller: deskripsiController,
),
SizedBox(height: 20),
Text("Tag Pencarian",style: TextStyle(fontSize: 18),textAlign: TextAlign.left,),
ListView(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
key: Key('Checkbox Fasilitas'),
children: fasilitas.keys.map((String key) {
return new CheckboxListTile(
title: Text(key),
value: fasilitas[key],
onChanged: (bool value) {
setState(() {
fasilitas[key] = value;
});
},
);
}).toList(),
),
SizedBox(height: 20),
Container(
alignment: Alignment.center,
key: Key('Star Rating'),
child: SmoothStarRating(
allowHalfRating: false,
onRatingChanged: (v) {
rating = v;
setState(() {});
},
starCount: 5,
rating: rating,
size: 40.0,
filledIconData: Icons.star,
halfFilledIconData: Icons.star_half,
color: Colors.green,
borderColor: Colors.green,
spacing:0.0,
),
),
Container(
margin: EdgeInsets.fromLTRB(0, 30, 0, 10),
alignment: Alignment.center,
child: Row(
children: <Widget>[
Expanded(
child: ButtonTheme(
key: Key("Batal Button"),
minWidth: double.infinity,
height: 40,
child: RaisedButton(
padding: EdgeInsets.symmetric(vertical: 15),
highlightElevation: 0.0,
splashColor: Color(0xff3A903A),
highlightColor: Color(0xff3A903A),
elevation: 0.0,
color: Colors.white70,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.all(Radius.circular(10)),
side: BorderSide(color: Color(0xff3A903A))
),
child: Text(
'Batal',
style: TextStyle(fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold),
),
onPressed: (){
_resetInput();
}
),
),
),
SizedBox(width: 5,),
Expanded(
child : ButtonTheme(
key: Key("Simpan Button"),
minWidth: double.infinity,
height: 40,
child: submitButton(
'Simpan', Color(0xff3A903A), Colors.white,
Color(0xff3A903A), Colors.white, _validateInformationInput),
),
),
],
),
),
],
),
),
)
)
);
}
addInfo(String tag, String deskripsi, String rating) async {
for(MapEntry<String, bool> me in fasilitas.entries)
if(me.value == true) tag = tag + tags[me.key] + ' ';
Map data = {
'tag': tag,
'deskripsi': deskripsi,
'rating' : rating,
};
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
String namaTempat = widget.nama;
var response = await http.post(
'http://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/add-fasilitas/$namaTempat/',
headers: {"Authorization" : "token " + sharedPreferences.getString("token")},
body: data);
Map<String, dynamic> test = jsonDecode(response.body);
String testing = test['response'];
// var response = await http.get('http://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list-fasilitas/$namaTempat/');
if (response.statusCode == 201) {
print(response.body);
inputData(context);
}
else {
print(sharedPreferences.getString("token"));
print(namaTempat);
print(response.statusCode);
print(data);
print(testing);
inputData(context);
}
}
void inputData(BuildContext context){
var alertDialog = AlertDialog(
title: Text('Tambah Informasi berhasil'),
content: Icon(FontAwesomeIcons.checkCircle),
);
showDialog(
context: context,
builder: (BuildContext context){
return alertDialog;
}
);
}
void _validateInformationInput() async {
final FormState form = _formKey.currentState;
if(_formKey.currentState.validate()) {
form.save();
int ratingInt = rating.toInt();
await addInfo(tag, deskripsiController.text.toString(), ratingInt.toString());
}
}
void _resetInput() async{
deskripsiController.clear();
rating = 0.0;
_clearImage();
_clearCheckBox();
}
}
\ No newline at end of file
......@@ -5,8 +5,11 @@ import 'package:ppl_disabilitas/component/bisago_appbar.dart';
import 'package:ppl_disabilitas/component/bisago_drawer.dart';
import 'package:ppl_disabilitas/config/styles.dart';
import 'package:ppl_disabilitas/network/data/network_model.dart';
import 'package:ppl_disabilitas/page/addInformasi/addInfromasi.dart';
import 'package:ppl_disabilitas/page/filter_fasilitas/komentar.dart';
import 'package:ppl_disabilitas/model/komentar.dart';
import 'package:ppl_disabilitas/page/login/login.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Fasilitas extends StatefulWidget {
final String nama;
......@@ -135,7 +138,7 @@ class _FasilitasState extends State<Fasilitas> {
side: BorderSide(color: Colors.transparent)),
splashColor: Colors.lightGreen,
onPressed: () {
/*...*/
checkLoginStatus();
},
child: Text(
"Tambah Informasi",
......@@ -943,4 +946,19 @@ class _FasilitasState extends State<Fasilitas> {
showUrutan = true;
super.dispose();
}
checkLoginStatus() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if(sharedPreferences.getString("token") == null) {
await Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (BuildContext context) => Login()), (Route<dynamic> route) => false);
}
else {
await Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => AddInformasi(
nama: widget.nama,
)));
}
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class CustomDeskripsiField extends StatelessWidget {
CustomDeskripsiField(
{ this.title,
this.hint,
this.obsecure = false,
this.key,
this.validator,
this.controller,
this.onSaved});
final String title;
final Key key;
final FormFieldSetter<String> onSaved;
final String hint;
final bool obsecure;
final FormFieldValidator<String> validator;
final TextEditingController controller;
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
title,
style: TextStyle(fontSize: 18),
),
SizedBox(
height: 10,
),
TextFormField(
keyboardType: TextInputType.multiline,
maxLines: null,
onSaved: onSaved,
validator: validator,
controller: controller,
autofocus: true,
obscureText: obsecure,
style: TextStyle(
fontSize: 15,
),
decoration: InputDecoration(
hintStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
hintText: hint,
contentPadding: EdgeInsets.all(8.0),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Theme.of(context).primaryColor,
width: 1,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Theme.of(context).primaryColor,
width: 1,
),
),
),
),
],
),
);
}
}
......@@ -65,4 +65,4 @@ class CustomTextField extends StatelessWidget {
),
);
}
}
\ No newline at end of file
}
......@@ -41,4 +41,10 @@ class FieldValidator {
return null;
}
}
static String validateInfo(String value) {
if (value.isEmpty) return '*Wajib diisi';
else
return null;
}
}
\ No newline at end of file
......@@ -32,6 +32,9 @@ dependencies:
json_serializable: ^3.2.5
cached_network_image: ^2.0.0
shared_preferences: 0.5.6+3
smooth_star_rating: ^1.0.4+2
image_picker: ^0.6.5
font_awesome_flutter: ^8.8.1
dev_dependencies:
flutter_test:
......
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/utils/validator.dart';
import 'package:ppl_disabilitas/page/addInformasi/addInfromasi.dart';
void main(){
testWidgets('Test Input Gambar', (WidgetTester tester) async {
final testInputImage = Key("Input Gambar");
await tester.pumpWidget(MaterialApp(home: AddInformasi()));
expect(find.byKey(testInputImage), findsOneWidget);
});
testWidgets('Info Text Field Test', (WidgetTester tester) async {
final textFieldKey = Key("Text Field Informasi");
await tester.pumpWidget(MaterialApp(home: AddInformasi()));
expect(find.byKey(textFieldKey), findsOneWidget);
});
testWidgets('Checkbox Fasilitas Test', (WidgetTester tester) async {
final checkBoxKey = Key("Checkbox Fasilitas");
await tester.pumpWidget(MaterialApp(home: AddInformasi()));
expect(find.byKey(checkBoxKey), findsOneWidget);
});
testWidgets('Star Rating Exist Test', (WidgetTester tester) async {
final starKey = Key("Star Rating");
await tester.pumpWidget(MaterialApp(home: AddInformasi()));
expect(find.byKey(starKey), findsOneWidget);
});
testWidgets('Simpan Button Test', (WidgetTester tester) async {
final simpanKey = Key("Simpan Button");
await tester.pumpWidget(MaterialApp(home: AddInformasi()));
expect(find.byKey(simpanKey), findsOneWidget);
});
testWidgets('Batal Button Test', (WidgetTester tester) async {
final batalKey = Key("Batal Button");
await tester.pumpWidget(MaterialApp(home: AddInformasi()));
expect(find.byKey(batalKey), findsOneWidget);
});
test('Empty Info Test', () {
var result = FieldValidator.validateInfo('');
expect(result, '*Wajib diisi');
});
test('Valid Info Test', () {
var result = FieldValidator.validateInfo('Margo city punya kursi roda');
expect(result, null);
});
test('Star rating start from zero', (){
var info = AddInformasiState();
expect(info.rating, 0.0);
});
}
\ No newline at end of file
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