Add location report map page and history list aligned with Android.

Extract shared LocationReportService, wire location_report menu routing, and add unit tests for reporting cooldown and history pagination.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-07 11:34:54 +08:00
parent 5a2b7b6097
commit d2879ad7e2
17 changed files with 1975 additions and 152 deletions

View File

@ -382,65 +382,56 @@ final class HomeViewController: BaseViewController {
}
private func presentOnlineStatusDialog() {
let goingOnline = !viewModel.isOnline
let alert = UIAlertController(
title: goingOnline ? "切换在线" : "切换离线",
message: goingOnline ? "确认切换到在线状态并上报位置?" : "确认切换到离线状态?",
preferredStyle: .alert
viewModel.hideOnlineStatusSwitchDialog()
LocationReportDialogPresenter.presentOnlineStatusSwitch(
from: self,
isOnline: viewModel.isOnline,
onConfirm: { [weak self] in
guard let self else { return }
self.activeDialog = nil
Task { await self.viewModel.switchOnlineStatus(api: self.homeAPI) }
},
onCancel: { [weak self] in
self?.viewModel.hideOnlineStatusSwitchDialog()
self?.activeDialog = nil
}
)
alert.addAction(UIAlertAction(title: "取消", style: .cancel) { [weak self] _ in
self?.viewModel.hideOnlineStatusSwitchDialog()
self?.activeDialog = nil
})
alert.addAction(UIAlertAction(title: "确定", style: .default) { [weak self] _ in
guard let self else { return }
self.activeDialog = nil
Task { await self.viewModel.switchOnlineStatus(api: self.homeAPI) }
})
present(alert, animated: true)
}
private func presentLocationTimeoutDialog() {
let alert = UIAlertController(
title: "位置上报提醒",
message: "您的位置上报即将超时,请立即上报",
preferredStyle: .alert
viewModel.hideLocationTimeoutDialog()
LocationReportDialogPresenter.presentLocationTimeout(
from: self,
onReport: { [weak self] in
guard let self else { return }
self.activeDialog = nil
Task { await self.viewModel.confirmLocationTimeoutReport(api: self.homeAPI) }
},
onLater: { [weak self] in
self?.viewModel.hideLocationTimeoutDialog()
self?.activeDialog = nil
}
)
alert.addAction(UIAlertAction(title: "稍后", style: .cancel) { [weak self] _ in
self?.viewModel.hideLocationTimeoutDialog()
self?.activeDialog = nil
})
alert.addAction(UIAlertAction(title: "立即上报", style: .default) { [weak self] _ in
guard let self else { return }
self.activeDialog = nil
Task { await self.viewModel.confirmLocationTimeoutReport(api: self.homeAPI) }
})
present(alert, animated: true)
}
private func presentLocationSuccessDialog() {
let alert = UIAlertController(
title: "上报成功",
message: "上报时间:\(viewModel.reportTimeText)",
preferredStyle: .alert
let reportTime = viewModel.reportTimeText
let countdown = viewModel.countdownDisplayText
viewModel.hideLocationReportSuccessDialog()
LocationReportDialogPresenter.presentReportSuccess(
from: self,
reportTime: reportTime,
countdown: countdown,
onDismiss: { [weak self] in
self?.activeDialog = nil
}
)
alert.addAction(UIAlertAction(title: "确定", style: .default) { [weak self] _ in
self?.viewModel.hideLocationReportSuccessDialog()
self?.activeDialog = nil
})
present(alert, animated: true)
}
private func presentReminderPicker() {
let alert = UIAlertController(title: "提前提醒", message: "选择位置超时提前提醒时间", preferredStyle: .actionSheet)
[0, 5, 10, 15, 30].forEach { minutes in
let title = minutes == 0 ? "不提醒" : "提前\(minutes)分钟"
alert.addAction(UIAlertAction(title: title, style: .default) { [weak self] _ in
self?.viewModel.updateReminderMinutes(minutes)
})
LocationReportDialogPresenter.presentReminderPicker(from: self) { [weak self] minutes in
self?.viewModel.updateReminderMinutes(minutes)
}
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
present(alert, animated: true)
}
private func presentScenicSelection() {