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

@ -0,0 +1,73 @@
//
// LocationReportDialogPresenter.swift
// suixinkan
//
import UIKit
/// Android
enum LocationReportDialogPresenter {
/// 线
@MainActor
static func presentOnlineStatusSwitch(
from viewController: UIViewController,
isOnline: Bool,
onConfirm: @escaping () -> Void,
onCancel: (() -> Void)? = nil
) {
let message = isOnline
? "是否确认切换为离线状态?\n离线后将暂停位置上报,直到下次手动切换为在线状态"
: "是否确认切换为在线状态?\n在线后将开始位置上报和计时"
let alert = UIAlertController(title: "切换在线状态", message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "取消", style: .cancel) { _ in onCancel?() })
alert.addAction(UIAlertAction(title: "确定", style: .default) { _ in onConfirm() })
viewController.present(alert, animated: true)
}
///
@MainActor
static func presentReportSuccess(
from viewController: UIViewController,
reportTime: String,
countdown: String,
onDismiss: (() -> Void)? = nil
) {
let message = "上报已成功,上报时间为\(reportTime)\n距离下次上报时间\(countdown)"
let alert = UIAlertController(title: "上报成功", message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "确定", style: .default) { _ in onDismiss?() })
viewController.present(alert, animated: true)
}
///
@MainActor
static func presentLocationTimeout(
from viewController: UIViewController,
onReport: @escaping () -> Void,
onLater: (() -> Void)? = nil
) {
let alert = UIAlertController(
title: "位置上报提醒",
message: "倒计时即将结束,请立即上报位置",
preferredStyle: .alert
)
alert.addAction(UIAlertAction(title: "稍后", style: .cancel) { _ in onLater?() })
alert.addAction(UIAlertAction(title: "立即上报", style: .default) { _ in onReport() })
viewController.present(alert, animated: true)
}
///
@MainActor
static func presentReminderPicker(
from viewController: UIViewController,
onSelect: @escaping (Int) -> Void
) {
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) { _ in onSelect(minutes) })
}
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
viewController.present(alert, animated: true)
}
}