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

[FATAL] Fix #123, #126, fix synchronized reviews, add translation in timetable #128

Merged
merged 7 commits into from
Aug 22, 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
13 changes: 10 additions & 3 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@
"remained_datetime": "D-{} days {} hours {} minutes"
},
"timetable": {
"ask_delete_lecture": "Are you delete class '{}'?",
"ask_delete_tab": "Do you really want to delete {}?",
"ask_delete_lecture": "Do you want to delete class '{}'?",
"ask_delete_tab": "Do you really want to delete '{}'?",
"my_tab": "My Table",
"tab": "Table {}",
"add_lecture": "Add Lecture",
"remove_lecture": "Remove Lecture",
"dialog": {
"add_lecture": "Add Lecture",
"ask_add_lecture": "There is a lecture with overlapping hours. If added, the previous lecture will be deleted.\nDo you want to add new lecture to the timetable?"
},
"tab_menu": {
"copy": "Copy Timetable",
"export_img": "Share as Image",
Expand Down Expand Up @@ -113,7 +119,8 @@
"load": "Load",
"speech": "Speech",
"like": "Like",
"report": "Report"
"report": "Report",
"expand": "more"
},
"user": {
"name": "Name",
Expand Down
11 changes: 9 additions & 2 deletions assets/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@
},
"timetable": {
"ask_delete_lecture": "'{}' 수업을 삭제하시겠습니까?",
"ask_delete_tab": "{}을(를) 정말 삭제하시겠습니까?",
"ask_delete_tab": "'{}'을(를) 정말 삭제하시겠습니까?",
"my_tab": "내 시간표",
"tab": "시간표 {}",
"add_lecture": "시간표에 추가",
"remove_lecture": "시간표에서 제거",
"dialog": {
"add_lecture": "수업 추가",
"ask_add_lecture": "시간이 겹치는 수업이 있습니다. 추가하시면 해당 수업은 삭제됩니다.\n시간표에 추가하시겠습니까?"
},
"tab_menu": {
"copy": "시간표 복제하기",
"export_img": "이미지로 내보내기",
Expand Down Expand Up @@ -113,7 +119,8 @@
"load": "널널",
"speech": "강의",
"like": "추천",
"report": "신고하기"
"report": "신고하기",
"expand": "더 보기"
},
"user": {
"name": "이름",
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import 'package:otlplus/providers/course_detail_model.dart';
import 'package:otlplus/providers/info_model.dart';
import 'package:otlplus/providers/lecture_detail_model.dart';
import 'package:otlplus/providers/review_model.dart';
import 'package:otlplus/providers/latest_reviews_model.dart';
import 'package:otlplus/providers/lecture_search_model.dart';
import 'package:otlplus/providers/timetable_model.dart';
import 'package:otlplus/utils/create_material_color.dart';
Expand Down Expand Up @@ -66,7 +66,7 @@
),
ChangeNotifierProvider(create: (_) => LectureSearchModel()),
ChangeNotifierProvider(create: (_) => CourseSearchModel()),
ChangeNotifierProvider(create: (_) => ReviewModel()),
ChangeNotifierProvider(create: (_) => LatestReviewsModel()),

Check warning on line 69 in lib/main.dart

View check run for this annotation

Codecov / codecov/patch

lib/main.dart#L69

Added line #L69 was not covered by tests
ChangeNotifierProvider(create: (_) => LikedReviewModel()),
ChangeNotifierProvider(create: (_) => HallOfFameModel()),
ChangeNotifierProvider(create: (_) => CourseDetailModel()),
Expand Down
9 changes: 5 additions & 4 deletions lib/pages/lecture_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
title: const Text("수업 추가"),
content: const Text(
"시간이 겹치는 수업이 있습니다. 추가하시면 해당 수업은 삭제됩니다.\n시간표에 추가하시겠습니까?"),
title: Text("timetable.dialog.add_lecture".tr()),
content: Text("timetable.dialog.ask_add_lecture".tr()),

Check warning on line 117 in lib/pages/lecture_detail_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/lecture_detail_page.dart#L116-L117

Added lines #L116 - L117 were not covered by tests
actions: [
IconTextButton(
padding: EdgeInsets.all(12),
Expand Down Expand Up @@ -144,7 +143,9 @@
);
}
},
text: isAdded ? "시간표에서 제거" : "시간표에 추가",
text: isAdded
? "timetable.remove_lecture".tr()
: "timetable.add_lecture".tr(),

Check warning on line 148 in lib/pages/lecture_detail_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/lecture_detail_page.dart#L147-L148

Added lines #L147 - L148 were not covered by tests
textStyle: const TextStyle(fontSize: 12.0),
icon: isAdded ? Icons.close : Icons.add,
iconSize: 14,
Expand Down
1 change: 1 addition & 0 deletions lib/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class _MainPageState extends State<MainPage> {
borderRadius:
BorderRadius.vertical(top: Radius.circular(16.0)),
child: Container(
color: OTLColor.grayF,
constraints: const BoxConstraints.expand(),
child: CustomScrollView(
reverse: true,
Expand Down
36 changes: 21 additions & 15 deletions lib/pages/review_page.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'package:flutter/material.dart';
import 'package:otlplus/pages/course_detail_page.dart';
import 'package:otlplus/models/review.dart';
import 'package:otlplus/providers/hall_of_fame_model.dart';
import 'package:otlplus/utils/navigator.dart';
import 'package:otlplus/widgets/hall_of_fame_control.dart';
import 'package:otlplus/widgets/otl_scaffold.dart';
import 'package:otlplus/widgets/review_mode_control.dart';
import 'package:provider/provider.dart';
import 'package:otlplus/providers/course_detail_model.dart';
import 'package:otlplus/providers/review_model.dart';
import 'package:otlplus/providers/latest_reviews_model.dart';
import 'package:otlplus/widgets/review_block.dart';

class ReviewPage extends StatefulWidget {
Expand All @@ -23,9 +22,6 @@
Widget build(BuildContext context) {
final _selectedMode =
context.select<HallOfFameModel, int>((m) => m.selectedMode);
final latestReviews =
context.select<ReviewModel, List<Review>>((m) => m.reviews);
final hallOfFames = context.watch<HallOfFameModel>().hallOfFames();

return OTLLayout(
leading: ReviewModeControl(
Expand All @@ -40,17 +36,17 @@
),
body: Card(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16.0)),
borderRadius: BorderRadius.only(topRight: Radius.circular(16.0)),
),
child: NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
if (_selectedMode == 1) {
final reviewModel = context.read<ReviewModel>();
final reviewModel = context.read<LatestReviewsModel>();

Check warning on line 44 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L44

Added line #L44 was not covered by tests

if (!reviewModel.isLoading &&
scrollNotification.metrics.pixels ==
scrollNotification.metrics.maxScrollExtent) {
reviewModel.loadReviews();
reviewModel.loadLatestReviews();

Check warning on line 49 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L49

Added line #L49 was not covered by tests
}

return true;
Expand All @@ -60,7 +56,7 @@
if (!hallOfFameModel.isLoading &&
scrollNotification.metrics.pixels ==
scrollNotification.metrics.maxScrollExtent) {
hallOfFameModel.loadHallOfFames();
hallOfFameModel.loadHallOfFame();

Check warning on line 59 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L59

Added line #L59 was not covered by tests
}

return true;
Expand All @@ -71,24 +67,28 @@
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
_selectedMode == 1
? _buildLatestReviews(latestReviews)
: _buildHallOfFames(hallOfFames),
_selectedMode == 1 ? LatestReviewsPage() : HallOfFamePage()

Check warning on line 70 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L70

Added line #L70 was not covered by tests
],
),
),
),
),
);
}
}

