Fakultas Ilmu Komputer UI

Commit a8bf57d6 authored by Fakhira Devina's avatar Fakhira Devina
Browse files

[CHORE] reverse recent search cookie

parent 1e7a7f82
Pipeline #38322 passed with stages
in 5 minutes and 30 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 17:23:41.601639","version":"1.15.17"} {"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-04-06 13:54:16.491102","version":"1.15.17"}
\ No newline at end of file \ No newline at end of file
...@@ -33,11 +33,9 @@ class LokasiResponseBloc { ...@@ -33,11 +33,9 @@ class LokasiResponseBloc {
try { try {
LokasiListResponse lokasiListResponse = LokasiListResponse lokasiListResponse =
await _lokasiRepository.fetchLokasi(); await _lokasiRepository.fetchLokasi();
print("lokasi list response: $lokasiListResponse");
lokasiListSink.add(NetworkModel.completed(lokasiListResponse)); lokasiListSink.add(NetworkModel.completed(lokasiListResponse));
} catch (e) { } catch (e) {
lokasiListSink.add(NetworkModel.error(e.toString())); lokasiListSink.add(NetworkModel.error(e.toString()));
print("$e");
} }
} }
...@@ -45,11 +43,9 @@ class LokasiResponseBloc { ...@@ -45,11 +43,9 @@ class LokasiResponseBloc {
recentSearchSink.add(NetworkModel.loading('Getting Recent Search')); recentSearchSink.add(NetworkModel.loading('Getting Recent Search'));
try { try {
LokasiListResponse recentSearchData = await _lokasiRepository.fetchRecentSearch(); LokasiListResponse recentSearchData = await _lokasiRepository.fetchRecentSearch();
print("recentSearchData ${recentSearchData.listLokasi}");
recentSearchSink.add(NetworkModel.completed(recentSearchData)); recentSearchSink.add(NetworkModel.completed(recentSearchData));
} catch (e) { } catch (e) {
recentSearchSink.add(NetworkModel.error(e.toString())); recentSearchSink.add(NetworkModel.error(e.toString()));
print("line 53 ${e.toString()}");
} }
} }
......
...@@ -72,7 +72,7 @@ class CookiesInterface { ...@@ -72,7 +72,7 @@ class CookiesInterface {
} else { } else {
currentSearchHistory = json.decode(cookie); currentSearchHistory = json.decode(cookie);
} }
currentSearchHistory.add(recentSearch); currentSearchHistory.insert(0, recentSearch);
}); });
} else { } else {
currentSearchHistory = []; currentSearchHistory = [];
......
...@@ -85,7 +85,8 @@ class PencarianState extends State<Pencarian> { ...@@ -85,7 +85,8 @@ class PencarianState extends State<Pencarian> {
displayWidget = Center( displayWidget = Center(
child: Text("Anda belum pernah melakukan pencarian")); child: Text("Anda belum pernah melakukan pencarian"));
} else { } else {
displayWidget = makeLokasiWidget("history",recentSearch); displayWidget =
makeLokasiWidget("history", recentSearch.listLokasi.take(3).toList());
} }
return Expanded( return Expanded(
child: Column( child: Column(
...@@ -95,8 +96,8 @@ class PencarianState extends State<Pencarian> { ...@@ -95,8 +96,8 @@ class PencarianState extends State<Pencarian> {
margin: EdgeInsets.all(doubleSpace), margin: EdgeInsets.all(doubleSpace),
child: Text( child: Text(
"Pencarian terdahulu", "Pencarian terdahulu",
style: TextStyle( style:
fontFamily: 'Muli', fontSize: 15), TextStyle(fontFamily: 'Muli', fontSize: 15),
)), )),
Flexible(child: displayWidget), Flexible(child: displayWidget),
], ],
...@@ -113,7 +114,8 @@ class PencarianState extends State<Pencarian> { ...@@ -113,7 +114,8 @@ class PencarianState extends State<Pencarian> {
}, },
), ),
Container( Container(
margin: EdgeInsets.only(left: doubleSpace, top: regularSpace, bottom: smallSpace), margin: EdgeInsets.only(
left: doubleSpace, top: regularSpace, bottom: smallSpace),
child: Text("Hasil Pencarian"), child: Text("Hasil Pencarian"),
), ),
StreamBuilder<NetworkModel<LokasiListResponse>>( StreamBuilder<NetworkModel<LokasiListResponse>>(
...@@ -131,7 +133,7 @@ class PencarianState extends State<Pencarian> { ...@@ -131,7 +133,7 @@ class PencarianState extends State<Pencarian> {
case Status.COMPLETED: case Status.COMPLETED:
lokasiFromApi = snapshot.data.data; lokasiFromApi = snapshot.data.data;
return Expanded( return Expanded(
flex: 2, child: makeLokasiWidget("api",lokasiFromApi)); flex: 2, child: makeLokasiWidget("api", lokasiFromApi.listLokasi));
break; break;
case Status.ERROR: case Status.ERROR:
return Center( return Center(
...@@ -148,15 +150,16 @@ class PencarianState extends State<Pencarian> { ...@@ -148,15 +150,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( return ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: places.listLokasi.length, itemCount: places.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return InkWell( return InkWell(
key: Key("$key-${places.listLokasi[index].nama}"), key: Key("$key-${places[index].nama}"),
onTap: () { onTap: () {
_bloc.saveRecentSearch(places.listLokasi[index]); _bloc.saveRecentSearch(places[index]);
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
...@@ -181,7 +184,7 @@ class PencarianState extends State<Pencarian> { ...@@ -181,7 +184,7 @@ class PencarianState extends State<Pencarian> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
places.listLokasi[index].nama, places[index].nama,
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
...@@ -190,7 +193,7 @@ class PencarianState extends State<Pencarian> { ...@@ -190,7 +193,7 @@ class PencarianState extends State<Pencarian> {
), ),
), ),
Text( Text(
places.listLokasi[index].alamat, places[index].alamat,
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 15,
color: Colors.black, color: Colors.black,
......
...@@ -22,7 +22,6 @@ class LokasiRepository { ...@@ -22,7 +22,6 @@ class LokasiRepository {
} else { } else {
await CookiesInterface().getCookieFile(fileName: "searchhistory").then((cookie) { await CookiesInterface().getCookieFile(fileName: "searchhistory").then((cookie) {
response = json.decode(cookie); response = json.decode(cookie);
print("response type: ${response.runtimeType}");
}); });
} }
}); });
......
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