d8436f79f6
* files reorganization (#432) * fix podspec * only include swift files * Fix broken readme paths (#433) * update links * fix french link * split skeleton debug to public and internal methods (#434) * Add build phase to execute SwiftLint (#435) * update tvOS tests * Refactor Extensions folder (#436) * Reorganize SkeletonAppearance (#437) * reorganize helpers and builders folders (#438) * Refactor flow and multilines (#439) * Reorganize collections folder (#440) * reorganize collections folder * update podspec * Refactor SkeletonView facade (#441) * reorganize collections folder * update podspec * refactor skeletonview facade * fix conflict * update iOS example * fix github workflows * update tvOS example project build settings
46 lines
1.3 KiB
Swift
46 lines
1.3 KiB
Swift
//
|
|
// Copyright SkeletonView. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// UITableView+Extensions.swift
|
|
//
|
|
// Created by Juanpe Catalán on 18/8/21.
|
|
|
|
import UIKit
|
|
|
|
extension UITableView {
|
|
|
|
var indexesOfVisibleSections: [Int] {
|
|
(0..<numberOfSections).reduce([]) {
|
|
let headerRect = style == .plain ? rect(forSection: $1) : rectForHeader(inSection: $1)
|
|
|
|
let visiblePartOfTableView = CGRect(
|
|
x: contentOffset.x,
|
|
y: contentOffset.y,
|
|
width: bounds.size.width,
|
|
height: bounds.size.height
|
|
)
|
|
|
|
if visiblePartOfTableView.intersects(headerRect) {
|
|
return $0 + [$1]
|
|
}
|
|
|
|
return $0
|
|
}
|
|
}
|
|
|
|
var visibleSectionHeaders: [UITableViewHeaderFooterView] {
|
|
indexesOfVisibleSections.compactMap { headerView(forSection: $0) }
|
|
}
|
|
|
|
var visibleSectionFooters: [UITableViewHeaderFooterView] {
|
|
indexesOfVisibleSections.compactMap { footerView(forSection: $0) }
|
|
}
|
|
|
|
}
|