From ec5920085609798c38e02cbe10cfcd4233636b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=8A=B9=ED=98=B8?= Date: Thu, 3 Aug 2023 01:01:08 +0900 Subject: [PATCH 1/2] fix: timetable translate --- assets/translations/en.json | 4 + assets/translations/ko.json | 4 + lib/pages/main_page.dart | 1 + lib/pages/timetable_page.dart | 4 +- lib/utils/build_page_route.dart | 5 +- lib/widgets/lecture_group_block.dart | 121 +++++++++++------------ lib/widgets/lecture_group_block_row.dart | 39 +++++--- lib/widgets/lecture_search.dart | 51 ++++++---- 8 files changed, 128 insertions(+), 101 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 98263701..10a4ea67 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -58,6 +58,10 @@ "ask_delete_tab": "Do you really want to delete {}?", "my_tab": "My Table", "tab": "Table {}", + "dialog": { + "add_lecture": "Add Lecture", + "ask_add_lecture": "There is a lecture with overlapping hours. If added, the lecture will be deleted.\nDo you want to add new lecture to the timetable?" + }, "tab_menu": { "copy": "Copy Timetable", "export_img": "Share as Image", diff --git a/assets/translations/ko.json b/assets/translations/ko.json index d209d355..76787269 100644 --- a/assets/translations/ko.json +++ b/assets/translations/ko.json @@ -58,6 +58,10 @@ "ask_delete_tab": "{}을(를) 정말 삭제하시겠습니까?", "my_tab": "내 시간표", "tab": "시간표 {}", + "dialog": { + "add_lecture": "수업 추가", + "ask_add_lecture": "시간이 겹치는 수업이 있습니다. 추가하시면 해당 수업은 삭제됩니다.\n시간표에 추가하시겠습니까?" + }, "tab_menu": { "copy": "시간표 복제하기", "export_img": "이미지로 내보내기", diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index f4c6ba5f..92226fa8 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -153,6 +153,7 @@ class _MainPageState extends State { borderRadius: BorderRadius.vertical(top: Radius.circular(16.0)), child: Container( + color: OTLColor.grayF, constraints: const BoxConstraints.expand(), child: CustomScrollView( reverse: true, diff --git a/lib/pages/timetable_page.dart b/lib/pages/timetable_page.dart index 26fa50b0..a529ebfc 100644 --- a/lib/pages/timetable_page.dart +++ b/lib/pages/timetable_page.dart @@ -75,7 +75,9 @@ class _TimetablePageState extends State { behavior: HitTestBehavior.translucent, onTap: () { Navigator.push( - context, buildLectureSearchPageRoute()); + context, + buildLectureSearchPageRoute(false), + ); }, child: Padding( padding: const EdgeInsets.fromLTRB(12, 18, 16, 18), diff --git a/lib/utils/build_page_route.dart b/lib/utils/build_page_route.dart index 5bcdf2c8..30c21ffd 100644 --- a/lib/utils/build_page_route.dart +++ b/lib/utils/build_page_route.dart @@ -136,9 +136,10 @@ Route buildCourseSearchPageRoute() { ); } -Route buildLectureSearchPageRoute() { +Route buildLectureSearchPageRoute(bool openKeyboard) { return PageRouteBuilder( - pageBuilder: (_, animation, __) => LectureSearchPage(openKeyboard: true), + pageBuilder: (_, animation, __) => + LectureSearchPage(openKeyboard: openKeyboard), transitionsBuilder: (_, animation, __, child) { const begin = Offset(1.0, 0.0); const end = Offset.zero; diff --git a/lib/widgets/lecture_group_block.dart b/lib/widgets/lecture_group_block.dart index 75fbe087..eecf62e9 100644 --- a/lib/widgets/lecture_group_block.dart +++ b/lib/widgets/lecture_group_block.dart @@ -1,5 +1,7 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:otlplus/constants/color.dart'; +import 'package:otlplus/constants/text_styles.dart'; import 'package:otlplus/models/lecture.dart'; import 'package:otlplus/widgets/lecture_group_block_row.dart'; @@ -11,6 +13,8 @@ class LectureGroupBlock extends StatelessWidget { @override Widget build(BuildContext context) { + final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en'); + if (lectures.isEmpty) { return Container( margin: const EdgeInsets.only(bottom: 6.0), @@ -22,71 +26,66 @@ class LectureGroupBlock extends StatelessWidget { child: Text("There is no lecture."), ); } - return ClipRRect( - borderRadius: BorderRadius.circular(8.0), - child: ColoredBox( - color: Color(0xFFEEEEEE), - child: Padding( - padding: EdgeInsets.fromLTRB(12, 8, 12, 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - padding: EdgeInsets.only(bottom: 4.0), - child: Wrap( - alignment: WrapAlignment.spaceBetween, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Text( - lectures.first.commonTitle, - style: const TextStyle( - fontSize: 14.0, fontWeight: FontWeight.bold), - ), - SizedBox( - width: 4, - ), - Text( - lectures.first.oldCode, - style: const TextStyle(fontSize: 14.0), - ), - ], - ), - Text.rich( - TextSpan( - style: const TextStyle( - fontSize: 10.0, - color: Color(0xFF999999), - ), - children: [ - TextSpan( - text: lectures.first.departmentCode, - ), - const TextSpan(text: " / "), - TextSpan(text: lectures.first.type), - ], - ), + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(8.0)), + color: OTLColor.grayE, + ), + padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 4.0), + child: Wrap( + alignment: WrapAlignment.spaceBetween, + crossAxisAlignment: WrapCrossAlignment.end, + children: [ + Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Text( + isEn + ? lectures.first.commonTitleEn + : lectures.first.commonTitle, + style: bodyBold, + ), + const SizedBox(width: 4), + Text(lectures.first.oldCode, style: bodyRegular), + ], + ), + Text.rich( + TextSpan( + style: labelRegular.copyWith(color: OTLColor.grayA), + children: [ + TextSpan(text: lectures.first.departmentCode), + const TextSpan(text: " / "), + TextSpan( + text: + isEn ? lectures.first.typeEn : lectures.first.type, ), ], ), ), - Padding( - padding: EdgeInsets.symmetric(vertical: 4.0), - child: SizedBox( - height: 1, - child: ColoredBox( - color: Color(0xFFDADADA), - ), - ), - ), - ...lectures.map((lecture) => LectureGroupBlockRow( - lecture: lecture, - onLongPress: () => onLongPress(lecture), - )), - ]), - ), + ], + ), + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 4.0), + child: SizedBox( + height: 1, + child: ColoredBox( + color: Color(0xFFDADADA), + ), + ), + ), + ...lectures.map( + (lecture) => LectureGroupBlockRow( + lecture: lecture, + onLongPress: () => onLongPress(lecture), + ), + ), + ], ), ); } diff --git a/lib/widgets/lecture_group_block_row.dart b/lib/widgets/lecture_group_block_row.dart index 8b15a20a..798195f7 100644 --- a/lib/widgets/lecture_group_block_row.dart +++ b/lib/widgets/lecture_group_block_row.dart @@ -1,6 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:otlplus/constants/color.dart'; +import 'package:otlplus/constants/text_styles.dart'; import 'package:otlplus/extensions/lecture.dart'; import 'package:otlplus/models/lecture.dart'; import 'package:otlplus/providers/lecture_search_model.dart'; @@ -27,6 +28,7 @@ class _LectureGroupBlockRowState extends State { RegExp exp = new RegExp(r"[^A-Z]"); @override Widget build(BuildContext context) { + final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en'); final alreadyAdded = context.select((model) => model.currentTimetable.lectures.any((lec) => lec.oldCode == widget.lecture.oldCode && @@ -62,21 +64,27 @@ class _LectureGroupBlockRowState extends State { padding: const EdgeInsets.fromLTRB(8, 6, 0, 6), child: Wrap( children: [ - Text.rich(TextSpan(children: [ + Text.rich( TextSpan( - text: widget.lecture.classTitle, - style: TextStyle( - fontSize: 14.0, fontWeight: FontWeight.bold)), - WidgetSpan( - child: SizedBox( - width: 8, - ), + children: [ + TextSpan( + text: widget.lecture.classTitle, + style: bodyBold, + ), + WidgetSpan( + child: const SizedBox(width: 8), + ), + WidgetSpan( + child: Text( + isEn + ? widget.lecture.professorsStrShortEn + : widget.lecture.professorsStrShort, + style: bodyRegular, + ), + ) + ], ), - WidgetSpan( - child: Text(widget.lecture.professorsStrShort, - style: TextStyle( - fontSize: 14.0, color: Colors.black54))) - ])) + ) ], ), ), @@ -138,9 +146,8 @@ class _LectureGroupBlockRowState extends State { 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()), actions: [ IconTextButton( padding: EdgeInsets.all(12), diff --git a/lib/widgets/lecture_search.dart b/lib/widgets/lecture_search.dart index c15e7a54..3ee1bafe 100644 --- a/lib/widgets/lecture_search.dart +++ b/lib/widgets/lecture_search.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:otlplus/utils/build_page_route.dart'; -import 'package:otlplus/pages/lecture_search_page.dart'; import 'package:otlplus/utils/responsive_button.dart'; import 'package:provider/provider.dart'; import 'package:otlplus/constants/color.dart'; @@ -29,7 +28,7 @@ class _LectureSearchState extends State { return WillPopScope( onWillPop: widget.onClosed, child: ColoredBox( - color: Colors.white, + color: OTLColor.grayF, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -38,16 +37,15 @@ class _LectureSearchState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( - child: Padding( - padding: const EdgeInsets.fromLTRB(16, 12, 0, 12), - child: ClipRRect( + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 0, 12), + child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(8.0)), child: BackgroundButton( onTap: () => Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - LectureSearchPage(openKeyboard: false))), - color: Color(0xFFF9F0F0), + buildLectureSearchPageRoute(true), + ), + color: OTLColor.pinksLight, child: Padding( padding: EdgeInsets.all(8.0), child: SizedBox( @@ -56,22 +54,29 @@ class _LectureSearchState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - SvgPicture.asset('assets/icons/search.svg', - height: 24.0, - width: 24.0, - colorFilter: ColorFilter.mode( - OTLColor.pinksMain, BlendMode.srcIn)), + SvgPicture.asset( + 'assets/icons/search.svg', + height: 24.0, + width: 24.0, + colorFilter: ColorFilter.mode( + OTLColor.pinksMain, + BlendMode.srcIn, + ), + ), SizedBox(width: 12.0), Flexible( - child: context - .watch() - .lectureSearchquery), + child: context + .watch() + .lectureSearchquery, + ), ], ), ), ), - )), - )), + ), + ), + ), + ), IconTextButton( padding: EdgeInsets.fromLTRB(8, 12, 16, 12), icon: Icons.close_outlined, @@ -88,7 +93,9 @@ class _LectureSearchState extends State { : Scrollbar( controller: _scrollController, child: _buildListView( - searchModel.lectures ?? [[]], _scrollController), + searchModel.lectures ?? [[]], + _scrollController, + ), ), ), ], @@ -98,7 +105,9 @@ class _LectureSearchState extends State { } ListView _buildListView( - List> lectures, ScrollController scrollController) { + List> lectures, + ScrollController scrollController, + ) { return ListView.separated( padding: EdgeInsets.fromLTRB(16, 0, 16, 12), controller: scrollController, From ecbc3205da46376b1a7c1cafdb57ed413352d1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=8A=B9=ED=98=B8?= Date: Thu, 3 Aug 2023 01:27:18 +0900 Subject: [PATCH 2/2] fix: timetable translate 2 --- assets/translations/en.json | 4 ++-- assets/translations/ko.json | 2 +- lib/pages/timetable_page.dart | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 10a4ea67..2855c921 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -54,8 +54,8 @@ "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 {}", "dialog": { diff --git a/assets/translations/ko.json b/assets/translations/ko.json index 76787269..0b1bde2a 100644 --- a/assets/translations/ko.json +++ b/assets/translations/ko.json @@ -55,7 +55,7 @@ }, "timetable": { "ask_delete_lecture": "'{}' 수업을 삭제하시겠습니까?", - "ask_delete_tab": "{}을(를) 정말 삭제하시겠습니까?", + "ask_delete_tab": "'{}'을(를) 정말 삭제하시겠습니까?", "my_tab": "내 시간표", "tab": "시간표 {}", "dialog": { diff --git a/lib/pages/timetable_page.dart b/lib/pages/timetable_page.dart index a529ebfc..9c702d82 100644 --- a/lib/pages/timetable_page.dart +++ b/lib/pages/timetable_page.dart @@ -150,9 +150,13 @@ class _TimetablePageState extends State { } Timetable _buildTimetable( - BuildContext context, List lectures, bool isExamTime) { + BuildContext context, + List lectures, + bool isExamTime, + ) { bool isFirst = true; final lectureSearchModel = context.watch(); + final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en'); return Timetable( lectures: (lectureSearchModel.selectedLecture == null) @@ -189,7 +193,7 @@ class _TimetablePageState extends State { builder: (context) => AlertDialog( title: Text("common.delete".tr()), content: Text("timetable.ask_delete_lecture").tr( - args: [lecture.title], + args: [isEn ? lecture.titleEn : lecture.title], ), actions: [ IconTextButton( @@ -283,7 +287,9 @@ class _TimetablePageState extends State { color: Colors.white, child: Text( 'timetable.ask_delete_tab'.tr(args: [ - 'timetable.tab'.tr(args: [i.toString()]) + 'timetable.tab'.tr( + args: [i.toString()], + ) ]), style: TextStyle( fontSize: 12,