diff --git a/assets/translations/en.json b/assets/translations/en.json index 66a939b8..fed19527 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -5,6 +5,7 @@ "cancel": "Cancel", "delete": "Delete", "reset": "Reset", + "reset_all": "Reset All", "search": "Search", "upload": "Upload", "edit": "Edit", @@ -13,7 +14,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", diff --git a/assets/translations/ko.json b/assets/translations/ko.json index 62169552..987247ba 100644 --- a/assets/translations/ko.json +++ b/assets/translations/ko.json @@ -5,6 +5,7 @@ "cancel": "취소", "delete": "삭제", "reset": "초기화", + "reset_all": "전체 초기화", "search": "검색", "upload": "업로드", "edit": "수정", @@ -13,7 +14,9 @@ "no_result": "검색 결과가 없습니다.", "select_all": "모두 선택", "unselect_all": "모두 해제", - "no_info": "정보 없음" + "no_info": "정보 없음", + "all_selected": "전체 선택됨", + "num_selected": "개 선택됨" }, "semester": { "spring": "봄", diff --git a/lib/models/filter.dart b/lib/models/filter.dart index 16430700..dc66f33b 100644 --- a/lib/models/filter.dart +++ b/lib/models/filter.dart @@ -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}); } diff --git a/lib/pages/course_search_page.dart b/lib/pages/course_search_page.dart index 45894e39..f1d290e6 100644 --- a/lib/pages/course_search_page.dart +++ b/lib/pages/course_search_page.dart @@ -107,7 +107,7 @@ class _CourseSearchPageState extends State { _focusNode.requestFocus(); }, child: Text( - "common.reset".tr(), + "common.reset_all".tr(), style: bodyBold.copyWith(color: OTLColor.pinksMain), ), style: ButtonStyle( diff --git a/lib/pages/lecture_search_page.dart b/lib/pages/lecture_search_page.dart index cacde916..de70df99 100644 --- a/lib/pages/lecture_search_page.dart +++ b/lib/pages/lecture_search_page.dart @@ -107,7 +107,7 @@ class _LectureSearchPageState extends State { _focusNode.requestFocus(); }, child: Text( - "common.reset".tr(), + "common.reset_all".tr(), style: bodyBold.copyWith(color: OTLColor.pinksMain), ), style: ButtonStyle( diff --git a/lib/providers/course_search_model.dart b/lib/providers/course_search_model.dart index 8dd35eb5..dfc8110c 100644 --- a/lib/providers/course_search_model.dart +++ b/lib/providers/course_search_model.dart @@ -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; diff --git a/lib/providers/lecture_search_model.dart b/lib/providers/lecture_search_model.dart index f1774435..da27e336 100644 --- a/lib/providers/lecture_search_model.dart +++ b/lib/providers/lecture_search_model.dart @@ -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; diff --git a/lib/widgets/search_filter_panel.dart b/lib/widgets/search_filter_panel.dart index 5df323c5..4d60ea49 100644 --- a/lib/widgets/search_filter_panel.dart +++ b/lib/widgets/search_filter_panel.dart @@ -1,3 +1,4 @@ +import 'package:easy_localization/easy_localization.dart' as _; import 'package:flutter/material.dart'; import 'package:otlplus/constants/color.dart'; import 'package:otlplus/constants/text_styles.dart'; @@ -92,44 +93,54 @@ class _SelectorState extends State { 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 == true) + .length == + 0 + ? [TextSpan(text: "common.all_selected".tr())] + : [ + TextSpan( + text: widget.selectList + .expand((i) => i) + .where((i) => i.selected == true) + .length + .toString()), + TextSpan(text: "common.num_selected".tr()), + ], + style: bodyRegular, + )), + ) + ], ), Visibility( - visible: widget.isMultiSelect, - child: GestureDetector( + 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); }); - } + }); }, - child: Text.rich( - TextSpan( - style: bodyRegular.copyWith( - color: OTLColor.pinksMain, - decoration: TextDecoration.underline, - ), - text: widget.selectList.every( - (v) => v.every((w) => w.selected == true), - ) - // unknown error - // ? "common.unselect_all".tr() - // : "common.select_all".tr() - ? "모두 해제" - : "모두 선택", - ), + text: "common.reset".tr(), + textStyle: bodyRegular.copyWith( + color: OTLColor.pinksMain, + decoration: TextDecoration.underline, ), ), )