Skip to content
Snippets Groups Projects
Select Git revision
  • b35c5f632b801efce7486aea534cb600059eb478
  • release default protected
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
41 results

sentRoundTracker_test.go

Blame
  • AttributeComponent.swift 2.15 KiB
    import UIKit
    
    public final class AttributeComponent: UIView {
        public enum Style {
            case steady
            case interactive
            case requiredEditable
        }
    
        public let titleLabel = UILabel()
        public let actionButton = UIButton()
        public let contentLabel = UILabel()
    
        let placeholder = "None provided"
        var buttonStyle: Style = .steady
    
        public private(set) var currentValue: String? {
            didSet { contentLabel.text = currentValue ?? placeholder }
        }
    
        public init() {
            super.init(frame: .zero)
    
            titleLabel.textColor = Asset.neutralWeak.color
            contentLabel.textColor = Asset.neutralActive.color
            titleLabel.font =  Fonts.Mulish.bold.font(size: 12.0)
            contentLabel.font = Fonts.Mulish.regular.font(size: 16.0)
    
            addSubview(titleLabel)
            addSubview(actionButton)
            addSubview(contentLabel)
    
            titleLabel.snp.makeConstraints { make in
                make.top.left.equalToSuperview()
                make.bottom.equalToSuperview().offset(-25)
            }
    
            contentLabel.snp.makeConstraints { make in
                make.top.equalTo(titleLabel.snp.bottom).offset(6)
                make.left.equalToSuperview()
            }
    
            actionButton.snp.makeConstraints { $0.right.centerY.equalToSuperview() }
        }
    
        required init?(coder: NSCoder) { nil }
    
        public func set(
            title: String,
            value: String? = nil,
            icon: UIImage? = nil,
            style: Style = .steady
        ) {
            titleLabel.text = title.uppercased()
            actionButton.setImage(icon, for: .normal)
            buttonStyle = style
    
            set(value: value)
        }
    
        public func set(value: String?) {
            currentValue = value
    
            if buttonStyle == .requiredEditable {
                actionButton.setImage(Asset.contactNicknameEdit.image, for: .normal)
                return
            }
    
            guard let _ = value else {
                if buttonStyle == .interactive {
                    actionButton.setImage(Asset.profileAdd.image, for: .normal)
                }
    
                return
            }
    
            if buttonStyle == .interactive {
                actionButton.setImage(Asset.profileDelete.image, for: .normal)
            }
        }
    }