-
-
Save laevandus/0cff5687df5a5b7bd49fd43a41b8ac42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MainActor final class ViewModel: ObservableObject { | |
func prepare() { | |
Task { | |
do { | |
async let wallpaperData = service.fetchImageData(id: "blue_wallpaper") | |
async let overlayData = service.fetchImageData(id: "gradient_overlay") | |
self.backgroundImage = try await ImageProcessor.merge(background: wallpaperData, overlay: overlayData) | |
} catch { | |
// TODO: present/handle error | |
} | |
} | |
} | |
} | |
struct ImageProcessor { | |
static func merge(background: Data, overlay: Data) throws -> UIImage { | |
// … | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment