Skip to content

Commit

Permalink
Merge branch 'master' into riverpod
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/life/electricity/index.dart
#	lib/life/expense_records/index.dart
  • Loading branch information
liplum committed Mar 28, 2024
2 parents 736d9bf + 3d537aa commit 24551e0
Show file tree
Hide file tree
Showing 78 changed files with 456 additions and 318 deletions.
10 changes: 8 additions & 2 deletions assets/l10n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ timetable:
newPaletteName: New palette
deleteRequest: Conform to delete?
deleteRequestDesc: The palette will be deleted permanently without unless a QR code backup is saved
addFromQrCode: Palette was added from QR code
addColor: Add a color
addFromQrCodeAction: Add palette
addFromQrCodeDesc: Confirm to add a timetable palette from QR code?
cellStyle:
title: Cell Style
showTeachers:
Expand Down Expand Up @@ -357,6 +358,7 @@ electricity:
refreshSuccessTip: Electricity balance refreshed successfully
refreshFailedTip: Failed to refresh electricity balance
searchRoom: Search Room
lastUpdateTime: "Last update: {}"
eduEmail:
title: Edu email
action:
Expand Down Expand Up @@ -425,6 +427,7 @@ expenseRecords:
noTransactionsTip: You have no transactions
refreshSuccessTip: Expense records refreshed successfully
refreshFailedTip: Failed to refresh expense records
lastUpdateTime: "Last update: {}"
statsMode:
week: Week
month: Month
Expand Down Expand Up @@ -530,11 +533,13 @@ library:
title: Borrowing
history: History
renew: Renew
noBorrowing: No borrowing books
history:
title: History
operation:
borrowing: Borrowing
returning: Returning
noHistory: No borrowing history
searchMethod:
any: Any
title: Title
Expand Down Expand Up @@ -632,7 +637,8 @@ settings:
username: Username
password: Password
invalidProxyFormatTip: Invalid proxy format
proxyChangedTip: Proxy was changed
setFromQrCodeAction: Set proxy
setFromQrCodeDesc: Confirm to set proxy from QR code?
shareQrCode:
title: Share QR code
desc: Share proxy as QR code
Expand Down
16 changes: 11 additions & 5 deletions assets/l10n/zh-Hans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ timetable:
mine:
title: 你的课程表
exportCalendar: 导出日历
deleteRequest: 确认删除
deleteRequest: 确定删除
deleteRequestDesc: 这个课程表将被永久删除
emptyTip: 快去导入一个课程表吧!
details: 详情
Expand Down Expand Up @@ -129,10 +129,11 @@ timetable:
fab: 配色方案
shareQrCode: 分享二维码
newPaletteName: 新的配色方案
deleteRequest: 确认删除
deleteRequest: 确定删除
deleteRequestDesc: 推荐先保存二维码备份再删除
addFromQrCode: 已从二维码添加配色方案
addColor: 添加一种配色
addFromQrCodeAction: 添加配色方案
addFromQrCodeDesc: 确定从读取的二维码中添加配色方案?
cellStyle:
title: 单元格风格
showTeachers:
Expand Down Expand Up @@ -227,7 +228,7 @@ class2nd:
btn: 申请
replyTip: 校方回复
applyRequest: 申请
applyRequestDesc: 确认申请这个活动吗
applyRequestDesc: 确定申请这个活动吗
applySuccessTip: 申请活动成功
applyFailureTip: 申请活动失败
info:
Expand Down Expand Up @@ -354,6 +355,7 @@ electricity:
refreshSuccessTip: 电费余额刷新成功
refreshFailedTip: 电费余额刷新失败
searchRoom: 搜索房间
lastUpdateTime: "上次更新:{}"
eduEmail:
title: 教育邮箱
action:
Expand Down Expand Up @@ -422,6 +424,7 @@ expenseRecords:
noTransactionsTip: 你没有交易记录
refreshSuccessTip: 消费记录刷新成功
refreshFailedTip: 消费记录刷新失败
lastUpdateTime: "上次更新:{}"
statsMode:
week:
month:
Expand Down Expand Up @@ -530,11 +533,13 @@ library:
title: 你的借阅
history: 历史
renew: 续借
noBorrowing: 你没有借阅中的书籍
history:
title: 历史
operation:
borrowing: 借书
returning: 还书
noHistory: 你没有借阅记录
searchMethod:
any: 任意
title: 标题
Expand Down Expand Up @@ -632,7 +637,8 @@ settings:
username: 用户名
password: 密码
invalidProxyFormatTip: 代理的格式无效
proxyChangedTip: 代理已更改
setFromQrCodeAction: 设置代理
setFromQrCodeDesc: 确定从读取的二维码中设置代理?
shareQrCode:
title: 分享二维码
desc: 将代理通过二维码分享
Expand Down
12 changes: 9 additions & 3 deletions assets/l10n/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ timetable:
newPaletteName: 新的調色盤
deleteRequest: 確認刪除?
deleteRequestDesc: 除非儲存了 QR 碼備份,否則調色板將被永久刪除
addFromQrCode: 已從 QR 碼加載調色盤
addColor: 增加一對顏色
addFromQrCodeAction: 新增調色盤
addFromQrCodeDesc: 確認從 QR 碼中新增調色盤?
cellStyle:
title: 單元樣式
showTeachers:
Expand Down Expand Up @@ -354,6 +355,7 @@ electricity:
refreshSuccessTip: 電費餘額重新整理成功
refreshFailedTip: 電費餘額重新整理失敗
searchRoom: 搜尋房間
lastUpdateTime: "最後更新:{}"
eduEmail:
title: Edu 電郵
action:
Expand Down Expand Up @@ -422,6 +424,7 @@ expenseRecords:
noTransactionsTip: 你沒有交易記錄
refreshSuccessTip: 消費記錄重新整理成功
refreshFailedTip: 消費記錄重新整理失敗
lastUpdateTime: "最後更新:{}"
statsMode:
week:
month:
Expand Down Expand Up @@ -530,11 +533,13 @@ library:
title: 你的借閱
history: 歷史
renew: 續借
noBorrowing: 你沒有借閱中的書籍
history:
title: 歷史
operation:
borrowing: 借書
returning: 還書
noHistory: 你沒有借閱歷史
searchMethod:
any: 任意
title: 標題
Expand Down Expand Up @@ -623,7 +628,7 @@ settings:
themeMode:
title: 亮度
proxy:
title: 代理
title: 網路代理
desc: 代理校園網路連線
authentication: 驗證
protocol: 通訊協定
Expand All @@ -632,7 +637,8 @@ settings:
username: 使用者名稱
password: 密碼
invalidProxyFormatTip: 無效的代理格式
proxyChangedTip: 網路代理已變更
setFromQrCodeAction: 設定代理
setFromQrCodeDesc: 確認從 QR 碼中設定代理?
shareQrCode:
title: 分享 QR 碼
desc: 使用 QR 碼分享代理
Expand Down
32 changes: 28 additions & 4 deletions lib/design/adaptive/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension DialogEx on BuildContext {
}

