Commit 2cde5631 by Dmitriy Stepanets

Added TodayAlertCell UI

parent be813357
No preview for this file type
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<key>1Weather.xcscheme_^#shared#^_</key> <key>1Weather.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>6</integer>
</dict> </dict>
<key>PG (Playground) 1.xcscheme</key> <key>PG (Playground) 1.xcscheme</key>
<dict> <dict>
......
{
"images" : [
{
"filename" : "alert.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
//General //General
"general.close" = "close"; "general.close" = "close";
"general.more" = "more";
//Forecast //Forecast
"forecast.sunny" = "Sunny"; "forecast.sunny" = "Sunny";
......
...@@ -14,4 +14,110 @@ class TodayAlertCell: UITableViewCell { ...@@ -14,4 +14,110 @@ class TodayAlertCell: UITableViewCell {
private let infoLabel = UILabel() private let infoLabel = UILabel()
private let timeAgoLabel = UILabel() private let timeAgoLabel = UILabel()
private let moreLabel = UILabel() private let moreLabel = UILabel()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
prepareCell()
prepareContainer()
prepareImageView()
prepareLabels()
updateUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
self.updateUI()
}
private func updateUI() {
contentView.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor
container.backgroundColor = ThemeManager.currentTheme.containerBackgroundColor
switch interfaceStyle {
case .light:
infoLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
timeAgoLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
container.layer.shadowColor = UIColor(hex: 0x020116).cgColor
container.layer.shadowOffset = .init(width: 0, height: 10)
container.layer.shadowRadius = 20
container.layer.shadowOpacity = 0.12
case .dark:
infoLabel.textColor = ThemeManager.currentTheme.primaryTextColor
infoLabel.textColor = ThemeManager.currentTheme.primaryTextColor
container.layer.shadowColor = UIColor.black.cgColor
container.layer.shadowOffset = .init(width: 8, height: 8)
container.layer.shadowRadius = 8
container.layer.shadowOpacity = 1.0
}
}
}
//MARK:- Prepare
private extension TodayAlertCell {
func prepareCell() {
selectionStyle = .none
}
func prepareContainer() {
container.layer.cornerRadius = 12
contentView.addSubview(container)
container.snp.makeConstraints { (make) in
make.edges.equalToSuperview().inset(18)
}
}
func prepareImageView() {
alertImageView.image = UIImage(named: "alert")
alertImageView.contentMode = .scaleAspectFit
container.addSubview(alertImageView)
alertImageView.snp.makeConstraints { (make) in
make.width.height.equalTo(33)
make.left.equalToSuperview().inset(8)
make.top.bottom.equalToSuperview().inset(16)
}
}
func prepareLabels() {
infoLabel.numberOfLines = 2
infoLabel.lineBreakMode = .byWordWrapping
infoLabel.font = AppFont.SFPro.regular(size: 16)
infoLabel.text = "Frost Advisory and 2 more alerts"
container.addSubview(infoLabel)
timeAgoLabel.font = AppFont.SFPro.regular(size: 14)
timeAgoLabel.text = "5 mins ago"
timeAgoLabel.textAlignment = .right
container.addSubview(timeAgoLabel)
moreLabel.font = AppFont.SFPro.medium(size: 14)
moreLabel.textColor = UIColor(hex: 0xff2e00)
moreLabel.text = "general.more".localized().uppercased()
moreLabel.textAlignment = .right
container.addSubview(moreLabel)
//Constraints
timeAgoLabel.snp.makeConstraints { (make) in
make.top.equalToSuperview().inset(14)
make.right.equalToSuperview().inset(18)
}
infoLabel.snp.makeConstraints { (make) in
make.left.equalTo(alertImageView.snp.right).offset(18)
make.top.equalToSuperview().inset(12)
make.bottom.equalToSuperview().inset(12)
make.right.equalTo(timeAgoLabel.snp.left).offset(-18)
}
moreLabel.snp.makeConstraints { (make) in
make.top.equalTo(timeAgoLabel.snp.bottom).offset(6)
make.right.equalToSuperview().inset(18)
}
}
} }
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<key>XMLCoder.xcscheme_^#shared#^_</key> <key>XMLCoder.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>5</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment