Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search filter page #119

Merged
merged 7 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"cancel": "Cancel",
"delete": "Delete",
"add": "Add",
"reset": "Reset",
"reset": "Clear",
"reset_all": "Clear All",
"search": "Search",
"upload": "Upload",
"edit": "Edit",
Expand All @@ -14,7 +15,9 @@
"no_result": "No result.",
"select_all": "Select All",
"unselect_all": "Unselect All",
"no_info": "No information"
"no_info": "No information",
"all_selected": "All Selected",
"num_selected": " Selected"
},
"semester": {
"spring": "Spring",
Expand Down
5 changes: 4 additions & 1 deletion assets/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"delete": "삭제",
"add": "추가하기",
"reset": "초기화",
"reset_all": "전체 초기화",
"search": "검색",
"upload": "업로드",
"edit": "수정",
Expand All @@ -14,7 +15,9 @@
"no_result": "검색 결과가 없습니다.",
"select_all": "모두 선택",
"unselect_all": "모두 해제",
"no_info": "정보 없음"
"no_info": "정보 없음",
"all_selected": "전체 선택됨",
"num_selected": "개 선택됨"
},
"semester": {
"spring": "봄",
Expand Down
14 changes: 14 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ class OTLFirebaseApp extends StatelessWidget {
SystemUiOverlayStyle(statusBarColor: Colors.transparent));

return MaterialApp(
builder: (context, child) {
return ScrollConfiguration(
behavior: NoEndOfScrollBehavior(),
child: child ?? Container(),
);
},
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
Expand Down Expand Up @@ -160,3 +166,11 @@ class OTLFirebaseApp extends StatelessWidget {
);
}
}

