Ferrite-backup/Ferrite/Views/CommonViews/Modifiers/InlinedList.swift
kingbri 4a87d86e76 Ferrite: Add fixes for Introspect v0.2.2
Introspect now properly updates on every view lifecycle change, so
add a check to a reference on the UIHostingController and see if it
has been instantiated already.

Also clean up view struct names to reflect what is a modifier.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-02-18 11:39:03 -05:00

30 lines
704 B
Swift

//
// InlinedList.swift
// Ferrite
//
// Created by Brian Dashore on 9/4/22.
//
// Removes the top padding on unsectioned lists
// If a list is sectioned, see InlineHeader
//
import Introspect
import SwiftUI
struct InlinedListModifier: ViewModifier {
let inset: CGFloat
func body(content: Content) -> some View {
if #available(iOS 16, *) {
content
.introspectCollectionView { collectionView in
collectionView.contentInset.top = inset
}
} else {
content
.introspectTableView { tableView in
tableView.contentInset.top = inset
}
}
}
}