class LatestReviewsPage extends StatelessWidget {
const LatestReviewsPage({Key? key}) : super(key: key);

Check warning on line 81 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L81

Added line #L81 was not covered by tests

Widget _buildLatestReviews(latestReviews) {
@override

Check warning on line 83 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L83

Added line #L83 was not covered by tests
Widget build(BuildContext context) {
final _scrollController = context.watch<HallOfFameModel>().scrollController;
final latestReviews = context.watch<LatestReviewsModel>().latestReviews;

Check warning on line 86 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L86

Added line #L86 was not covered by tests

return Expanded(
child: RefreshIndicator(
onRefresh: () async {
await context.read<ReviewModel>().clear();
await context.read<LatestReviewsModel>().clear();

Check warning on line 91 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L91

Added line #L91 was not covered by tests
},
child: Scrollbar(
child: CustomScrollView(
Expand Down Expand Up @@ -132,9 +132,15 @@
),
);
}
}

class HallOfFamePage extends StatelessWidget {
const HallOfFamePage({Key? key}) : super(key: key);

Check warning on line 138 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L138

Added line #L138 was not covered by tests

Widget _buildHallOfFames(hallOfFames) {
@override

Check warning on line 140 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L140

Added line #L140 was not covered by tests
Widget build(BuildContext context) {
final _scrollController = context.watch<HallOfFameModel>().scrollController;
final hallOfFames = context.watch<HallOfFameModel>().hallOfFame;

Check warning on line 143 in lib/pages/review_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/review_page.dart#L143

Added line #L143 was not covered by tests

return Expanded(
child: RefreshIndicator(
Expand Down
14 changes: 11 additions & 3 deletions lib/pages/timetable_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
OTLNavigator.push(context, LectureSearchPage());
OTLNavigator.push(

Check warning on line 98 in lib/pages/timetable_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/timetable_page.dart#L98

Added line #L98 was not covered by tests
context,
LectureSearchPage(

Check warning on line 100 in lib/pages/timetable_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/timetable_page.dart#L100

Added line #L100 was not covered by tests
openKeyboard: false,
));
},
child: Padding(
padding:
Expand Down Expand Up @@ -167,10 +171,14 @@
}

Timetable _buildTimetable(
BuildContext context, List<Lecture> lectures, bool isExamTime) {
BuildContext context,
List<Lecture> lectures,
bool isExamTime,
) {
bool isFirst = true;
final tempLecture =
context.select<TimetableModel, Lecture?>((model) => model.tempLecture);
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');

Check warning on line 181 in lib/pages/timetable_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/timetable_page.dart#L181

Added line #L181 was not covered by tests

return Timetable(
lectures: (tempLecture == null) ? lectures : [...lectures, tempLecture],
Expand Down Expand Up @@ -205,7 +213,7 @@
builder: (context) => AlertDialog(
title: Text("common.delete".tr()),
content: Text("timetable.ask_delete_lecture").tr(
args: [lecture.title],
args: [isEn ? lecture.titleEn : lecture.title],

Check warning on line 216 in lib/pages/timetable_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/timetable_page.dart#L216

Added line #L216 was not covered by tests
),
actions: [
IconTextButton(
Expand Down
17 changes: 9 additions & 8 deletions lib/providers/hall_of_fame_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Semester? get semeseter => _semester;
void setSemester(Semester? semester) {
_semester = semester;
notifyListeners();

Check warning on line 22 in lib/providers/hall_of_fame_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/hall_of_fame_model.dart#L22

Added line #L22 was not covered by tests

// 1. Animate Immediately But Error Prone
// _scrollController.animateTo(
Expand All @@ -40,16 +41,16 @@
);
}

List<Review> _hallOfFames = <Review>[];
List<Review> hallOfFames() {
if (_hallOfFames.length == 0 && !_isLoading) loadHallOfFames();
return _hallOfFames;
List<Review> _hallOfFame = <Review>[];
List<Review> get hallOfFame {
if (_hallOfFame.length == 0 && !_isLoading) loadHallOfFame();
return _hallOfFame;

Check warning on line 47 in lib/providers/hall_of_fame_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/hall_of_fame_model.dart#L45-L47

Added lines #L45 - L47 were not covered by tests
}

Future<void> clear() async {
_hallOfFames.clear();
_hallOfFame.clear();

Check warning on line 51 in lib/providers/hall_of_fame_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/hall_of_fame_model.dart#L51

Added line #L51 was not covered by tests
_page = 0;
await loadHallOfFames();
await loadHallOfFame();

Check warning on line 53 in lib/providers/hall_of_fame_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/hall_of_fame_model.dart#L53

Added line #L53 was not covered by tests

// 2. Animate Slowly But Safe
_scrollController.animateTo(
Expand All @@ -59,7 +60,7 @@
);
}

Future<void> loadHallOfFames() async {
Future<void> loadHallOfFame() async {

Check warning on line 63 in lib/providers/hall_of_fame_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/hall_of_fame_model.dart#L63

Added line #L63 was not covered by tests
_isLoading = true;

try {
Expand All @@ -82,7 +83,7 @@
});
}
final rawReviews = response.data as List;
_hallOfFames.addAll(rawReviews.map((review) => Review.fromJson(review)));
_hallOfFame.addAll(rawReviews.map((review) => Review.fromJson(review)));

Check warning on line 86 in lib/providers/hall_of_fame_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/hall_of_fame_model.dart#L86

Added line #L86 was not covered by tests
_page++;
_isLoading = false;
notifyListeners();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
import 'package:otlplus/dio_provider.dart';
import 'package:otlplus/models/review.dart';

class ReviewModel extends ChangeNotifier {
class LatestReviewsModel extends ChangeNotifier {
int _page = 0;
int get page => _page;

bool _isLoading = false;
bool get isLoading => _isLoading;

List<Review> _reviews = <Review>[];
List<Review> get reviews {
if (_reviews.length == 0 && !_isLoading) loadReviews();
return _reviews;
List<Review> _latestReviews = <Review>[];
List<Review> get latestReviews {
if (_latestReviews.length == 0 && !_isLoading) loadLatestReviews();
return _latestReviews;

Check warning on line 16 in lib/providers/latest_reviews_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/latest_reviews_model.dart#L14-L16

Added lines #L14 - L16 were not covered by tests
}

Future<void> clear() async {
_reviews.clear();
_latestReviews.clear();

Check warning on line 20 in lib/providers/latest_reviews_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/latest_reviews_model.dart#L20

Added line #L20 was not covered by tests
_page = 0;
await loadReviews();
await loadLatestReviews();

Check warning on line 22 in lib/providers/latest_reviews_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/latest_reviews_model.dart#L22

Added line #L22 was not covered by tests
}

Future<void> loadReviews() async {
Future<void> loadLatestReviews() async {

Check warning on line 25 in lib/providers/latest_reviews_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/latest_reviews_model.dart#L25

Added line #L25 was not covered by tests
_isLoading = true;

try {
Expand All @@ -33,7 +33,8 @@
"limit": 10,
});
final rawReviews = response.data as List;
_reviews.addAll(rawReviews.map((review) => Review.fromJson(review)));
_latestReviews
.addAll(rawReviews.map((review) => Review.fromJson(review)));

Check warning on line 37 in lib/providers/latest_reviews_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/providers/latest_reviews_model.dart#L36-L37

Added lines #L36 - L37 were not covered by tests
_page++;
_isLoading = false;
notifyListeners();
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/expandable_text.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:easy_localization/easy_localization.dart' as _;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -25,11 +26,11 @@ class ExpandableTextState extends State<ExpandableText> {
TextSpan expandButton = TextSpan(
children: <TextSpan>[
TextSpan(
text: "..",
text: ".. ",
style: widget.style,
),
TextSpan(
text: " 더보기",
text: "review.expand".tr(),
style:
(widget.style ?? TextStyle()).copyWith(color: Colors.black45),
recognizer: TapGestureRecognizer()
Expand Down
Loading
Loading