Fakultas Ilmu Komputer UI

Commit 6c05d5b4 authored by Agnes Handoko's avatar Agnes Handoko
Browse files

[CHORE] pull from PI 5

parents 243c6cd0 b482102f
Pipeline #38426 passed with stages
in 9 minutes and 23 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"}
{"_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
......@@ -33,11 +33,9 @@ class LokasiResponseBloc {
try {
LokasiListResponse lokasiListResponse =
await _lokasiRepository.fetchLokasi();
print("lokasi list response: $lokasiListResponse");
lokasiListSink.add(NetworkModel.completed(lokasiListResponse));
} catch (e) {
lokasiListSink.add(NetworkModel.error(e.toString()));
print("$e");
}
}
......@@ -45,11 +43,9 @@ class LokasiResponseBloc {
recentSearchSink.add(NetworkModel.loading('Getting Recent Search'));
try {
LokasiListResponse recentSearchData = await _lokasiRepository.fetchRecentSearch();
print("recentSearchData ${recentSearchData.listLokasi}");
recentSearchSink.add(NetworkModel.completed(recentSearchData));
} catch (e) {
recentSearchSink.add(NetworkModel.error(e.toString()));
print("line 53 ${e.toString()}");
}
}
......
......@@ -72,7 +72,7 @@ class CookiesInterface {
} else {
currentSearchHistory = json.decode(cookie);
}
currentSearchHistory.add(recentSearch);
currentSearchHistory.insert(0, recentSearch);
});
} else {
currentSearchHistory = [];
......
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';
/// 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");
/// Text for appbar
Widget appBarText = Text('Pencarian Lokasi');
/// List of places currently searched on the textFormField
List<Lokasi> currentSearch = [];
/// List for places from API
List<Lokasi> places = [];
/// BLoC for pencarian
LokasiResponseBloc _bloc = LokasiResponseBloc();
LokasiListResponse lokasiFromApi;
LokasiListResponse recentSearch;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty<List>('places', places))
..add(DiagnosticsProperty<List>('currentSearch', currentSearch));
}
@override
void initState() {
myController.addListener(() {
List<Lokasi> tempList = [];
for (int i = 0; i < places.length; i++) {
if (myController.text.isNotEmpty) {
if (places[i]
.nama
.toLowerCase()
.contains(myController.text.toLowerCase())) {
tempList.add(places[i]);
}
}
}
setState(() {
currentSearch = tempList;
});
});
super.initState();
}
......@@ -27,7 +67,7 @@ class PencarianState extends State<Pencarian> {
backgroundColor: greenPrimary,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios, size: 25),
key: Key("Back Icon Key"),
key: Key('Back Icon Key'),
onPressed: () => Navigator.pop(context, 'Take me back')),
title: Container(
margin: EdgeInsets.only(top: doubleSpace, bottom: doubleSpace),
......@@ -36,7 +76,8 @@ class PencarianState extends State<Pencarian> {
borderRadius: doubleBorderRadius,
boxShadow: regularShadow),
child: TextFormField(
key: Key("Text Field Mau Kemana"),
controller: myController,
key: Key('Text Field Mau Kemana'),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(0),
isDense: false,
......@@ -54,12 +95,13 @@ class PencarianState extends State<Pencarian> {
fontFamily: 'Muli',
fontWeight: FontWeight.w700),
suffixIcon: IconButton(
icon: Icon(
Icons.mic,
color: greenPrimary,
size: 25,
),
onPressed: () {})),
icon: Icon(
Icons.mic,
color: greenPrimary,
size: 25,
),
onPressed: () {},
)),
),
),
),
......@@ -79,28 +121,29 @@ class PencarianState extends State<Pencarian> {
);
break;
case Status.COMPLETED:
recentSearch = snapshot.data.data;
final recentSearch = snapshot.data.data;
Widget displayWidget;
if (recentSearch.listLokasi.isEmpty) {
displayWidget = Center(
child: Text("Anda belum pernah melakukan pencarian"));
} else {
displayWidget = makeLokasiWidget("history",recentSearch);
displayWidget = makeLokasiWidget(
"history", recentSearch.listLokasi.take(3).toList());
}
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),
],
));
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(
......@@ -113,7 +156,8 @@ class PencarianState extends State<Pencarian> {
},
),
Container(
margin: EdgeInsets.only(left: doubleSpace, top: regularSpace, bottom: smallSpace),
margin: EdgeInsets.only(
left: doubleSpace, top: regularSpace, bottom: smallSpace),
child: Text("Hasil Pencarian"),
),
StreamBuilder<NetworkModel<LokasiListResponse>>(
......@@ -129,9 +173,12 @@ class PencarianState extends State<Pencarian> {
);
break;
case Status.COMPLETED:
lokasiFromApi = snapshot.data.data;
places = snapshot.data.data.listLokasi;
return Expanded(
flex: 2, child: makeLokasiWidget("api",lokasiFromApi));
flex: 2,
child: currentSearch.isEmpty
? Center(child: Text('Cari lokasi'))
: makeLokasiWidget("api", currentSearch));
break;
case Status.ERROR:
return Center(
......@@ -148,15 +195,16 @@ class PencarianState extends State<Pencarian> {
);
}
Widget makeLokasiWidget(String key, LokasiListResponse places) {
Widget makeLokasiWidget(String key, List<Lokasi> places) {
print('$key - $places');
return ListView.builder(
shrinkWrap: true,
itemCount: places.listLokasi.length,
itemCount: places.length,
itemBuilder: (context, index) {
return InkWell(
key: Key("$key-${places.listLokasi[index].nama}"),
key: Key("$key-${places[index].nama}"),
onTap: () {
_bloc.saveRecentSearch(places.listLokasi[index]);
_bloc.saveRecentSearch(places[index]);
},
child: Container(
decoration: BoxDecoration(
......@@ -181,7 +229,7 @@ class PencarianState extends State<Pencarian> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
places.listLokasi[index].nama,
places[index].nama,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w800,
......@@ -190,7 +238,7 @@ class PencarianState extends State<Pencarian> {
),
),
Text(
places.listLokasi[index].alamat,
places[index].alamat,
style: TextStyle(
fontSize: 15,
color: Colors.black,
......
......@@ -22,7 +22,6 @@ class LokasiRepository {
} else {
await CookiesInterface().getCookieFile(fileName: "searchhistory").then((cookie) {
response = json.decode(cookie);
print("response type: ${response.runtimeType}");
});
}
});
......
......@@ -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