fix customizing widgets not working
This commit is contained in:
@@ -79,21 +79,32 @@ class CustomWidgetModel: ObservableObject, Codable, NSCopying {
|
||||
@Published var isSaved: Bool
|
||||
@Published var createdDate: Date
|
||||
|
||||
private var oldBackground: CustomWidgetBackGroundOptions?
|
||||
private var oldBackgroundImages: [(Image, String)]?
|
||||
|
||||
public var backgroundImages : [(Image, String)] {
|
||||
if let oldBackgroundImages = oldBackgroundImages,
|
||||
oldBackground == background {
|
||||
return oldBackgroundImages
|
||||
}
|
||||
|
||||
oldBackground = background
|
||||
|
||||
if background == .random {
|
||||
var blah = [(Image, String)]()
|
||||
for _ in 0...CustomWidgetModel.numberOfBGItems {
|
||||
let image = CustomWidgetBackGroundOptions.selectable.randomElement()?.image ?? CustomWidgetBackGroundOptions.defaultOption.image
|
||||
blah.append((image, UUID().uuidString))
|
||||
}
|
||||
return blah
|
||||
oldBackgroundImages = blah
|
||||
} else {
|
||||
var blah = [(Image, String)]()
|
||||
for _ in 0...CustomWidgetModel.numberOfBGItems {
|
||||
blah.append((background.image, UUID().uuidString))
|
||||
}
|
||||
return blah
|
||||
oldBackgroundImages = blah
|
||||
}
|
||||
return oldBackgroundImages!
|
||||
}
|
||||
|
||||
enum CodingKeys: CodingKey {
|
||||
|
||||
Reference in New Issue
Block a user