Add notes about the benefit of snapshot image caching.
This commit is contained in:
parent
ad1f1b1420
commit
0d37238c50
|
@ -48,8 +48,6 @@ extension PadsState.DataFetchingState: Equatable {
|
|||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ extension MapSnapshotServicing {
|
|||
|
||||
let snapshotter = MKMapSnapshotter(options: snapshotOptions)
|
||||
|
||||
// TOOD: Ideally, we'd implement some kind of cahcing here, or save the images
|
||||
// as part of each pad model -- which could be persisted in Core Data.
|
||||
return Future { promise in
|
||||
snapshotter.start(with: self.queue) { (snapshot, error) in
|
||||
guard error == nil else {
|
||||
|
|
|
@ -35,6 +35,14 @@ extension PadDetailsView {
|
|||
self.isPadFavorited = isPadFavorited
|
||||
self.snapshotService = snapshotService
|
||||
|
||||
// In lieu of image caching or persistance, we'll have to call
|
||||
// this during init instead of onAppear. That's not the greatest.
|
||||
// self.takeMapSnapshot(
|
||||
// size: CGSize(
|
||||
// width: UIScreen.main.bounds.width,
|
||||
// height: UIScreen.main.bounds.width * 0.75
|
||||
// )
|
||||
// )
|
||||
setupSubscribers()
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +92,7 @@ extension PadDetailsView.ViewModel {
|
|||
// MARK: - Public Methods
|
||||
extension PadDetailsView.ViewModel {
|
||||
|
||||
func takeMapSnapshot(with size: CGSize) {
|
||||
func takeMapSnapshot(size: CGSize) {
|
||||
snapshotService
|
||||
.takeSnapshot(with: size, at: pad.coordinate)
|
||||
.assertNoFailure()
|
||||
|
|
|
@ -12,8 +12,6 @@ import CypherPoetSwiftUIKit
|
|||
|
||||
|
||||
struct PadDetailsView {
|
||||
@EnvironmentObject private var store: AppStore
|
||||
|
||||
@ObservedObject var viewModel: ViewModel
|
||||
|
||||
var onFavoriteToggled: ((Pad) -> Void)?
|
||||
|
@ -42,17 +40,17 @@ extension PadDetailsView: View {
|
|||
|
||||
self.optionsSection
|
||||
}
|
||||
.onAppear {
|
||||
self.viewModel.takeMapSnapshot(
|
||||
with: CGSize(
|
||||
width: UIScreen.main.bounds.width,
|
||||
height: UIScreen.main.bounds.width * 0.75
|
||||
)
|
||||
)
|
||||
}
|
||||
.embedInScrollView(axes: .vertical)
|
||||
}
|
||||
.navigationBarTitle(Text(viewModel.padNameText), displayMode: .inline)
|
||||
.onAppear {
|
||||
self.viewModel.takeMapSnapshot(
|
||||
size: CGSize(
|
||||
width: UIScreen.main.bounds.width,
|
||||
height: UIScreen.main.bounds.width * 0.75
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue