From 238dac33e625255e503d49e9e4c2117833add2f9 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Fri, 29 Sep 2023 21:20:21 +0100 Subject: [PATCH] Fix widget wizard rect bug (#668) --- .../Settings/LayoutWidgets/LayoutWidgetCollection.swift | 6 ++++-- .../Views/Appearance/Shared/LayoutWidgetEditView.swift | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Mlem/Models/Settings/LayoutWidgets/LayoutWidgetCollection.swift b/Mlem/Models/Settings/LayoutWidgets/LayoutWidgetCollection.swift index 758636a25..51e7a9a0c 100644 --- a/Mlem/Models/Settings/LayoutWidgets/LayoutWidgetCollection.swift +++ b/Mlem/Models/Settings/LayoutWidgets/LayoutWidgetCollection.swift @@ -111,8 +111,10 @@ class OrderedWidgetCollection: FiniteWidgetCollection { } override func addTo(_ widget: LayoutWidget) { - items.insert(widget, at: predictedDropIndex!) - itemsWithPlaceholder = items + if let index = predictedDropIndex { + items.insert(widget, at: index) + itemsWithPlaceholder = items + } } func updatePlaceholderPosition(widgetDragging: LayoutWidget, index: Int) { diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Shared/LayoutWidgetEditView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Shared/LayoutWidgetEditView.swift index e94397cd9..ee90b0084 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Shared/LayoutWidgetEditView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Shared/LayoutWidgetEditView.swift @@ -154,7 +154,7 @@ struct LayoutWidgetEditView: View { .frame(maxWidth: .infinity, maxHeight: .infinity) .onAppear { barCollection.rect = geo.frame(in: .global) - .offsetBy(dx: 0, dy: -outerFrame.origin.y) + .offsetBy(dx: -outerFrame.origin.x, dy: -outerFrame.origin.y) .insetBy(dx: -20, dy: -60) } } @@ -186,8 +186,9 @@ struct LayoutWidgetEditView: View { Color.clear .frame(maxWidth: .infinity, maxHeight: .infinity) .onAppear { + trayCollection.rect = geo.frame(in: .global) - .offsetBy(dx: 0, dy: -outerFrame.origin.y - 90) + .offsetBy(dx: -outerFrame.origin.x, dy: -outerFrame.origin.y - 90) } } }