Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #130 from CCXXXI/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
CCXXXI committed Oct 23, 2021
2 parents 4a782d5 + 3eb1c0b commit 8e8269e
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 292 deletions.
24 changes: 0 additions & 24 deletions lib/dev/dev_logic.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter_loggy/flutter_loggy.dart';
import 'package:get/get.dart';

import '../toolbox/toolbox_logic.dart';
import '../utils/database.dart';
import '../utils/gu.dart';
import '../utils/loading.dart';
Expand All @@ -10,29 +9,6 @@ import 'cheater_view.dart';
import 'trivia_view.dart';

class DevLogic extends GetxController with L {
final toolboxLogic = Get.find<ToolboxLogic>();

void suckerOnChanged(bool v) {
toolbox
..sucker = v
..save();
toolboxLogic.updateSuckerEnabled(v);
}

void cheaterOnChanged(bool v) {
toolbox
..cheater = v
..save();
toolboxLogic.updateCheaterEnabled(v);
}

void juanOnChanged(bool v) {
toolbox
..juan = v
..save();
toolboxLogic.updateJuanEnabled(v);
}

void levelOnChanged(String v) {
log
..level = v
Expand Down
23 changes: 0 additions & 23 deletions lib/dev/dev_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,6 @@ class DevPage extends StatelessWidget {
appBar: AppBar(title: const Text('开发者选项')),
body: ListView(
children: [
SettingsGroup(
title: '工具箱',
children: [
SwitchSettingsTile(
title: 'sucker',
settingKey: 'toolbox.sucker',
defaultValue: toolbox.sucker,
onChange: logic.suckerOnChanged,
),
SwitchSettingsTile(
title: 'cheater',
settingKey: 'toolbox.cheater',
defaultValue: toolbox.cheater,
onChange: logic.cheaterOnChanged,
),
SwitchSettingsTile(
title: 'juan',
settingKey: 'toolbox.juan',
defaultValue: toolbox.juan,
onChange: logic.juanOnChanged,
),
],
),
SettingsGroup(
title: '日志',
children: [
Expand Down
50 changes: 26 additions & 24 deletions lib/timetable/ecnu/ecnu_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,34 @@ class EcnuPage extends StatelessWidget {
subtitle: const Text('并确认课表内容无误。'),
content: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
width: 200,
child: DropDownSettingsTile(
title: '学年',
settingKey: 'timetable.year.$hashCode',
selected: logic.year.value,
values: logic.years,
enabled: logic.isLoading.isFalse,
onChange: logic.yearOnChanged,
FittedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
width: 200,
child: DropDownSettingsTile(
title: '学年',
settingKey: 'timetable.year.$hashCode',
selected: logic.year.value,
values: logic.years,
enabled: logic.isLoading.isFalse,
onChange: logic.yearOnChanged,
),
),
),
SizedBox(
width: 200,
child: DropDownSettingsTile(
title: '学期',
settingKey: 'timetable.semester.$hashCode',
selected: logic.semester.value,
values: logic.semesters,
enabled: logic.isLoading.isFalse,
onChange: logic.semesterOnChanged,
SizedBox(
width: 200,
child: DropDownSettingsTile(
title: '学期',
settingKey: 'timetable.semester.$hashCode',
selected: logic.semester.value,
values: logic.semesters,
enabled: logic.isLoading.isFalse,
onChange: logic.semesterOnChanged,
),
),
),
],
],
),
),
Text(
logic.coursesPreview.value,
Expand Down
32 changes: 29 additions & 3 deletions lib/timetable/timetable_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,38 @@ class TimetableLogic extends GetxController {
.where((unit) => _unitWeekday[unit].expand((l) => l).isNotEmpty)
.toList();

static List<List<String>> get areasRaw {
final r = <List<String>>[];

for (final weekday in ['x', ...weekdays]) {
r.add([]);
for (final z in zip([
['x', ...units],
['', 'x', ...units],
])) {
final unit = z.first;
final pre = z.last;
if (weekday == 'x' ||
unit == 'x' ||
unit == 0 ||
_weekdayUnit[weekday as int][unit as int].toString() !=
_weekdayUnit[weekday][pre as int].toString()) {
r.last.add('$weekday-$unit');
} else {
r.last.add(r.last.last);
}
}
}

return r;
}

static String get areas {
final r = StringBuffer();

for (final unit in ['x', ...units]) {
for (final weekday in ['x', ...weekdays]) {
r.write('$weekday-$unit ');
for (var unitIdx = 0; unitIdx <= units.length; unitIdx++) {
for (var weekdayIdx = 0; weekdayIdx <= weekdays.length; weekdayIdx++) {
r.write(areasRaw[weekdayIdx][unitIdx] + ' ');
}
r.writeln();
}
Expand Down
49 changes: 28 additions & 21 deletions lib/timetable/timetable_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,46 @@ class TimetablePage extends StatelessWidget {
children: [
...TimetableLogic.weekdays.map(
(i) => Center(
child: Text(
['一', '二', '三', '四', '五', '六', '日'][i],
textAlign: TextAlign.center,
child: FittedBox(
child: Text(
['一', '二', '三', '四', '五', '六', '日'][i],
textAlign: TextAlign.center,
),
),
).inGridArea('$i-x'),
),
...TimetableLogic.units.map(
(i) => Center(
child: Text(
[
'8:00\n8:45',
'8:50\n9:35',
'9:50\n10:35',
'10:40\n11:25',
'11:30\n12:15',
'13:00\n13:45',
'13:50\n14:35',
'14:50\n15:35',
'15:40\n16:25',
'16:30\n17:15',
'18:00\n18:45',
'18:50\n19:35',
'19:40\n20:25',
][i],
textAlign: TextAlign.center,
child: FittedBox(
child: Text(
[
'8:00\n8:45',
'8:50\n9:35',
'9:50\n10:35',
'10:40\n11:25',
'11:30\n12:15',
'13:00\n13:45',
'13:50\n14:35',
'14:50\n15:35',
'15:40\n16:25',
'16:30\n17:15',
'18:00\n18:45',
'18:50\n19:35',
'19:40\n20:25',
][i],
textAlign: TextAlign.center,
),
),
).inGridArea('x-$i'),
),
for (final course in courses.values)
for (final period in course.periods!)
Center(
child: Text(
'${course.courseName}',
'${course.courseName!.length <= 12 ? course.courseName : course.courseName!.substring(0, 11) + '...'}\n'
'${course.roomName! + course.specialRoom!}\n'
'${course.weeks!.sublist(1, 10).map((e) => e ? 'o' : 'x').join()}\n'
'${course.weeks!.sublist(10, 19).map((e) => e ? 'o' : 'x').join()}',
textAlign: TextAlign.center,
),
).inGridArea(
Expand Down
10 changes: 1 addition & 9 deletions lib/toolbox/calendar/calendar_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

Expand All @@ -20,14 +19,7 @@ class CalendarPage extends StatelessWidget {
() => Center(
child: logic.imgUrl.isEmpty
? Loading()
: CachedNetworkImage(
imageUrl: logic.imgUrl.value,
progressIndicatorBuilder: (_, __, downloadProgress) =>
CircularProgressIndicator(
value: downloadProgress.progress,
),
errorWidget: (_, url, error) => Text('$url\n$error'),
),
: Image.network(logic.imgUrl.value),
),
),
),
Expand Down
26 changes: 2 additions & 24 deletions lib/toolbox/toolbox_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

import '../utils/database.dart';
import '../utils/log.dart';
import '../utils/string.dart';
import '../utils/web.dart';
Expand All @@ -18,18 +17,11 @@ class ToolboxLogic extends GetxController with L {
@override
void onInit() {
super.onInit();
if (suckerEnabled.isTrue) updateSucker();
if (cheaterEnabled.isTrue) updateCheater();
updateSucker();
updateCheater();
}

// region sucker
final suckerEnabled = toolbox.sucker.obs;

updateSuckerEnabled(bool v) {
suckerEnabled.value = v;
if (v) updateSucker();
}

final sucker = ''.obs;

void updateSucker() async {
Expand Down Expand Up @@ -64,13 +56,6 @@ class ToolboxLogic extends GetxController with L {
// endregion

// region cheater
final cheaterEnabled = toolbox.cheater.obs;

updateCheaterEnabled(bool v) {
cheaterEnabled.value = v;
if (v) updateCheater();
}

final cheater = ''.obs;

void updateCheater() {
Expand All @@ -91,18 +76,11 @@ class ToolboxLogic extends GetxController with L {

// endregion

// region juan
final juanEnabled = toolbox.juan.obs;

updateJuanEnabled(bool v) => juanEnabled.value = v;

void juanOnTap() => Get.defaultDialog(
title: 'ceil(5*(2*a/b-1)*log(a-b+1))',
content: JuanWidget(),
);

// endregion

void calendarOnTap() {
if (GetPlatform.isWeb) {
Get.defaultDialog(
Expand Down
49 changes: 23 additions & 26 deletions lib/toolbox/toolbox_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,29 @@ class ToolboxPage extends StatelessWidget {
crossAxisSpacing: 16,
mainAxisSpacing: 16,
children: [
if (logic.suckerEnabled.isTrue)
Tool(
FontAwesomeIcons.dog,
'/sucker',
logic.sucker.value.length < 16
? logic.sucker.value
: logic.sucker.value.substring(0, 16) + '……',
onTap: logic.suckerOnTap,
enabled: !GetPlatform.isWeb,
),
if (logic.cheaterEnabled.isTrue)
Tool(
FontAwesomeIcons.cat,
'/cheater',
logic.cheater.value.length < 16
? logic.cheater.value
: logic.cheater.value.substring(0, 16) + '……',
onTap: logic.cheaterOnTap,
),
if (logic.juanEnabled.isTrue)
Tool(
FontAwesomeIcons.graduationCap,
'卷课意愿值估算',
'仅供参考',
onTap: logic.juanOnTap,
),
Tool(
FontAwesomeIcons.dog,
'/sucker',
logic.sucker.value.length < 16
? logic.sucker.value
: logic.sucker.value.substring(0, 16) + '……',
onTap: logic.suckerOnTap,
enabled: !GetPlatform.isWeb,
),
Tool(
FontAwesomeIcons.cat,
'/cheater',
logic.cheater.value.length < 16
? logic.cheater.value
: logic.cheater.value.substring(0, 16) + '……',
onTap: logic.cheaterOnTap,
),
Tool(
FontAwesomeIcons.graduationCap,
'卷课意愿值估算',
'仅供参考',
onTap: logic.juanOnTap,
),
Tool(
FontAwesomeIcons.calendarAlt,
'校历',
Expand Down
Loading

0 comments on commit 8e8269e

Please sign in to comment.