diff --git a/lib/feature/bus_feature.dart b/lib/feature/bus_feature.dart index fc8a0479..3a18701b 100644 --- a/lib/feature/bus_feature.dart +++ b/lib/feature/bus_feature.dart @@ -100,11 +100,11 @@ class BusFeature extends Feature { switch (element.direction) { case BusDirection.NONE: break; - case BusDirection.DUAL: case BusDirection.BACKWARD: from = element.end; to = element.start; break; + case BusDirection.DUAL: case BusDirection.FORWARD: from = element.start; to = element.end; @@ -129,8 +129,19 @@ class BusFeature extends Feature { } BusScheduleItem? nextBusForCampus(Campus campus) { + // Split dual-direction bus with different start times into two single-direction buses to avoid confusion. final List filteredBusList = _busList! - .where((element) => element.start == campus || element.end == campus) + .where((element) => (element.start == campus || element.end == campus)) + .expand(((element) => (element.direction == BusDirection.DUAL && + !element.startTime! + .toExactTime() + .isAtSameMomentAs(element.endTime!.toExactTime())) + ? [ + element.copyWith(direction: BusDirection.FORWARD), + BusScheduleItem.reversed(element) + .copyWith(direction: BusDirection.FORWARD) + ] + : [element])) .toList(); // Get the next bus time filteredBusList.sort(); diff --git a/lib/feature/ecard_balance_feature.dart b/lib/feature/ecard_balance_feature.dart index 9d9392c6..eb3dddf8 100644 --- a/lib/feature/ecard_balance_feature.dart +++ b/lib/feature/ecard_balance_feature.dart @@ -23,7 +23,6 @@ import 'package:dan_xi/provider/state_provider.dart'; import 'package:dan_xi/repository/fdu/ecard_repository.dart'; import 'package:dan_xi/util/master_detail_view.dart'; import 'package:dan_xi/util/platform_universal.dart'; -import 'package:dan_xi/util/retrier.dart'; import 'package:dan_xi/widget/feature_item/feature_progress_indicator.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -102,7 +101,7 @@ class EcardBalanceFeature extends Feature { } else if (_status == ConnectionStatus.DONE) { return Text( Constant.yuanSymbol(_balance), - textScaleFactor: 1.2, + textScaler: TextScaler.linear(1.2), style: TextStyle( color: num.tryParse(_balance!) == null ? null diff --git a/lib/feature/next_course_feature.dart b/lib/feature/next_course_feature.dart index b32aa620..945ba6ce 100644 --- a/lib/feature/next_course_feature.dart +++ b/lib/feature/next_course_feature.dart @@ -140,7 +140,7 @@ class NextCourseFeature extends Feature { ), Text( S.of(context!).exam_schedule, - textScaleFactor: 0.8, + textScaler: TextScaler.linear(0.8), ), ], ), diff --git a/lib/feature/welcome_feature.dart b/lib/feature/welcome_feature.dart index ccf52857..71a6da7c 100644 --- a/lib/feature/welcome_feature.dart +++ b/lib/feature/welcome_feature.dart @@ -156,7 +156,7 @@ class WelcomeFeature extends Feature { children: [ status, const SizedBox(height: 2), - Text(S.of(context!).entry_permission, textScaleFactor: 0.8) + Text(S.of(context!).entry_permission, textScaler: TextScaler.linear(0.8)) ], ), onTap: () { diff --git a/lib/page/dashboard/announcement_notices.dart b/lib/page/dashboard/announcement_notices.dart index 283e4a4f..50cb564b 100644 --- a/lib/page/dashboard/announcement_notices.dart +++ b/lib/page/dashboard/announcement_notices.dart @@ -70,7 +70,7 @@ class AnnouncementListState extends State { ? S.of(context).older_announcement : S.of(context).latest_announcement, softWrap: true, - textScaleFactor: MediaQuery.textScaleFactorOf(context), + textScaler: MediaQuery.textScalerOf(context), ), onPressed: () => setState(() => _showingLatest = !_showingLatest), ) diff --git a/lib/page/dashboard/bus.dart b/lib/page/dashboard/bus.dart index 3b469156..226f4717 100644 --- a/lib/page/dashboard/bus.dart +++ b/lib/page/dashboard/bus.dart @@ -155,28 +155,20 @@ class BusPageState extends State { }); } - void swapBusDetails(BusScheduleItem element) { - final start = element.start; - element.start = element.end; - element.end = start; - final startTime = element.startTime; - element.startTime = element.endTime; - element.endTime = startTime; - } - List _filterBus(List origBusList) { // Normalize all backward entries and reversed dual entries - for (var element in origBusList) { - if (element.direction == BusDirection.BACKWARD) { - swapBusDetails(element); - element.direction = BusDirection.FORWARD; - } else if (element.direction == BusDirection.DUAL && - element.start == _endSelectItem && - element.end == _startSelectItem) { - swapBusDetails(element); - } - } return origBusList + .map((element) { + if (element.direction == BusDirection.BACKWARD) { + return BusScheduleItem.reversed(element); + } else if (element.direction == BusDirection.DUAL && + element.start == _endSelectItem && + element.end == _startSelectItem) { + return BusScheduleItem.reversed(element); + } else { + return element; + } + }) .where((element) => (element.start == _startSelectItem && element.end == _endSelectItem)) .toList(); @@ -249,8 +241,7 @@ class BusPageState extends State { padding: const EdgeInsets.only(top: 8, bottom: 4), child: CupertinoSlidingSegmentedControl( onValueChanged: (int? value) { - _onStartLocationChanged( - Campus.values[value!]); + _onStartLocationChanged(Campus.values[value!]); }, groupValue: _startSelectItem?.index, children: _getCupertinoItems(), diff --git a/lib/page/dashboard/empty_classroom_detail.dart b/lib/page/dashboard/empty_classroom_detail.dart index 46886d48..adc279bb 100644 --- a/lib/page/dashboard/empty_classroom_detail.dart +++ b/lib/page/dashboard/empty_classroom_detail.dart @@ -386,11 +386,11 @@ class EmptyClassroomDetailPageState extends State { children: [ Text( element.roomName!, - textScaleFactor: 1, + textScaler: TextScaler.linear(1) ), Text( S.of(context).seats(element.seats ?? "?"), - textScaleFactor: 0.8, + textScaler: TextScaler.linear(0.8), style: TextStyle(color: Theme.of(context).hintColor), ), ], diff --git a/lib/page/dashboard/exam_detail.dart b/lib/page/dashboard/exam_detail.dart index ebadfdf4..10d26050 100644 --- a/lib/page/dashboard/exam_detail.dart +++ b/lib/page/dashboard/exam_detail.dart @@ -307,7 +307,7 @@ class ExamListState extends State { snapShot.data! .firstWhere((element) => element.id == _info!.id) .gpa, - textScaleFactor: 1.25, + textScaler: TextScaler.linear(1.25), style: const TextStyle(color: Colors.white), ); }, @@ -377,6 +377,27 @@ class ExamListState extends State { Expanded(child: Divider(color: color)), ])); + Widget _buildGradeContainer(String level, String? score) => Container( + height: 36, + width: 36, + decoration: BoxDecoration( + border: Border.all( + color: Colors.white, + width: 1, + ), + ), + child: Column(children: [ + Center( + child: Text( + level, + ), + ), + Center( + child: Text(score!, textScaler: TextScaler.linear(0.6)), + ), + ])); + + // Grade card with exam data Widget _buildCardHybrid(Exam value, BuildContext context) => Card( child: Padding( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), @@ -390,7 +411,7 @@ class ExamListState extends State { children: [ Text( "${value.testCategory} ${value.type}", - textScaleFactor: 0.8, + textScaler: TextScaler.linear(0.8), style: TextStyle(color: Theme.of(context).hintColor), ), Text( @@ -406,7 +427,7 @@ class ExamListState extends State { if (value.date != "" || value.time != "") ...[ Text( "${value.date} ${value.time}", - textScaleFactor: 0.8, + textScaler: TextScaler.linear(0.8) ), const SizedBox( width: 8, @@ -415,14 +436,14 @@ class ExamListState extends State { ...[], Text( "${value.location} ", - textScaleFactor: 0.8, + textScaler: TextScaler.linear(0.8) ), ], ), if (value.note.trim() != "") Text( value.note, - textScaleFactor: 0.8, + textScaler: TextScaler.linear(0.8), style: TextStyle(color: Theme.of(context).hintColor), ), ], @@ -449,33 +470,15 @@ class ExamListState extends State { const SizedBox( width: 8, ), - Container( - height: 36, - width: 36, - decoration: BoxDecoration( - border: Border.all( - color: Colors.white, - width: 1, - ), - ), - child: Column(children: [ - Center( - child: Text( - _cachedScoreData! - .firstWhere((element) => - element.id == value.id) - .level, - ), - ), - Center( - child: Text( - _cachedScoreData! - .firstWhere((element) => - element.id == value.id) - .score!, - textScaleFactor: 0.6), - ), - ])) + _buildGradeContainer( + _cachedScoreData! + .firstWhere( + (element) => element.id == value.id) + .level, + _cachedScoreData! + .firstWhere( + (element) => element.id == value.id) + .score) ], ); // If we cannot find such an element, we will build an empty SizedBox. @@ -494,6 +497,7 @@ class ExamListState extends State { )), ); + // Grade card without exam data Widget _buildCardGrade(ExamScore value, BuildContext context) => Card( child: Padding( padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), @@ -508,7 +512,7 @@ class ExamListState extends State { children: [ Text( value.type, - textScaleFactor: 0.8, + textScaler: TextScaler.linear(0.8), style: TextStyle(color: Theme.of(context).hintColor), maxLines: 1, overflow: TextOverflow.ellipsis, @@ -521,16 +525,7 @@ class ExamListState extends State { ], ), ), - Container( - width: 28, - alignment: Alignment.centerLeft, - child: Center( - child: Text( - value.level, - textScaleFactor: 1.2, - ), - ), - ), + _buildGradeContainer(value.level, value.score) ], )), ); diff --git a/lib/page/forum/hole_messages.dart b/lib/page/forum/hole_messages.dart index 95195bab..87d57165 100644 --- a/lib/page/forum/hole_messages.dart +++ b/lib/page/forum/hole_messages.dart @@ -97,7 +97,7 @@ class OTMessagesPageState extends State { ? S.of(context).show_all : S.of(context).show_unread, softWrap: true, - textScaleFactor: MediaQuery.textScaleFactorOf(context), + textScaler: MediaQuery.textScalerOf(context), ), onPressed: () async { setState(() { diff --git a/lib/page/subpage_dashboard.dart b/lib/page/subpage_dashboard.dart index 27c13361..c38fb648 100644 --- a/lib/page/subpage_dashboard.dart +++ b/lib/page/subpage_dashboard.dart @@ -64,7 +64,7 @@ class HomeSubpage extends PlatformSubpage { Create> get trailing => (cxt) => [ AppBarButtonItem( S.of(cxt).dashboard_layout, - Text(S.of(cxt).edit, textScaleFactor: 1.2), + Text(S.of(cxt).edit, textScaler: TextScaler.linear(1.2)), () => smartNavigatorPush(cxt, '/dashboard/reorder').then( (value) => RefreshHomepageEvent(onlyRefreshOrder: true).fire())) ]; diff --git a/lib/page/subpage_settings.dart b/lib/page/subpage_settings.dart index 12c9fbad..e0b28a21 100644 --- a/lib/page/subpage_settings.dart +++ b/lib/page/subpage_settings.dart @@ -991,7 +991,7 @@ class SettingsSubpageState extends PlatformSubpageState { //Description Text( S.of(context).app_description_title, - textScaleFactor: 1.1, + textScaler: TextScaler.linear(1.1) ), Divider( color: originalDividerColor, @@ -1001,7 +1001,7 @@ class SettingsSubpageState extends PlatformSubpageState { //Terms and Conditions Text( S.of(context).terms_and_conditions_title, - textScaleFactor: 1.1, + textScaler: TextScaler.linear(1.1) ), Divider( color: originalDividerColor, @@ -1037,7 +1037,7 @@ class SettingsSubpageState extends PlatformSubpageState { //Acknowledgement Text( S.of(context).acknowledgements, - textScaleFactor: 1.1, + textScaler: TextScaler.linear(1.1) ), Divider(color: originalDividerColor), PostRenderWidget( @@ -1052,7 +1052,7 @@ class SettingsSubpageState extends PlatformSubpageState { // Authors Text( S.of(context).authors, - textScaleFactor: 1.1, + textScaler: TextScaler.linear(1.1) ), Divider(color: originalDividerColor), const SizedBox(height: 4), @@ -1078,7 +1078,7 @@ class SettingsSubpageState extends PlatformSubpageState { children: [ Text( S.of(context).author_descriptor, - textScaleFactor: 0.7, + textScaler: TextScaler.linear(0.7), textAlign: TextAlign.right, ) ], diff --git a/lib/repository/fdu/bus_repository.dart b/lib/repository/fdu/bus_repository.dart index ce24194f..c98e0b9f 100644 --- a/lib/repository/fdu/bus_repository.dart +++ b/lib/repository/fdu/bus_repository.dart @@ -22,7 +22,6 @@ import 'package:dan_xi/model/person.dart'; import 'package:dan_xi/repository/base_repository.dart'; import 'package:dan_xi/repository/fdu/uis_login_tool.dart'; import 'package:dan_xi/util/public_extension_methods.dart'; -import 'package:dan_xi/util/retrier.dart'; import 'package:dan_xi/util/vague_time.dart'; import 'package:dio/dio.dart'; import 'package:intl/intl.dart'; @@ -94,6 +93,20 @@ class BusScheduleItem implements Comparable { return VagueTime.onlyHHmm(time.replaceAll(".", ":")); } + BusScheduleItem.reversed(BusScheduleItem original) + : id = original.id, + start = original.end, + end = original.start, + startTime = original.endTime, + endTime = original.startTime, + direction = original.direction.reverse(), + holidayRun = original.holidayRun; + + BusScheduleItem copyWith({BusDirection? direction}) { + return BusScheduleItem(id, start, end, startTime, endTime, + direction ?? this.direction, holidayRun); + } + @override int compareTo(BusScheduleItem other) => realStartTime!.compareTo(other.realStartTime!); @@ -132,6 +145,17 @@ extension BusDirectionExtension on BusDirection { return null; } } + + BusDirection reverse() { + switch (this) { + case BusDirection.FORWARD: + return BusDirection.BACKWARD; + case BusDirection.BACKWARD: + return BusDirection.FORWARD; + default: + return this; + } + } } extension VagueTimeExtension on VagueTime { diff --git a/lib/repository/fdu/data_center_repository.dart b/lib/repository/fdu/data_center_repository.dart index 41b0484b..e4bc6a9b 100644 --- a/lib/repository/fdu/data_center_repository.dart +++ b/lib/repository/fdu/data_center_repository.dart @@ -23,7 +23,6 @@ import 'package:dan_xi/repository/base_repository.dart'; import 'package:dan_xi/repository/fdu/edu_service_repository.dart'; import 'package:dan_xi/repository/fdu/uis_login_tool.dart'; import 'package:dan_xi/util/public_extension_methods.dart'; -import 'package:dan_xi/util/retrier.dart'; import 'package:dio/dio.dart'; import 'package:html/dom.dart' as dom; diff --git a/lib/repository/fdu/time_table_repository.dart b/lib/repository/fdu/time_table_repository.dart index c64f6d50..8426e0dd 100644 --- a/lib/repository/fdu/time_table_repository.dart +++ b/lib/repository/fdu/time_table_repository.dart @@ -25,7 +25,6 @@ import 'package:dan_xi/repository/base_repository.dart'; import 'package:dan_xi/repository/fdu/uis_login_tool.dart'; import 'package:dan_xi/util/io/cache.dart'; import 'package:dan_xi/util/io/dio_utils.dart'; -import 'package:dan_xi/util/retrier.dart'; import 'package:dio/dio.dart'; import 'package:html/dom.dart' as dom; diff --git a/lib/widget/forum/horizontal_selector.dart b/lib/widget/forum/horizontal_selector.dart index 3dbc5093..9ebc5fc1 100644 --- a/lib/widget/forum/horizontal_selector.dart +++ b/lib/widget/forum/horizontal_selector.dart @@ -55,7 +55,7 @@ class HorizontalSelector extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4), child: Text( e.toString(), - textScaleFactor: selectedOption == e ? 1.25 : 1.0, + textScaler: TextScaler.linear(selectedOption == e ? 1.25 : 1.0), style: TextStyle( color: selectedOption == e ? null diff --git a/lib/widget/libraries/platform_app_bar_ex.dart b/lib/widget/libraries/platform_app_bar_ex.dart index e0c402a5..eb15c29f 100644 --- a/lib/widget/libraries/platform_app_bar_ex.dart +++ b/lib/widget/libraries/platform_app_bar_ex.dart @@ -73,7 +73,7 @@ class PlatformAppBarX extends PlatformAppBar { bottom: data?.bottom, actions: data?.actions ?? trailingActions, automaticallyImplyLeading: - data?.automaticallyImplyLeading ?? automaticallyImplyLeading ?? true, + data?.automaticallyImplyLeading ?? automaticallyImplyLeading ?? true, bottomOpacity: data?.bottomOpacity ?? 1.0, toolbarTextStyle: data?.toolbarTextStyle, centerTitle: data?.centerTitle, @@ -104,17 +104,13 @@ class PlatformAppBarX extends PlatformAppBar { // will push the list down. Adding some alpha value fixes it (in a hacky way) //backgroundColor: Colors.white.withAlpha(254), leading: MediaQuery( - data: MediaQueryData( - textScaler: - TextScaler.linear(MediaQuery.textScaleFactorOf(context))), + data: MediaQueryData(textScaler: MediaQuery.textScalerOf(context)), child: CupertinoNavigationBarBackButton( onPressed: () => Navigator.of(context).pop(), ), ), title: MediaQuery( - data: MediaQueryData( - textScaler: - TextScaler.linear(MediaQuery.textScaleFactorOf(context))), + data: MediaQueryData(textScaler: MediaQuery.textScalerOf(context)), child: data?.title ?? title!), ); var trailing = trailingActions?.isEmpty ?? true @@ -151,7 +147,7 @@ class PlatformAppBarX extends PlatformAppBar { middle: defaultData.title ?? title, backgroundColor: defaultData.backgroundColor ?? backgroundColor, automaticallyImplyLeading: - data?.automaticallyImplyLeading ?? automaticallyImplyLeading ?? true, + data?.automaticallyImplyLeading ?? automaticallyImplyLeading ?? true, automaticallyImplyMiddle: data?.automaticallyImplyMiddle ?? true, previousPageTitle: data?.previousPageTitle, padding: data?.padding,