Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions assets/flutter_i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,46 @@ library:
can_be_renewable: Renewable
cannot_be_renewable: Not renewable
renewing: Renewing
renew_success: Renewed successfully
empty_borrow_list: No borrowed books found
borrow_list_info: Borrowing {borrow} book(s), among which {dued} book(s) have expired
search_book_window: null
search_here: Search here
book_detail: Book details
no_result: No result, change parameter or start your search
scan_borrow: Scan to Borrow
toggle_flash: Toggle flash
scan_book_barcode: Align the holding barcode, then confirm borrowing
scan_expected_book_barcode: 'Scan the holding barcode on "{book}"'
scan_barcode_help: Keep the one-dimensional holding barcode horizontal and fill the frame as much as possible
loading_scanned_book: Loading book information
scan_book_found: Book identified
scan_borrow_available: "Book identified. Borrowable location: {location}"
scan_borrow_unavailable: "Book identified, but unavailable now: {status}"
scan_borrow_no_copy: Book identified, but no borrowable copy was found
scan_expected_book_mismatch: 'Scanned "{actual}", not the book selected in search: "{expected}"'
scan_borrow_fallback: Book identified, borrowable (exact copy location not matched)
confirm_borrow_title: Borrow this book?
confirm_borrow: Confirm borrow
confirm_borrow_real_action: Confirm borrow (will really borrow)
borrow_submitting_notice: Submitting borrow request, please wait
rescan: Scan again
scanned_barcode: "Barcode: {barcode}"
borrow_this_book: Borrow this book
scan_to_borrow_this_book: Scan to borrow this book
search_borrow_warning: Search results cannot be borrowed directly to avoid mistakes. Take the book in the library, scan its holding barcode, then the final confirm action will really submit the borrow request.
borrow_unavailable: No borrowable copy
borrowing_book: Requesting borrow
borrow_submitted: Borrow request submitted
confirm_search_borrow_message: 'Borrow "{book}" from {location}?'
error_barcode_empty: Holding barcode is empty
error_search_failed: Book search failed
error_book_not_found: No matching books found
error_no_search_code: Missing call number, cannot borrow
error_user_barcode_failed: Failed to get reader barcode
error_borrow_failed: Borrow request failed
error_renew_failed: Renew failed
error_session_expired: Library session expired
library_card:
title: Library status
fetching: Fetching
Expand Down
34 changes: 34 additions & 0 deletions assets/flutter_i18n/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ library:
can_be_renewable: 续借
cannot_be_renewable: 不可续借
renewing: 正在续借
renew_success: 续借成功
empty_borrow_list: "目前没有查询到在借图书

不借书就要变成上面的小呆瓜咯"
Expand All @@ -568,6 +569,39 @@ library:
search_here: 在此搜索
book_detail: 书籍详细信息
no_result: 没有结果,请修改搜索参数或者开始你的搜索
scan_borrow: 扫码借书
toggle_flash: 切换闪光灯
scan_book_barcode: 对准馆藏条码,扫描后确认借书
scan_expected_book_barcode: 请扫描《{book}》书上的馆藏条码
scan_barcode_help: 请横向对准图书上的一维馆藏条码,尽量让条码充满框内
loading_scanned_book: 正在读取图书信息
scan_book_found: 已识别图书
scan_borrow_available: 已识别图书,可借位置:{location}
scan_borrow_unavailable: 已识别图书,但当前不可借:{status}
scan_borrow_no_copy: 已识别图书,但没有找到可借馆藏
scan_expected_book_mismatch: 扫到的是《{actual}》,不是你在搜索页选择的《{expected}》
scan_borrow_fallback: 已识别图书,可借(未能匹配精确馆藏位置)
confirm_borrow_title: 确认借阅这本书?
confirm_borrow: 确认借书
confirm_borrow_real_action: 确认借书(将真实借出)
borrow_submitting_notice: 正在提交借书申请,请稍候
rescan: 重新扫描
scanned_barcode: 条码:{barcode}
borrow_this_book: 借阅此书
scan_to_borrow_this_book: 扫码借阅此书
search_borrow_warning: 为避免误借,搜索结果不能直接借出。请到馆拿到这本书后,扫描书上的馆藏条码;最终点击确认借书会真实发起借阅。
borrow_unavailable: 暂无可借馆藏
borrowing_book: 正在申请借书
borrow_submitted: 借书申请已提交
confirm_search_borrow_message: 确认借阅《{book}》?馆藏位置:{location}
error_barcode_empty: 馆藏条码为空
error_search_failed: 查询图书失败
error_book_not_found: 未查找到相关书籍
error_no_search_code: 缺少索书号,无法申请借书
error_user_barcode_failed: 获取读者条码失败
error_borrow_failed: 申请借书失败
error_renew_failed: 续借失败
error_session_expired: 图书馆登录已失效
library_card:
title: 图书馆当前状况
fetching: 正在获取图书馆信息
Expand Down
34 changes: 34 additions & 0 deletions assets/flutter_i18n/zh_TW.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ library:
can_be_renewable: 續借
cannot_be_renewable: 不可續借
renewing: 正在續借
renew_success: 續借成功
empty_borrow_list: '目前沒有查詢到在借圖書

