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"}
\ No newline at end of file
{"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
......@@ -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 = [];
......
......@@ -85,7 +85,8 @@ class PencarianState extends State<Pencarian> {
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(
......@@ -95,8 +96,8 @@ class PencarianState extends State<Pencarian> {
margin: EdgeInsets.all(doubleSpace),
child: Text(
"Pencarian terdahulu",
style: TextStyle(
fontFamily: 'Muli', fontSize: 15),
style:
TextStyle(fontFamily: 'Muli', fontSize: 15),
)),
Flexible(child: displayWidget),
],
......@@ -113,7 +114,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>>(
......@@ -131,7 +133,7 @@ class PencarianState extends State<Pencarian> {
case Status.COMPLETED:
lokasiFromApi = snapshot.data.data;
return Expanded(
flex: 2, child: makeLokasiWidget("api",lokasiFromApi));
flex: 2, child: makeLokasiWidget("api", lokasiFromApi.listLokasi));
break;
case Status.ERROR:
return Center(
......@@ -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(
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 +184,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 +193,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}");
});
}
});
......
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