Fakultas Ilmu Komputer UI

Commit bf56b92d authored by Usman Sidiq's avatar Usman Sidiq
Browse files
parents 7066591b d3a4ff48
Pipeline #42402 failed with stages
in 19 minutes and 23 seconds
......@@ -46,17 +46,17 @@ class KomentarBloc {
komentarListSink.add(NetworkModel.completed(KomentarList(currentList)));
}
sortKomentarList(String option, List<KomentarModel> currentList) {
if (option == 'latest') {
sortKomentarList(int option, List<KomentarModel> currentList) {
if (option == 0) {
currentList.sort((next_komentar, prev_komentar) =>
prev_komentar.date_time.compareTo(next_komentar.date_time));
} else if (option == 'rating') {
currentList.sort((next_komentar, prev_komentar) =>
prev_komentar.like.compareTo(next_komentar.like));
} else {
} else if (option == 1) {
currentList.sort((next_komentar, prev_komentar) =>
(prev_komentar.like + prev_komentar.dislike)
.compareTo(next_komentar.like + next_komentar.dislike));
} else if (option == 2) {
currentList.sort((next_komentar, prev_komentar) =>
prev_komentar.like.compareTo(next_komentar.like));
}
komentarListSink.add(NetworkModel.completed(KomentarList(currentList)));
}
......
......@@ -11,6 +11,7 @@ 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;
final String alamat;
......@@ -36,9 +37,7 @@ class _FasilitasState extends State<Fasilitas> {
var tongkatVal = true;
var kursiDisabilitasVal = true;
var runningTextVal = true;
var komentarTerbaru = false;
var komentarRatingTertinggi = false;
var komentarTerpopuler = false;
var sortKomentar = -1;
var showUrutan = true;
var komentarStream;
List<KomentarModel> allKomentarFromApi;
......@@ -383,17 +382,16 @@ class _FasilitasState extends State<Fasilitas> {
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: greenPrimary,
child: Radio(
value: 0,
groupValue: sortKomentar,
activeColor: greenPale,
value: komentarTerbaru,
onChanged: (bool value) {
if (value) {
onChanged: (sort) {
_bloc.sortKomentarList(
'latest', allKomentarFromApi);
}
sort, allKomentarFromApi);
setStateModal(() {
komentarTerbaru = value;
sortKomentar = sort;
});
},
),
......@@ -412,17 +410,16 @@ class _FasilitasState extends State<Fasilitas> {
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: greenPrimary,
child: Radio(
value: 1,
groupValue: sortKomentar,
activeColor: greenPale,
value: komentarTerpopuler,
onChanged: (bool value) {
if (value) {
_bloc.sortKomentarList(
'popular', allKomentarFromApi);
}
onChanged: (sort) {
_bloc.sortKomentarList(
sort, allKomentarFromApi);
setStateModal(() {
komentarTerpopuler = value;
sortKomentar = sort;
});
},
),
......@@ -443,17 +440,16 @@ class _FasilitasState extends State<Fasilitas> {
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: greenPrimary,
child: Radio(
value: 2,
groupValue: sortKomentar,
activeColor: greenPale,
value: komentarRatingTertinggi,
onChanged: (bool value) {
if (value) {
_bloc.sortKomentarList(
'rating', allKomentarFromApi);
}
onChanged: (sort) {
_bloc.sortKomentarList(
sort, allKomentarFromApi);
setStateModal(() {
komentarRatingTertinggi = value;
sortKomentar = sort;
});
},
),
......@@ -899,10 +895,7 @@ class _FasilitasState extends State<Fasilitas> {
tongkatVal = true;
kursiDisabilitasVal = true;
runningTextVal = true;
komentarTerbaru = false;
komentarRatingTertinggi = false;
komentarTerpopuler = false;
showUrutan = true;
sortKomentar = -1;
});
_bloc.resetKomentarList();
},
......@@ -940,10 +933,7 @@ class _FasilitasState extends State<Fasilitas> {
tongkatVal = true;
kursiDisabilitasVal = true;
runningTextVal = true;
komentarTerbaru = false;
komentarRatingTertinggi = false;
komentarTerpopuler = false;
showUrutan = true;
sortKomentar = -1;
super.dispose();
}
......
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