Refactor AppServices into grouped bundles and document DI conventions.
Centralize dependency wiring with Session/Context/Network/UI/Runtime bundles, unify leaf ViewControllers on appServices, and add a test initializer with AppServicesTests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -141,8 +141,6 @@ final class PunchPointEditorViewController: UIViewController {
|
||||
private let mapPicker = PunchPointMapPickerView()
|
||||
private let locationProvider = ForegroundLocationProvider()
|
||||
|
||||
private var services: AppServices { AppServices.shared }
|
||||
|
||||
init(punchPointId: Int?) {
|
||||
self.punchPointId = punchPointId
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
@ -175,7 +173,7 @@ final class PunchPointEditorViewController: UIViewController {
|
||||
|
||||
Task {
|
||||
guard let punchPointId else { return }
|
||||
if let detail = try? await services.punchPointAPI.punchPointInfo(id: punchPointId) {
|
||||
if let detail = try? await appServices.punchPointAPI.punchPointInfo(id: punchPointId) {
|
||||
viewModel.apply(detail)
|
||||
syncFieldsFromViewModel()
|
||||
}
|
||||
@ -252,7 +250,7 @@ final class PunchPointEditorViewController: UIViewController {
|
||||
)
|
||||
syncFieldsFromViewModel()
|
||||
} catch {
|
||||
services.toastCenter.show("定位失败:\(error.localizedDescription)")
|
||||
appServices.toastCenter.show("定位失败:\(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -264,15 +262,15 @@ final class PunchPointEditorViewController: UIViewController {
|
||||
viewModel.longitudeText = longitudeField.text ?? ""
|
||||
Task {
|
||||
let success = await viewModel.submit(
|
||||
scenicId: services.currentScenicId,
|
||||
api: services.punchPointAPI,
|
||||
uploadService: services.ossUploadService
|
||||
scenicId: appServices.currentScenicId,
|
||||
api: appServices.punchPointAPI,
|
||||
uploadService: appServices.ossUploadService
|
||||
)
|
||||
if success {
|
||||
services.toastCenter.show("保存成功")
|
||||
appServices.toastCenter.show("保存成功")
|
||||
navigationController?.popViewController(animated: true)
|
||||
} else if let message = viewModel.errorMessage {
|
||||
services.toastCenter.show(message)
|
||||
appServices.toastCenter.show(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user