Skip to content

Commit

Permalink
Merge pull request #480 from kooWZ/dev
Browse files Browse the repository at this point in the history
fix #463, #478
  • Loading branch information
w568w authored Jan 6, 2025
2 parents af1cc0b + 4291ac6 commit c86ed34
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 92 deletions.
15 changes: 13 additions & 2 deletions lib/feature/bus_feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<BusScheduleItem> 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();
Expand Down
3 changes: 1 addition & 2 deletions lib/feature/ecard_balance_feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/feature/next_course_feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class NextCourseFeature extends Feature {
),
Text(
S.of(context!).exam_schedule,
textScaleFactor: 0.8,
textScaler: TextScaler.linear(0.8),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/feature/welcome_feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: () {
Expand Down
2 changes: 1 addition & 1 deletion lib/page/dashboard/announcement_notices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class AnnouncementListState extends State<AnnouncementList> {
? S.of(context).older_announcement
: S.of(context).latest_announcement,
softWrap: true,
textScaleFactor: MediaQuery.textScaleFactorOf(context),
textScaler: MediaQuery.textScalerOf(context),
),
onPressed: () => setState(() => _showingLatest = !_showingLatest),
)
Expand Down
33 changes: 12 additions & 21 deletions lib/page/dashboard/bus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,20 @@ class BusPageState extends State<BusPage> {
});
}

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<BusScheduleItem> _filterBus(List<BusScheduleItem> 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();
Expand Down Expand Up @@ -249,8 +241,7 @@ class BusPageState extends State<BusPage> {
padding: const EdgeInsets.only(top: 8, bottom: 4),
child: CupertinoSlidingSegmentedControl<int>(
onValueChanged: (int? value) {
_onStartLocationChanged(
Campus.values[value!]);
_onStartLocationChanged(Campus.values[value!]);
},
groupValue: _startSelectItem?.index,
children: _getCupertinoItems(),
Expand Down
4 changes: 2 additions & 2 deletions lib/page/dashboard/empty_classroom_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ class EmptyClassroomDetailPageState extends State<EmptyClassroomDetailPage> {
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),
),
],
Expand Down
81 changes: 38 additions & 43 deletions lib/page/dashboard/exam_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class ExamListState extends State<ExamList> {
snapShot.data!
.firstWhere((element) => element.id == _info!.id)
.gpa,
textScaleFactor: 1.25,
textScaler: TextScaler.linear(1.25),
style: const TextStyle(color: Colors.white),
);
},
Expand Down Expand Up @@ -377,6 +377,27 @@ class ExamListState extends State<ExamList> {
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),
Expand All @@ -390,7 +411,7 @@ class ExamListState extends State<ExamList> {
children: [
Text(
"${value.testCategory} ${value.type}",
textScaleFactor: 0.8,
textScaler: TextScaler.linear(0.8),
style: TextStyle(color: Theme.of(context).hintColor),
),
Text(
Expand All @@ -406,7 +427,7 @@ class ExamListState extends State<ExamList> {
if (value.date != "" || value.time != "") ...[
Text(
"${value.date} ${value.time}",
textScaleFactor: 0.8,
textScaler: TextScaler.linear(0.8)
),
const SizedBox(
width: 8,
Expand All @@ -415,14 +436,14 @@ class ExamListState extends State<ExamList> {
...[],
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),
),
],
Expand All @@ -449,33 +470,15 @@ class ExamListState extends State<ExamList> {
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.
Expand All @@ -494,6 +497,7 @@ class ExamListState extends State<ExamList> {
)),
);

// Grade card without exam data
Widget _buildCardGrade(ExamScore value, BuildContext context) => Card(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
Expand All @@ -508,7 +512,7 @@ class ExamListState extends State<ExamList> {
children: [
Text(
value.type,
textScaleFactor: 0.8,
textScaler: TextScaler.linear(0.8),
style: TextStyle(color: Theme.of(context).hintColor),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expand All @@ -521,16 +525,7 @@ class ExamListState extends State<ExamList> {
],
),
),
Container(
width: 28,
alignment: Alignment.centerLeft,
child: Center(
child: Text(
value.level,
textScaleFactor: 1.2,
),
),
),
_buildGradeContainer(value.level, value.score)
],
)),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/page/forum/hole_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class OTMessagesPageState extends State<OTMessagesPage> {
? S.of(context).show_all
: S.of(context).show_unread,
softWrap: true,
textScaleFactor: MediaQuery.textScaleFactorOf(context),
textScaler: MediaQuery.textScalerOf(context),
),
onPressed: () async {
setState(() {
Expand Down
2 changes: 1 addition & 1 deletion lib/page/subpage_dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class HomeSubpage extends PlatformSubpage<HomeSubpage> {
Create<List<AppBarButtonItem>> 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()))
];
Expand Down
10 changes: 5 additions & 5 deletions lib/page/subpage_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ class SettingsSubpageState extends PlatformSubpageState<SettingsSubpage> {
//Description
Text(
S.of(context).app_description_title,
textScaleFactor: 1.1,
textScaler: TextScaler.linear(1.1)
),
Divider(
color: originalDividerColor,
Expand All @@ -1001,7 +1001,7 @@ class SettingsSubpageState extends PlatformSubpageState<SettingsSubpage> {
//Terms and Conditions
Text(
S.of(context).terms_and_conditions_title,
textScaleFactor: 1.1,
textScaler: TextScaler.linear(1.1)
),
Divider(
color: originalDividerColor,
Expand Down Expand Up @@ -1037,7 +1037,7 @@ class SettingsSubpageState extends PlatformSubpageState<SettingsSubpage> {
//Acknowledgement
Text(
S.of(context).acknowledgements,
textScaleFactor: 1.1,
textScaler: TextScaler.linear(1.1)
),
Divider(color: originalDividerColor),
PostRenderWidget(
Expand All @@ -1052,7 +1052,7 @@ class SettingsSubpageState extends PlatformSubpageState<SettingsSubpage> {
// Authors
Text(
S.of(context).authors,
textScaleFactor: 1.1,
textScaler: TextScaler.linear(1.1)
),
Divider(color: originalDividerColor),
const SizedBox(height: 4),
Expand All @@ -1078,7 +1078,7 @@ class SettingsSubpageState extends PlatformSubpageState<SettingsSubpage> {
children: <Widget>[
Text(
S.of(context).author_descriptor,
textScaleFactor: 0.7,
textScaler: TextScaler.linear(0.7),
textAlign: TextAlign.right,
)
],
Expand Down
Loading

0 comments on commit c86ed34

Please sign in to comment.