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

Quelle  ThemedCodeButton.swift   Sprache: JAVA

 

import UIKit

/// Base class for `UIButton`s that are implemented in code
///
/// It provides a color method to update your colors on theme changes (`updateColors()`)
/// and a default action that gets called when the button is tapped (`Action`).
///
/// If you don't need more information during initialization you can just override `configureButton()`.
open class ThemedCodeButton: UIButton {
    public typealias Action = (ThemedCodeButton) -> Void
    
    private let action: Action
    
    // MARK: - Lifecycle
    
    public init(frame: CGRect = .zero, action: @escaping Action) {
        self.action = action
        
        super.init(frame: frame)
        
        configureButton()
        registerObserver()
        updateColors()
    }
    
    @available(*, unavailable)
    override init(frame: CGRect) {
        fatalError("init(frame:) has not been implemented")
    }
    
    @available(*, unavailable)
    public required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /// Called during initialization
    open func configureButton() {
        addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
    }
    
    private func registerObserver() {
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(colorThemeChanged),
            name: NSNotification.Name(rawValue: kNotificationColorThemeChanged),
            object: nil
        )
    }
    
    // MARK: - Update
    
    /// Called whenever the colors of the button should be set to the current theme colors
    open func updateColors() { }
    
    // MARK: - Action
    
    @objc private func buttonTapped() {
        action(self)
    }
    
    // MARK: - Notification
    
    @objc private func colorThemeChanged() {
        updateColors()
    }
}

Messung
CHZG
829710093

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© 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.