Fakultas Ilmu Komputer UI

Commit 922f9ab5 authored by Adzkia Aisyah Afrah Hardian's avatar Adzkia Aisyah Afrah Hardian
Browse files

Merge branch 'dev-afrah' into 'PBI-2-pencarian_lokasi'

Dev afrah

See merge request !25
parents 0fd8667f 3e55ef16
Pipeline #38302 failed with stages
in 3 minutes and 14 seconds
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"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":[]}],"date_created":"2020-03-25 22:33:34.112007","version":"1.15.17"}
\ 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":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]}]}
\ No newline at end of file
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/bloc/LokasiResponseBloc.dart';
import 'package:ppl_disabilitas/config/styles.dart';
import 'package:ppl_disabilitas/model/lokasi.dart';
import 'package:ppl_disabilitas/network/data/network_model.dart';
import 'package:ppl_disabilitas/network/network_interface.dart';
/// Create Pencarian page widget with a state
class Pencarian extends StatefulWidget {
@override
PencarianState createState() => PencarianState();
}
/// State of Pencacrian page
class PencarianState extends State<Pencarian> {
/// Controller for textFormField
TextEditingController myController = TextEditingController();
/// Search Icon for textFormField
Icon searchIcon = Icon(Icons.search);
Widget appBarText = Text("Pencarian Lokasi");
LokasiResponseBloc _bloc = LokasiResponseBloc();
LokasiListResponse lokasiFromApi;
LokasiListResponse recentSearch;
/// Text for appbar
Widget appBarText = Text('Pencarian Lokasi');
/// To get API of places
NetworkInterface networkInterface = NetworkInterface();
/// List for places from API
List places = [];
/// List of places currently searched on the textFormField
List currentSearch = [];
/// Data from API
Future<NetworkModel> data;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties..add(DiagnosticsProperty<List>('places', places))
..add(DiagnosticsProperty<List>('currentSearch', currentSearch))
..add(DiagnosticsProperty<NetworkInterface>('networkInterface', networkInterface));
}
@override
void initState() {
data = networkInterface.get(
url: 'https://my.api.mockaroo.com/mall.json?key=dbcde960');
myController.addListener(() {
List tempList = [];
for (int i = 0; i < places.length; i++) {
if (places[i]['nama']
.toLowerCase()
.contains(myController.text.toLowerCase())) {
tempList.add(places[i]);
}
}
setState(() {
currentSearch = tempList;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: greenPrimary,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios, size: 25),
key: Key("Back Icon Key"),
onPressed: () => Navigator.pop(context, 'Take me back')),
title: Container(
margin: EdgeInsets.only(top: doubleSpace, bottom: doubleSpace),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: doubleBorderRadius,
boxShadow: regularShadow),
child: TextFormField(
key: Key("Text Field Mau Kemana"),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(0),
isDense: false,
prefixIcon: Icon(
Icons.search,
color: greenPrimary,
size: 25,
),
border: InputBorder.none,
fillColor: Colors.white,
labelText: 'Kamu mau kemana?',
labelStyle: TextStyle(
appBar: AppBar(
backgroundColor: greenPrimary,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios, size: 25),
key: Key('Back Icon Key'),
onPressed: () => Navigator.pop(context, 'Take me back')),
title: Container(
margin: EdgeInsets.only(top: doubleSpace, bottom: doubleSpace),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: doubleBorderRadius,
boxShadow: regularShadow),
child: TextFormField(
controller: myController,
key: Key('Text Field Mau Kemana'),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(0),
isDense: false,
prefixIcon: Icon(
Icons.search,
color: greenPrimary,
fontSize: 18,
fontFamily: 'Muli',
fontWeight: FontWeight.w700),
suffixIcon: IconButton(
size: 25,
),
border: InputBorder.none,
fillColor: Colors.white,
labelText: 'Kamu mau kemana?',
labelStyle: TextStyle(
color: greenPrimary,
fontSize: 18,
fontFamily: 'Muli',
fontWeight: FontWeight.w700),
suffixIcon: IconButton(
icon: Icon(
Icons.mic,
color: greenPrimary,
size: 25,
),
onPressed: () {})),
), onPressed: () {},
)),
),
),
),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
StreamBuilder<NetworkModel<LokasiListResponse>>(
stream: _bloc.recentSearchStream,
body: Stack(children: [
FutureBuilder<NetworkModel>(
future: data,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.LOADING:
return Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(greenPrimary),
),
);
break;
case Status.COMPLETED:
recentSearch = snapshot.data.data;
Widget displayWidget;
if (recentSearch.listLokasi.isEmpty) {
displayWidget = Center(
child: Text("Anda belum pernah melakukan pencarian"));
} else {
displayWidget = makeLokasiWidget("history",recentSearch);
}
return Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.all(doubleSpace),
child: Text(
"Pencarian terdahulu",
style: TextStyle(
fontFamily: 'Muli', fontSize: 15),
)),
Flexible(child: displayWidget),
],
));
break;
case Status.ERROR:
return Center(
child: Text("${snapshot.data.status}"),
);
break;
}
//places = snapshot.data.response;
return Container();
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return Container();
},
),
Container(
margin: EdgeInsets.only(left: doubleSpace, top: regularSpace, bottom: smallSpace),
child: Text("Hasil Pencarian"),
),
StreamBuilder<NetworkModel<LokasiListResponse>>(
stream: _bloc.lokasiListStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.LOADING:
return Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(greenPrimary),
),
);
break;
case Status.COMPLETED:
lokasiFromApi = snapshot.data.data;
return Expanded(
flex: 2, child: makeLokasiWidget("api",lokasiFromApi));
break;
case Status.ERROR:
return Center(
child: Text(snapshot.data.data.toString()),
);
break;
}
}
return Container();
},
),
],
),
);
}
Widget makeLokasiWidget(String key, LokasiListResponse places) {
return ListView.builder(
shrinkWrap: true,
itemCount: places.listLokasi.length,
itemBuilder: (context, index) {
return InkWell(
key: Key("$key-${places.listLokasi[index].nama}"),
onTap: () {
_bloc.saveRecentSearch(places.listLokasi[index]);
// By default, show a loading spinner.
return CircularProgressIndicator();
},
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
border: Border(bottom: BorderSide(color: Colors.grey[400]))),
margin: EdgeInsets.only(left: doubleSpace, right: doubleSpace),
height: 90,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
),
ListView.builder(
itemCount: currentSearch.length,
itemBuilder: (context, index) {
return Container(
decoration: BoxDecoration(
color: Colors.transparent,
border:
Border(bottom: BorderSide(color: Colors.grey[400]))),
margin:
EdgeInsets.only(left: doubleSpace, right: doubleSpace),
height: 90,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
CircleAvatar(
backgroundColor: greenPrimary,
child: Text('Test'),
),
Container(
padding: EdgeInsets.all(doubleSpace),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
places.listLokasi[index].nama,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w800,
color: Colors.black,
fontFamily: 'Muli',
),
),
Text(
places.listLokasi[index].alamat,
style: TextStyle(
fontSize: 15,
color: Colors.black,
fontFamily: 'Muli',
),
Row(
children: <Widget>[
CircleAvatar(
backgroundColor: greenPrimary,
child: Text('Test'),
),
Container(
padding: EdgeInsets.all(doubleSpace),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
currentSearch[index]['nama'],
key: Key('Result text'),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w800,
color: Colors.black,
fontFamily: 'Muli',
),
),
Text(
currentSearch[index]['alamat'],
style: TextStyle(
fontSize: 15,
color: Colors.black,
fontFamily: 'Muli',
),
),
],
),
],
),
),
],
),
Icon(
Icons.arrow_forward_ios,
color: Colors.grey[400],
size: 20,
)
],
),
Icon(
Icons.arrow_forward_ios,
color: Colors.grey[400],
size: 20,
)
],
),
),
);
});
);
})
]));
}
}
}
\ No newline at end of file
......@@ -36,7 +36,6 @@ void main() {
});
});
testWidgets('display list view in pencarian', (WidgetTester tester) async {
// Provide the childWidget to the Container.
await tester.pumpWidget(MaterialApp(home: Pencarian()));
// [TODO] pencet textfieldnya, isi textfieldnya pake Coolidge
// [TODO] expect nya keluar satu item namanya coolidge, expectnya pake key aja
......@@ -53,4 +52,13 @@ void main() {
expect(find.byKey(textFieldKey), findsOneWidget);
});
testWidgets('test textfield result', (WidgetTester tester) async {
final textFieldKey = Key("Text Field Mau Kemana");
await tester.pumpWidget(MaterialApp(home: Pencarian()));
await tester.enterText(find.byKey(textFieldKey), 'Mallory');
await tester.pump();
expect(find.text('Mallory'), findsOneWidget);
});
}
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