class NoEndOfScrollBehavior extends ScrollBehavior {
@override
Widget buildOverscrollIndicator(
BuildContext context, Widget child, ScrollableDetails details) {
return child;
}
}
2 changes: 1 addition & 1 deletion lib/models/filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ class CodeLabelPair {
final String code;
final String label;
bool selected;
CodeLabelPair({required this.code, this.label = "", this.selected = true});
CodeLabelPair({required this.code, this.label = "", this.selected = false});
}
2 changes: 1 addition & 1 deletion lib/pages/course_search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class _CourseSearchPageState extends State<CourseSearchPage> {
context.read<CourseSearchModel>().resetCourseFilter();
},
child: Text(
"common.reset".tr(),
"common.reset_all".tr(),
style: bodyBold.copyWith(color: OTLColor.pinksMain),
),
style: ButtonStyle(
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/lecture_search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class _LectureSearchPageState extends State<LectureSearchPage> {
context.read<LectureSearchModel>().resetLectureFilter();
},
child: Text(
"common.reset".tr(),
"common.reset_all".tr(),
style: bodyBold.copyWith(color: OTLColor.pinksMain),
),
style: ButtonStyle(
Expand Down
3 changes: 0 additions & 3 deletions lib/pages/timetable_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ class _TimetablePageState extends State<TimetablePage> {
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
context
.read<LectureSearchModel>()
.resetLectureFilter();
Navigator.push(
context, buildLectureSearchPageRoute());
},
Expand Down
10 changes: 5 additions & 5 deletions lib/providers/course_search_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CourseSearchModel extends ChangeNotifier {
_courseSearchText = '';
_courseFilter.values.forEach((e) {
if (e.isMultiSelect)
e.options.forEach((b) => b.forEach((c) => c.selected = true));
e.options.forEach((b) => b.forEach((c) => c.selected = false));
else {
e.options.forEach((b) => b.forEach((c) => c.selected = false));
e.options.first.first.selected = true;
Expand Down Expand Up @@ -191,7 +191,7 @@ class CourseSearchModel extends ChangeNotifier {
if (v.options.expand((i) => i).every((i) => i.selected == false)) {
if (v.isMultiSelect == true)
v.options.expand((i) => i).forEach((j) {
j.selected = true;
// j.selected = true;
});
else
v.options.first.first.selected = true;
Expand All @@ -200,7 +200,7 @@ class CourseSearchModel extends ChangeNotifier {
List<CodeLabelPair> dep = _courseFilter['departments']!
.options
.expand((i) => i)
.every((i) => i.selected == true)
.every((i) => i.selected == false)
? []
: _courseFilter['departments']!
.options
Expand All @@ -210,7 +210,7 @@ class CourseSearchModel extends ChangeNotifier {
List<CodeLabelPair> typ = _courseFilter['types']!
.options
.expand((i) => i)
.every((i) => i.selected == true)
.every((i) => i.selected == false)
? []
: _courseFilter['types']!
.options
Expand All @@ -220,7 +220,7 @@ class CourseSearchModel extends ChangeNotifier {
List<CodeLabelPair> lev = _courseFilter['levels']!
.options
.expand((i) => i)
.every((i) => i.selected == true)
.every((i) => i.selected == false)
? []
: _courseFilter['levels']!
.options
Expand Down
10 changes: 5 additions & 5 deletions lib/providers/lecture_search_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class LectureSearchModel extends ChangeNotifier {
_lectureSearchText = '';
_lectureFilter.values.forEach((e) {
if (e.isMultiSelect)
e.options.forEach((b) => b.forEach((c) => c.selected = true));
e.options.forEach((b) => b.forEach((c) => c.selected = false));
else {
e.options.forEach((b) => b.forEach((c) => c.selected = false));
e.options.first.first.selected = true;
Expand Down Expand Up @@ -212,7 +212,7 @@ class LectureSearchModel extends ChangeNotifier {
if (v.options.expand((i) => i).every((i) => i.selected == false)) {
if (v.isMultiSelect == true)
v.options.expand((i) => i).forEach((j) {
j.selected = true;
// j.selected = true;
});
else
v.options.first.first.selected = true;
Expand All @@ -221,7 +221,7 @@ class LectureSearchModel extends ChangeNotifier {
List<CodeLabelPair> dep = _lectureFilter['departments']!
.options
.expand((i) => i)
.every((i) => i.selected == true)
.every((i) => i.selected == false)
? []
: _lectureFilter['departments']!
.options
Expand All @@ -231,7 +231,7 @@ class LectureSearchModel extends ChangeNotifier {
List<CodeLabelPair> typ = _lectureFilter['types']!
.options
.expand((i) => i)
.every((i) => i.selected == true)
.every((i) => i.selected == false)
? []
: _lectureFilter['types']!
.options
Expand All @@ -241,7 +241,7 @@ class LectureSearchModel extends ChangeNotifier {
List<CodeLabelPair> lev = _lectureFilter['levels']!
.options
.expand((i) => i)
.every((i) => i.selected == true)
.every((i) => i.selected == false)
? []
: _lectureFilter['levels']!
.options
Expand Down
67 changes: 43 additions & 24 deletions lib/widgets/search_filter_panel.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:math' as math;

import 'package:easy_localization/easy_localization.dart' as _;
import 'package:flutter/material.dart';
import 'package:otlplus/constants/color.dart';
Expand Down Expand Up @@ -95,40 +94,60 @@ class _SelectorState extends State<Selector> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.title,
style: titleBold,
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
widget.title,
style: titleBold,
),
SizedBox(width: 8),
Visibility(
visible: widget.isMultiSelect,
child: Text.rich(
TextSpan(
children: widget.selectList
.expand((i) => i)
.where((i) => i.selected)
.length ==
0
? [TextSpan(text: "common.all_selected".tr())]
: [
TextSpan(
text: widget.selectList
.expand((i) => i)
.where((i) => i.selected)
.length
.toString(),
),
TextSpan(text: "common.num_selected".tr()),
],
style: bodyRegular,
),
),
)
],
),
Visibility(
visible: widget.isMultiSelect,
visible: widget.isMultiSelect &&
!widget.selectList.every(
(v) => v.every((w) => w.selected == false),
),
child: IconTextButton(
onTap: () {
if (widget.selectList
.every((v) => v.every((w) => w.selected == true))) {
widget.selectList.forEach((v) {
v.forEach((w) {
widget.setFilter(w.code, false);
});
});
} else {
widget.selectList.forEach((v) {
v.forEach((w) {
widget.setFilter(w.code, true);
});
widget.selectList.forEach((v) {
v.forEach((w) {
widget.setFilter(w.code, false);
});
}
});
},
text: widget.selectList.every(
(v) => v.every((w) => w.selected == true),
)
? "common.unselect_all".tr()
: "common.select_all".tr(),
text: "common.reset".tr(),
textStyle: bodyRegular.copyWith(
color: OTLColor.pinksMain,
decoration: TextDecoration.underline,
),
),
)
),
],
),
),
Expand Down