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 #135 from CCXXXI/dev
Browse files Browse the repository at this point in the history
1.3.0+22
  • Loading branch information
CCXXXI authored Oct 25, 2021
2 parents 689f2d5 + 09ddc56 commit 15e3231
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 106 deletions.
19 changes: 14 additions & 5 deletions lib/timetable/timetable_menu/timetable_menu_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import 'package:flutter_settings_screens/flutter_settings_screens.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';

import '../../utils/database.dart';
import '../../utils/gu.dart';
import '../../utils/string.dart';
import '../../utils/web.dart';
import '../ecnu/ecnu_logic.dart';
import '../ecnu/ecnu_view.dart';
import 'timetable_menu_logic.dart';

Expand Down Expand Up @@ -90,13 +92,20 @@ class TimetableMenuPage extends StatelessWidget {
context: context,
tiles: [
ListTile(
title: const Text('壁纸'),
subtitle: Text('🕊' * 5),
trailing: const FaIcon(FontAwesomeIcons.dove),
onTap: gu,
title: Text('ICS文件'.s),
subtitle:
user.id == null ? const Text('需先登录公共数据库') : null,
enabled: user.id != null,
trailing: const FaIcon(FontAwesomeIcons.fileExport),
onTap: Url.ics(
user.id!,
user.password!,
EcnuLogic.guessYear(DateTime.now()),
EcnuLogic.guessSemester(DateTime.now()),
).launch,
),
ListTile(
title: const Text('ics'),
title: const Text('壁纸'),
subtitle: Text('🕊' * 5),
trailing: const FaIcon(FontAwesomeIcons.dove),
onTap: gu,
Expand Down
8 changes: 1 addition & 7 deletions lib/toolbox/toolbox_menu/toolbox_menu_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:quiver/iterables.dart';

import '../../utils/database.dart';
import '../toolbox_view.dart';
Expand All @@ -15,8 +14,6 @@ class ToolboxMenuPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
final tools_ = tools();

return Scaffold(
appBar: AppBar(
title: const Text('工具箱'),
Expand All @@ -27,10 +24,7 @@ class ToolboxMenuPage extends StatelessWidget {
child: ValueListenableBuilder(
valueListenable: conf.listenable(keys: ['toolbox']),
builder: (_, __, ___) => ReorderableListView(
children: range(tools_.length)
.cast<int>()
.map((i) => tools_[toolbox.order[i]].toTile())
.toList(),
children: tools.map((e) => e.toTile()).toList(),
onReorder: toolbox.reorder,
),
),
Expand Down
173 changes: 83 additions & 90 deletions lib/toolbox/toolbox_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,104 +20,102 @@ class ToolboxPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
final tools_ = tools(logic);

return ValueListenableBuilder(
valueListenable: conf.listenable(keys: ['toolbox']),
builder: (_, __, ___) => GridView.extent(
maxCrossAxisExtent: 512,
childAspectRatio: pi,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
children: range(tools_.length)
.cast<int>()
.map((i) => tools_[toolbox.order[i]].toCard())
.toList(),
children: tools.map((e) => e.toCard()).toList(),
),
);
}
}

List<Tool> tools([ToolboxLogic? logic]) => [
Tool(
FontAwesomeIcons.dog,
'/sucker',
'',
subtitleWidget: logic == null
? null
: Obx(
() => logic.sucker.isEmpty
? Loading()
: Text(
logic.sucker.value.length < 16
? logic.sucker.value
: logic.sucker.value.substring(0, 16) + '……',
),
List<Tool> get tools {
final logic = Get.find<ToolboxLogic>();

final tools_ = [
Tool(
FontAwesomeIcons.dog,
'/sucker',
Obx(
() => logic.sucker.isEmpty
? Loading()
: Text(
logic.sucker.value.length < 16
? logic.sucker.value
: logic.sucker.value.substring(0, 16) + '……',
),
onTap: logic?.suckerOnTap,
enabled: !GetPlatform.isWeb,
),
Tool(
FontAwesomeIcons.cat,
'/cheater',
'',
subtitleWidget: logic == null
? null
: Obx(
() => logic.cheater.isEmpty
? Loading()
: Text(
logic.cheater.value.length < 16
? logic.cheater.value
: logic.cheater.value.substring(0, 16) + '……',
),
onTap: logic.suckerOnTap,
enabled: !GetPlatform.isWeb,
),
Tool(
FontAwesomeIcons.cat,
'/cheater',
Obx(
() => logic.cheater.isEmpty
? Loading()
: Text(
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,
'校历',
'长按打开网页版',
onTap: logic?.calendarOnTap,
onLongPress: Url.calendar.launch,
),
Tool(
FontAwesomeIcons.scroll,
'公告',
'善用搜索',
onTap: Url.announcements.launch,
),
Tool(
FontAwesomeIcons.mapMarked,
'校内地图',
'2D/3D',
onTap: Url.map.launch,
),
Tool(
FontAwesomeIcons.bus,
'校车时刻表',
'需要连学校Wifi/VPN'.s,
onTap: Url.bus.launch,
),
Tool(
FontAwesomeIcons.cube,
'ECNU软件镜像站'.s,
'内容很少',
onTap: Url.mirrors.launch,
),
Tool(
FontAwesomeIcons.key,
'学校VPN'.s,
'对校外网站有减速作用',
onTap: Url.vpn.launch,
),
];
onTap: logic.cheaterOnTap,
),
Tool(
FontAwesomeIcons.graduationCap,
'卷课意愿值估算',
const Text('仅供参考'),
onTap: logic.juanOnTap,
),
Tool(
FontAwesomeIcons.calendarAlt,
'校历',
const Text('长按打开网页版'),
onTap: logic.calendarOnTap,
onLongPress: Url.calendar.launch,
),
Tool(
FontAwesomeIcons.scroll,
'公告',
const Text('善用搜索'),
onTap: Url.announcements.launch,
),
Tool(
FontAwesomeIcons.mapMarked,
'校内地图',
const Text('2D/3D'),
onTap: Url.map.launch,
),
Tool(
FontAwesomeIcons.bus,
'校车时刻表',
Text('需要连学校Wifi/VPN'.s),
onTap: Url.bus.launch,
),
Tool(
FontAwesomeIcons.cube,
'ECNU软件镜像站'.s,
const Text('内容很少'),
onTap: Url.mirrors.launch,
),
Tool(
FontAwesomeIcons.key,
'学校VPN'.s,
const Text('对校外网站有减速作用'),
onTap: Url.vpn.launch,
),
];

return range(tools_.length)
.cast<int>()
.map((i) => tools_[toolbox.order[i]])
.toList(growable: false);
}

class Tool {
const Tool(
Expand All @@ -127,13 +125,11 @@ class Tool {
this.onTap,
this.onLongPress,
this.enabled = true,
this.subtitleWidget,
});

final IconData leading;
final String title;
final String subtitle;
final Widget? subtitleWidget;
final Widget subtitle;
final void Function()? onTap;
final void Function()? onLongPress;
final bool enabled;
Expand All @@ -145,7 +141,6 @@ class Tool {
onTap: onTap,
onLongPress: onLongPress,
enabled: enabled,
subtitleWidget: subtitleWidget,
);

ToolTile toTile() => ToolTile(
Expand All @@ -164,13 +159,11 @@ class ToolCard extends StatelessWidget {
this.onTap,
this.onLongPress,
this.enabled = true,
this.subtitleWidget,
}) : super(key: key);

final IconData leading;
final String title;
final String subtitle;
final Widget? subtitleWidget;
final Widget subtitle;
final void Function()? onTap;
final void Function()? onLongPress;
final bool enabled;
Expand All @@ -191,7 +184,7 @@ class ToolCard extends StatelessWidget {
child: ListTile(
leading: FaIcon(leading),
title: Text(title),
subtitle: subtitleWidget ?? Text(subtitle),
subtitle: subtitle,
mouseCursor: MouseCursor.uncontrolled,
),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'pangu.dart';
// record them manually
const appName = 'ECNU Timetable';
const packageName = 'io.github.ccxxxi.ecnu_timetable';
const version = '1.2.0';
const buildNumber = '21';
const version = '1.3.0';
const buildNumber = '22';

const release = '$packageName@$version+$buildNumber';

Expand Down
5 changes: 5 additions & 0 deletions lib/utils/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,10 @@ class Url {
static const captcha = '$_cas/code';
static const ids = '$_eams/courseTableForStd!index.action';
static const table = '$_eams/courseTableForStd!courseTable.action';

// endregion

static String ics(String id, String password, int year, int semester) =>
'http://application.jjaychen.me/ecnu-service/course-calendar'
'?username=$id&password=$password&year=$year&semesterIndex=${semester + 1}';
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 更美观更智能的ECNU课程表。
# Prevent the package from being accidentally published to pub.dev.
publish_to: "none"

version: 1.2.0+21
version: 1.3.0+22

environment:
sdk: ">=2.15.0-172.0.dev"
Expand Down Expand Up @@ -60,7 +60,7 @@ msix_config:
display_name: "ECNU Timetable"
publisher_display_name: "CCXXXI"
identity_name: "io.github.ccxxxi.ecnu-timetable"
msix_version: 1.2.0.21
msix_version: 1.3.0.22
logo_path: "assets/images/app_icon.png"

flutter:
Expand Down
9 changes: 9 additions & 0 deletions test/utils/web_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ void main() {
'https://github.com/CCXXXI/ecnu_timetable/releases/tag/v0.1.0',
),
);

test(
'ics',
() => expect(
Url.ics('10101001000', 'abc', 2021, 0),
'http://application.jjaychen.me/ecnu-service/course-calendar'
'?username=10101001000&password=abc&year=2021&semesterIndex=1',
),
);
}

0 comments on commit 15e3231

Please sign in to comment.