不借書就要變成上面的小呆瓜咯'
Expand All @@ -566,6 +567,39 @@ library:
search_here: 在此搜索
book_detail: 書籍詳細信息
no_result: 沒有結果,請修改搜索參數或者開始你的搜索
scan_borrow: 掃碼借書
toggle_flash: 切換閃光燈
scan_book_barcode: 對準館藏條碼,掃描後確認借書
scan_expected_book_barcode: 請掃描《{book}》書上的館藏條碼
scan_barcode_help: 請橫向對準圖書上的一維館藏條碼,盡量讓條碼充滿框內
loading_scanned_book: 正在讀取圖書信息
scan_book_found: 已識別圖書
scan_borrow_available: 已識別圖書,可借位置:{location}
scan_borrow_unavailable: 已識別圖書,但當前不可借:{status}
scan_borrow_no_copy: 已識別圖書,但沒有找到可借館藏
scan_expected_book_mismatch: 掃到的是《{actual}》,不是你在搜索頁選擇的《{expected}》
scan_borrow_fallback: 已識別圖書,可借(未能匹配精確館藏位置)
confirm_borrow_title: 確認借閱這本書?
confirm_borrow: 確認借書
confirm_borrow_real_action: 確認借書(將真實借出)
borrow_submitting_notice: 正在提交借書申請,請稍候
rescan: 重新掃描
scanned_barcode: 條碼:{barcode}
borrow_this_book: 借閱此書
scan_to_borrow_this_book: 掃碼借閱此書
search_borrow_warning: 為避免誤借,搜索結果不能直接借出。請到館拿到這本書後,掃描書上的館藏條碼;最終點擊確認借書會真實發起借閱。
borrow_unavailable: 暫無可借館藏
borrowing_book: 正在申請借書
borrow_submitted: 借書申請已提交
confirm_search_borrow_message: 確認借閱《{book}》?館藏位置:{location}
error_barcode_empty: 館藏條碼為空
error_search_failed: 查詢圖書失敗
error_book_not_found: 未查找到相關書籍
error_no_search_code: 缺少索書號,無法申請借書
error_user_barcode_failed: 獲取讀者條碼失敗
error_borrow_failed: 申請借書失敗
error_renew_failed: 續借失敗
error_session_expired: 圖書館登錄已失效
library_card:
title: 圖書館當前狀況
fetching: 正在獲取圖書館信息
Expand Down
8 changes: 0 additions & 8 deletions lib/model/xidian_ids/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,8 @@ class BookInfo {
}
return searchCode!.first;
}

String get barCodesStr {
if (barCodes == null || barCodes!.isEmpty) {
return "未提供";
}
return barCodes!.first ?? "未提供";
}
}

@JsonSerializable()
class BookLocation {
final String? yearVol;
final String? locationName;
Expand Down
94 changes: 69 additions & 25 deletions lib/page/library/book_detail_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,78 @@ import 'package:watermeter/repository/logger.dart';

class BookDetailCard extends StatefulWidget {
final BookInfo toUse;
final bool showBorrowAction;
final void Function(BuildContext context, BookInfo bookInfo)? onBorrowRequest;

const BookDetailCard({super.key, required this.toUse});
const BookDetailCard({
super.key,
required this.toUse,
this.showBorrowAction = true,
this.onBorrowRequest,
});

@override
State<BookDetailCard> createState() => _BookDetailCardState();
}

class _BookDetailCardState extends State<BookDetailCard> {
BookLocation? get _firstBorrowableLocation {
final items = widget.toUse.items;
if (items == null) return null;
for (final item in items) {
if (item.processType == "在架" && (item.barCode?.isNotEmpty ?? false)) {
return item;
}
}
return null;
}

Widget _buildBorrowAction(BuildContext context) {
final borrowableLocation = _firstBorrowableLocation;
if (borrowableLocation == null) {
return OutlinedButton.icon(
onPressed: null,
icon: const Icon(Icons.block),
label: Text(
FlutterI18n.translate(context, "library.borrow_unavailable"),
),
);
}

return [
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.errorContainer,
borderRadius: BorderRadius.circular(12),
),
child: [
Icon(
Icons.warning_rounded,
color: Theme.of(context).colorScheme.onErrorContainer,
),
const SizedBox(width: 10),
Text(
FlutterI18n.translate(context, "library.search_borrow_warning"),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onErrorContainer,
),
).expanded(),
].toRow(),
),
const SizedBox(height: 8),
FilledButton.icon(
onPressed: widget.onBorrowRequest == null
? null
: () => widget.onBorrowRequest!(context, widget.toUse),
icon: const Icon(Icons.qr_code_scanner),
label: Text(
FlutterI18n.translate(context, "library.scan_to_borrow_this_book"),
),
),
].toColumn(crossAxisAlignment: CrossAxisAlignment.stretch);
}

@override
Widget build(BuildContext context) {
return ListView(
Expand Down Expand Up @@ -212,35 +276,15 @@ class _BookDetailCardState extends State<BookDetailCard> {
],
),
),
Text.rich(
TextSpan(
children: [
TextSpan(
text: FlutterI18n.translate(
context,
"library.arrangement_code",
),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Color(0xFFBFBFBF),
),
),
TextSpan(
text: widget.toUse.barCodesStr,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
],
),
),
]
.toColumn(crossAxisAlignment: CrossAxisAlignment.stretch)
.flexible(),
],
),
if (widget.showBorrowAction) ...[
const SizedBox(height: 12),
_buildBorrowAction(context),
],
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Column(
Expand Down
Loading