Future<bool?> showRequest({
required String title,
String? title,
required String desc,
required String yes,
required String no,
Expand All @@ -78,8 +78,32 @@ extension DialogEx on BuildContext {
);
}

Future<bool?> showActionRequest({
required String desc,
required String action,
required String cancel,
bool destructive = false,
}) async {
if (isCupertino) {
return showCupertinoRequest(
desc: desc,
yes: action,
cancel: cancel,
destructive: destructive,
);
}
return await showAnyRequest(
title: action,
make: (_) => desc.text(style: const TextStyle()),
yes: action,
no: cancel,
highlight: destructive,
serious: destructive,
);
}

Future<bool?> showCupertinoRequest({
required String title,
String? title,
required String desc,
required String yes,
required String cancel,
Expand All @@ -88,7 +112,7 @@ extension DialogEx on BuildContext {
return await showCupertinoModalPopup(
context: this,
builder: (ctx) => CupertinoActionSheet(
title: title.text(),
title: title?.text(),
message: desc.text(),
actions: [
CupertinoActionSheetAction(
Expand All @@ -110,7 +134,7 @@ extension DialogEx on BuildContext {
}

Future<bool?> showAnyRequest({
required String title,
String? title,
required WidgetBuilder make,
required String yes,
required String no,
Expand Down
5 changes: 3 additions & 2 deletions lib/design/adaptive/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:sit/design/adaptive/multiplatform.dart';
import 'package:sit/l10n/common.dart';
import 'package:rettulf/rettulf.dart';

Expand Down Expand Up @@ -329,7 +330,7 @@ class _IntEditorState extends State<IntEditor> {
return Row(
children: [
PlatformTextButton(
child: const Icon(Icons.remove),
child: Icon(ctx.icons.remove),
onPressed: () {
setState(() {
value--;
Expand All @@ -353,7 +354,7 @@ class _IntEditorState extends State<IntEditor> {
},
).sized(w: 100),
PlatformTextButton(
child: const Icon(Icons.add),
child: Icon(ctx.icons.add),
onPressed: () {
setState(() {
value++;
Expand Down
10 changes: 3 additions & 7 deletions lib/design/adaptive/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,26 @@ class PullDownItem implements PullDownEntry {
final String title;
final VoidCallback? onTap;
final IconData? icon;
final IconData? cupertinoIcon;
final bool destructive;

const PullDownItem({
required this.title,
this.onTap,
this.icon,
this.cupertinoIcon,
this.destructive = false,
});

const PullDownItem.edit({
required this.title,
this.onTap,
this.icon = Icons.edit,
this.cupertinoIcon = CupertinoIcons.pencil,
this.icon,
this.destructive = false,
});

const PullDownItem.delete({
required this.title,
this.onTap,
this.icon = Icons.delete,
this.cupertinoIcon = CupertinoIcons.delete,
this.icon,
}) : destructive = true;

@override
Expand All @@ -61,7 +57,7 @@ class PullDownItem implements PullDownEntry {
onTap: onTap,
title: title,
isDestructive: destructive,
icon: cupertinoIcon ?? icon,
icon: icon,
);
}

Expand Down
16 changes: 16 additions & 0 deletions lib/design/adaptive/multiplatform.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:sit/r.dart';
import 'package:universal_platform/universal_platform.dart';

Expand All @@ -17,3 +19,17 @@ extension ShareX on BuildContext {
return sharePositionOrigin;
}
}

extension BuildContextPlatformIconsX on BuildContext {
PlatformIcons get icons => PlatformIcons(this);
}

extension PlatformIconsX on PlatformIcons {
IconData get lock => isMaterial(context) ? Icons.lock : CupertinoIcons.lock;

IconData get copy => isMaterial(context) ? Icons.copy : CupertinoIcons.plus_square_on_square;

IconData get calendar => isMaterial(context) ? Icons.calendar_month : CupertinoIcons.calendar;

IconData get qrcode => isMaterial(context) ? Icons.qr_code : CupertinoIcons.qrcode;
}
6 changes: 2 additions & 4 deletions lib/design/adaptive/swipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import 'multiplatform.dart';
class SwipeToDismissAction {
final VoidCallback action;
final Icon? icon;
final Icon? cupertinoIcon;
final String? label;

SwipeToDismissAction({
required this.action,
this.icon,
this.cupertinoIcon,
this.label,
});
}
Expand Down Expand Up @@ -46,7 +44,7 @@ class SwipeToDismiss extends StatelessWidget {
: <SwipeAction>[
SwipeAction(
title: right.label,
icon: isCupertino ? right.cupertinoIcon : right.icon,
icon: right.icon,
style: context.textTheme.titleSmall ?? const TextStyle(),
performsFirstActionWithFullSwipe: true,
onTap: (CompletionHandler handler) async {
Expand All @@ -61,7 +59,7 @@ class SwipeToDismiss extends StatelessWidget {
: <SwipeAction>[
SwipeAction(
title: left.label,
icon: isCupertino ? left.cupertinoIcon : left.icon,
icon: left.icon,
style: context.textTheme.titleSmall ?? const TextStyle(),
performsFirstActionWithFullSwipe: true,
onTap: (CompletionHandler handler) async {
Expand Down
Loading

0 comments on commit 24551e0

Please sign in to comment.