Skip to content

Commit

Permalink
[add]实验详情可关闭
Browse files Browse the repository at this point in the history
  • Loading branch information
hxphieno committed Sep 3, 2024
1 parent 5c0aac9 commit 2b05daa
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 4 deletions.
44 changes: 44 additions & 0 deletions lib/auth/view/settings/general_setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,50 @@ class _GeneralSettingPageState extends State<GeneralSettingPage> {
),
),
SizedBox(height: 10.h),
Container(
padding: EdgeInsets.fromLTRB(20.w, 10.h, 15.w, 10.h),
decoration: BoxDecoration(
color: WpyTheme.of(context)
.get(WpyColorKey.primaryBackgroundColor),
borderRadius: BorderRadius.circular(12.r),
),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('实验课显示详细内容',
style: mainTextStyle),
SizedBox(height: 3.h),
Text('若开启时遇到课表显示问题,可在此处关闭',
style: hintTextStyle)
],
),
),
Switch(
value: CommonPreferences.isShowExperiment.value,
onChanged: (value) {
setState(
() => CommonPreferences.isShowExperiment.value = value);
Provider.of<CourseDisplayProvider>(context,
listen: false)
.showExperiment = value;
},
activeColor: WpyTheme.of(context)
.get(WpyColorKey.oldSecondaryActionColor),
inactiveThumbColor:
WpyTheme.of(context).get(WpyColorKey.oldHintColor),
activeTrackColor: WpyTheme.of(context)
.get(WpyColorKey.oldSwitchBarColor),
inactiveTrackColor: WpyTheme.of(context)
.get(WpyColorKey.oldSwitchBarColor),
),
],
),
),
SizedBox(height: 10.h),
Container(
padding: EdgeInsets.fromLTRB(20.w, 10.h, 15.w, 10.h),
decoration: BoxDecoration(
Expand Down
1 change: 1 addition & 0 deletions lib/commons/preferences/common_prefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class CommonPreferences {
/// 自定义课表
static final customCourseToken = PrefsBean<String>('customCourseToken');
static final courseAppBarShrink = PrefsBean<bool>('courseAppBarShrink');
static final isShowExperiment = PrefsBean<bool>('isShowExperiment',true);

/// 学期信息
/// 修改termStart默认值的时候,记得也修改下kotlin/com.twt.service/widget/SchedulePreferences.kt中的默认值
Expand Down
4 changes: 3 additions & 1 deletion lib/schedule/extension/ui_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:we_pei_yang_flutter/schedule/model/course.dart';
import 'package:we_pei_yang_flutter/schedule/view/course_detail_widget.dart';
import 'package:we_pei_yang_flutter/schedule/view/course_dialog.dart';

import '../../commons/preferences/common_prefs.dart';

class AnimatedActiveCourse extends StatelessWidget {
static const _duration = const Duration(milliseconds: 375);
final List<Pair<Course, int>> _pairs;
Expand Down Expand Up @@ -77,7 +79,7 @@ class AnimatedActiveCourse extends StatelessWidget {
Spacer(),
Text(
formatText(
!_pairs[0].arrange.isExperiment
!(_pairs[0].arrange.isExperiment& CommonPreferences.isShowExperiment.value)
? _pairs[0].first.name
: _pairs[0].arrange.name!,
),
Expand Down
7 changes: 7 additions & 0 deletions lib/schedule/model/course_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,11 @@ class CourseDisplayProvider with ChangeNotifier {
}

bool get nightMode => CommonPreferences.nightMode.value;

set showExperiment(bool value){
CommonPreferences.isShowExperiment.value=value;
notifyListeners();
}

bool get showExperiment => CommonPreferences.isShowExperiment.value;
}
5 changes: 3 additions & 2 deletions lib/schedule/view/course_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:we_pei_yang_flutter/schedule/model/course.dart';
import 'package:we_pei_yang_flutter/schedule/model/edit_provider.dart';
import 'package:we_pei_yang_flutter/schedule/page/edit_detail_page.dart';

import '../../commons/preferences/common_prefs.dart';
import '../../commons/themes/wpy_theme.dart';
import '../../commons/widgets/w_button.dart';

Expand Down Expand Up @@ -71,7 +72,7 @@ class CourseDialog extends Dialog {

Widget _getSingleCard(BuildContext context, Pair<Course, int> pair) {
var teacher = '';
final _teachers = pair.arrange.isExperiment
final _teachers = (pair.arrange.isExperiment&CommonPreferences.isShowExperiment.value)
? pair.arrange.teacherList
: pair.first.teacherList;
_teachers.forEach((str) {
Expand Down Expand Up @@ -114,7 +115,7 @@ class CourseDialog extends Dialog {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
pair.arrange.isExperiment
(pair.arrange.isExperiment&CommonPreferences.isShowExperiment.value)
? "${pair.first.name}\n"
"${pair.arrange.name!}"
: pair.first.name,
Expand Down
3 changes: 2 additions & 1 deletion lib/schedule/view/wpy_course_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:we_pei_yang_flutter/schedule/extension/logic_extension.dart';
import 'package:we_pei_yang_flutter/schedule/model/course.dart';
import 'package:we_pei_yang_flutter/schedule/model/course_provider.dart';

import '../../commons/preferences/common_prefs.dart';
import '../../commons/widgets/w_button.dart';

class TodayCoursesWidget extends StatelessWidget {
Expand Down Expand Up @@ -107,7 +108,7 @@ class TodayCoursesWidget extends StatelessWidget {
SizedBox(
width: 1.sw - 125.w - 50.r,
child: Text(
todayPairs[i].arrange.isExperiment
(todayPairs[i].arrange.isExperiment&CommonPreferences.isShowExperiment.value)
? "[实验] ${todayPairs[i].arrange.name!}"
: todayPairs[i].first.name,
style: TextUtil.base.PingFangSC
Expand Down

0 comments on commit 2b05daa

Please sign in to comment.