Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/Threema/Settings/   (Social Medium ©)  Datei vom 26.9.2026 mit Größe 3 kB image not shown  

Quelle  SettingsCollectionView.swift   Sprache: JAVA

 

import Foundation
import UIKit

final class SettingsCollectionView: UICollectionView, UICollectionViewDelegate {
    
    // MARK: - Properties

    private let currentDestinationFetcher: () -> SettingsCoordinator.InternalDestination?
    private let shouldAllowAutoDeselection: () -> Bool

    // MARK: - Lifecycle

    init(
        currentDestinationFetcher: @escaping () -> SettingsCoordinator.InternalDestination?,
        shouldAllowAutoDeselection: @escaping () -> Bool
    ) {
        self.currentDestinationFetcher = currentDestinationFetcher
        self.shouldAllowAutoDeselection = shouldAllowAutoDeselection
        
        let layout = UICollectionViewCompositionalLayout { _, layoutEnvironment in
            let config = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
            return NSCollectionLayoutSection.list(using: config, layoutEnvironment: layoutEnvironment)
        }
        
        super.init(frame: .zero, collectionViewLayout: layout)
        
        delegate = self
    }
    
    @available(*, unavailable)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - Updates
    
    func updateSelection(for sizeClass: UIUserInterfaceSizeClass) {
        if shouldAllowAutoDeselection() {
            indexPathsForSelectedItems?.forEach {
                deselectItem(at: $0, animated: false)
            }
        }
        else {
            guard let destination = currentDestinationFetcher(),
                  let dataSource = dataSource as? SettingsCollectionViewDataSource,
                  let row = SettingsCollectionViewDataSource.Row.row(for: destination),
                  let index = dataSource.indexPathForItem(row) else {
                // Nothing is shown anymore: clear a stale highlight.
                indexPathsForSelectedItems?.forEach {
                    deselectItem(at: $0, animated: false)
                }
                return
            }

            selectItem(at: index, animated: false, scrollPosition: .centeredVertically)
        }
    }
    
    func betaFeedbackCell() -> UICollectionViewCell? {
        guard let dataSource = dataSource as? SettingsCollectionViewDataSource,
              let index = dataSource.indexPathForItem(.betaFeedback), let cell = cellForItem(at: index) else {
            return nil
        }
        
        return cell
    }
    
    // MARK: - UICollectionViewDelegate
    
    func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
        guard let dataSource = dataSource as? SettingsCollectionViewDataSource else {
            return false
        }
        
        return dataSource.canSelectItem(at: indexPath)
    }
    
    func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
        guard let dataSource = dataSource as? SettingsCollectionViewDataSource else {
            return false
        }
        
        return dataSource.canSelectItem(at: indexPath)
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        guard let dataSource = dataSource as? SettingsCollectionViewDataSource else {
            collectionView.deselectItem(at: indexPath, animated: true)
            return
        }
        
        dataSource.didSelectItem(at: indexPath)
    }
}

Messung
CHZG
859710094

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.