Christian Sousa
05/28/2020, 11:36 AMclass LeftAlignedCollectionViewFlowLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let attributes = super.layoutAttributesForElements(in: rect)
var leftMargin = sectionInset.left
var maxY: CGFloat = -1.0
attributes?.forEach { layoutAttribute in
if layoutAttribute.frame.origin.y >= maxY {
leftMargin = sectionInset.left
}
layoutAttribute.frame.origin.x = leftMargin
leftMargin += layoutAttribute.frame.width + minimumInteritemSpacing
maxY = max(layoutAttribute.frame.maxY , maxY)
}
return attributes
}
}
Asking this because if I try to do:
class LeftLayout: UICollectionViewFlowLayout {
constructor(): super()
override fun layoutAttributesForElementsInRect(rect: CGSize){
}
}
It simply tells me that theres nothing to override..russhwolf
05/28/2020, 12:33 PMrect: CGRect
but your kotlin takes rect: CGSize
Christian Sousa
05/28/2020, 12:33 PMChristian Sousa
05/28/2020, 12:35 PMrusshwolf
05/28/2020, 12:37 PMChristian Sousa
05/28/2020, 12:39 PMChristian Sousa
05/28/2020, 12:39 PM@kotlinx.cinterop.ExternalObjCClass public open class UICollectionViewFlowLayout : platform.UIKit.UICollectionViewLayout {
public companion object : platform.UIKit.UICollectionViewFlowLayoutMeta, kotlinx.cinterop.ObjCClassOf<platform.UIKit.UICollectionViewFlowLayout> {
}
@kotlinx.cinterop.ObjCConstructor public constructor() { /* compiled code */ }
@kotlinx.cinterop.ObjCConstructor public constructor(coder: platform.Foundation.NSCoder) { /* compiled code */ }
public final var estimatedItemSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> /* compiled code */
public final var footerReferenceSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> /* compiled code */
public final var headerReferenceSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> /* compiled code */
public final var itemSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> /* compiled code */
public final var minimumInteritemSpacing: platform.CoreGraphics.CGFloat /* = kotlin.Double */ /* compiled code */
public final var minimumLineSpacing: platform.CoreGraphics.CGFloat /* = kotlin.Double */ /* compiled code */
public final var scrollDirection: platform.UIKit.UICollectionViewScrollDirection /* compiled code */
public final var sectionFootersPinToVisibleBounds: kotlin.Boolean /* compiled code */
public final var sectionHeadersPinToVisibleBounds: kotlin.Boolean /* compiled code */
public final var sectionInset: kotlinx.cinterop.CValue<platform.UIKit.UIEdgeInsets> /* compiled code */
public final var sectionInsetReference: platform.UIKit.UICollectionViewFlowLayoutSectionInsetReference /* compiled code */
@kotlinx.cinterop.ObjCMethod public open external fun estimatedItemSize(): kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun footerReferenceSize(): kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun headerReferenceSize(): kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> { /* compiled code */ }
@kotlin.Deprecated @kotlinx.cinterop.ObjCMethod @kotlinx.cinterop.internal.CCall.ConsumesReceiver @kotlinx.cinterop.internal.CCall.ReturnsRetained public open external fun init(): platform.UIKit.UICollectionViewFlowLayout { /* compiled code */ }
@kotlin.Deprecated @kotlinx.cinterop.ObjCMethod @kotlinx.cinterop.internal.CCall.ConsumesReceiver @kotlinx.cinterop.internal.CCall.ReturnsRetained public open external fun initWithCoder(coder: platform.Foundation.NSCoder): platform.UIKit.UICollectionViewFlowLayout? { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun itemSize(): kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize> { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun minimumInteritemSpacing(): platform.CoreGraphics.CGFloat /* = kotlin.Double */ { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun minimumLineSpacing(): platform.CoreGraphics.CGFloat /* = kotlin.Double */ { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun scrollDirection(): platform.UIKit.UICollectionViewScrollDirection { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun sectionFootersPinToVisibleBounds(): kotlin.Boolean { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun sectionHeadersPinToVisibleBounds(): kotlin.Boolean { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun sectionInset(): kotlinx.cinterop.CValue<platform.UIKit.UIEdgeInsets> { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun sectionInsetReference(): platform.UIKit.UICollectionViewFlowLayoutSectionInsetReference { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setEstimatedItemSize(estimatedItemSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize>): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setFooterReferenceSize(footerReferenceSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize>): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setHeaderReferenceSize(headerReferenceSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize>): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setItemSize(itemSize: kotlinx.cinterop.CValue<platform.CoreGraphics.CGSize>): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setMinimumInteritemSpacing(minimumInteritemSpacing: platform.CoreGraphics.CGFloat /* = kotlin.Double */): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setMinimumLineSpacing(minimumLineSpacing: platform.CoreGraphics.CGFloat /* = kotlin.Double */): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setScrollDirection(scrollDirection: platform.UIKit.UICollectionViewScrollDirection): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setSectionFootersPinToVisibleBounds(sectionFootersPinToVisibleBounds: kotlin.Boolean): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setSectionHeadersPinToVisibleBounds(sectionHeadersPinToVisibleBounds: kotlin.Boolean): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setSectionInset(sectionInset: kotlinx.cinterop.CValue<platform.UIKit.UIEdgeInsets>): kotlin.Unit { /* compiled code */ }
@kotlinx.cinterop.ObjCMethod public open external fun setSectionInsetReference(sectionInsetReference: platform.UIKit.UICollectionViewFlowLayoutSectionInsetReference): kotlin.Unit { /* compiled code */ }
}
Artyom Degtyarev [JB]
05/28/2020, 1:45 PM@kotlinx.cinterop.ObjCMethod public external fun platform.UIKit.UICollectionViewLayout.layoutAttributesForElementsInRect(rect: kotlinx.cinterop.CValue<platform.CoreGraphics.CGRect>): kotlin.collections.List<*>? { /* compiled code */ }
and can be imported directly as import platform.UIKit.layoutAttributesForElementsInRect
.Christian Sousa
05/28/2020, 1:47 PMChristian Sousa
05/28/2020, 1:59 PMArtyom Degtyarev [JB]
05/28/2020, 2:39 PMChristian Sousa
05/28/2020, 2:44 PM