-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSendPointCollectionCell.swift
51 lines (43 loc) · 1.74 KB
/
SendPointCollectionCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// SendPointCollectionCell.swift
// Commun
//
// Created by Chung Tran on 12/20/19.
// Copyright © 2019 Commun Limited. All rights reserved.
//
import Foundation
import CyberSwift
class SendPointCollectionCell: MyCollectionViewCell {
// MARK: - Constants
static let height: CGFloat = 124
// MARK: - Properties
var user: ResponseAPIContentGetProfile?
// MARK: - Subviews
lazy var avatarImageView = MyAvatarImageView(size: 50)
lazy var nameLabel = UILabel.with(textSize: 12, weight: .semibold, numberOfLines: 2, textAlignment: .center)
// MARK: - Methods
override func setUpViews() {
super.setUpViews()
contentView.backgroundColor = .appWhiteColor
contentView.cornerRadius = 10
contentView.addSubview(avatarImageView)
avatarImageView.autoPinEdge(toSuperviewEdge: .top, withInset: 16)
avatarImageView.autoAlignAxis(toSuperviewAxis: .vertical)
contentView.addSubview(nameLabel)
nameLabel.autoPinEdge(.top, to: .bottom, of: avatarImageView, withOffset: 10)
nameLabel.autoPinEdge(toSuperviewEdge: .bottom, withInset: 16)
nameLabel.autoPinEdge(toSuperviewEdge: .leading, withInset: 10)
nameLabel.autoPinEdge(toSuperviewEdge: .trailing, withInset: 10)
}
func setUp(with user: ResponseAPIContentGetProfile?) {
self.user = user
if let user = user {
avatarImageView.setAvatar(urlString: user.avatarUrl)
nameLabel.text = user.username
} else {
// add friend
avatarImageView.image = UIImage(named: "add-circle")
nameLabel.text = String(format: "%@ %@", "add".localized().uppercaseFirst, "friend".localized())
}
}
}