//
//  TSBaseCollectionView.swift
//  Pods
//
//  Created by 100Years on 2025/6/17.
//

open class TSBaseCollectionView: UICollectionView {
//    override var effectiveUserInterfaceLayoutDirection: UIUserInterfaceLayoutDirection {
//        return kIsRTL ? .rightToLeft : .leftToRight
//    }

    // MARK: - 初始化
    
    override public init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
        super.init(frame: frame, collectionViewLayout: layout)
        commonInit()
    }
    
    required public init?(coder: NSCoder) {
        super.init(coder: coder)
        commonInit()
    }
    
    // MARK: - 公共配置
    
    private func commonInit() {
        // 通用配置
        backgroundColor = .systemBackground
        keyboardDismissMode = .onDrag
     
        
        if kIsRTL {
            semanticContentAttribute = .forceRightToLeft
        }
        
        
        backgroundColor = .clear
        showsVerticalScrollIndicator = false
        showsHorizontalScrollIndicator = false
        if #available(iOS 11.0, *) {
            contentInsetAdjustmentBehavior = .never
        }
    }
}

open class TSBaseCollectionViewFlowLayout: UICollectionViewFlowLayout {
    open override var flipsHorizontallyInOppositeLayoutDirection: Bool {
        return kIsRTL
    }
}



open class TSBaseTableView: UITableView {
    // MARK: - 初始化
    
    override public init(frame: CGRect, style: UITableView.Style) {
        super.init(frame: frame, style: style)
        commonInit()
    }
    
    required public init?(coder: NSCoder) {
        super.init(coder: coder)
        commonInit()
    }
    
    // MARK: - 公共配置
    private func commonInit() {
        if #available(iOS 11.0, *) {
            contentInsetAdjustmentBehavior = .never
        }

        if #available(iOS 15.0, *) {
            sectionHeaderTopPadding = 0
        }

        if kIsRTL {
            semanticContentAttribute = .forceRightToLeft
        }
        
        separatorStyle = .none
        backgroundColor = .clear

        estimatedRowHeight = 0
        estimatedSectionHeaderHeight = 0
        estimatedSectionFooterHeight = 0

        showsVerticalScrollIndicator = false
        showsHorizontalScrollIndicator = false

        backgroundColor = .clear

        if tableFooterView == nil {
            tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFLOAT_MIN))
        }
    }
}
