closed #89 make custom widgets codable

This commit is contained in:
Trey t
2022-02-21 11:36:45 -06:00
parent bdfa780c22
commit 83060e8353
45 changed files with 679 additions and 130 deletions

View File

@@ -12,27 +12,6 @@ struct CustomWidgetView: View {
private let facePercSize = 0.6
// private var gridXOffset: CGFloat {
// if isPreview {
// return CGFloat(0)
// }
// return CGFloat(6)
// }
//
// private var gridYOffset: CGFloat {
// if isPreview {
// return CGFloat(0)
// }
// return CGFloat(-8)
// }
//
// private var entireFuckingViewOffset: CGFloat {
// if isPreview {
// return CGFloat(0)
// }
// return CGFloat(25)
// }
let columns = [
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
@@ -56,8 +35,8 @@ struct CustomWidgetView: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
LazyVGrid(columns: columns, alignment: .leading, spacing: 0) {
ForEach(customWidgetModel.background, id: \.self.1) { (bgOption, uuid) in
bgOption.image
ForEach(customWidgetModel.backgroundImages, id: \.self.1) { (bgOption, uuid) in
bgOption
.resizable()
.aspectRatio(1, contentMode: .fill)
.foregroundColor(customWidgetModel.bgOverlayColor)
@@ -114,16 +93,8 @@ struct CustomWidgetView: View {
}
struct WidgetView_Previews: PreviewProvider {
static var backgrounds: [(CustomWidgetBackGroundOptions, UUID)] = {
var blah = [(CustomWidgetBackGroundOptions, UUID)]()
for _ in 0...CustomWidgetModel.numberOfBGItems {
blah.append((CustomWidgetBackGroundOptions.selectable.randomElement()!, UUID()))
}
return blah
}()
static var previews: some View {
CustomWidgetView(customWidgetModel: CustomWidgetModel.defaultCustomIcon)
CustomWidgetView(customWidgetModel: CustomWidgetModel.defaultCustomWidget)
.frame(width: 256, height: 256, alignment: .center)
}