Commit 46752414 by Dmitry Stepanets

[IOS-187]: Added swipe nudge view

[IOS-179]: Implemented the swipe nudge UI
parent 39aef5b9
{
"images" : [
{
"filename" : "precip_swipe_nudge.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
{
"images" : [
{
"filename" : "temp_swipe_nudge.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
......@@ -356,3 +356,6 @@
"onboarding.alerts.subtitle" = "Get alerts about severe weather well-in-advance";
"onboarding.radar.title" = "Live doppler radar";
"onboarding.radar.subtitle" = "Our live radar gives you real-time weather updates with excellent accuracy";
//Minutele
"minutelty.swipeToSee" = "swipe to see\nmore";
......@@ -60,10 +60,61 @@ private class MinutelyLevelView: UIView {
}
}
private class SwipeNudgeView: UIView {
private let imageView = UIImageView()
private let label = UILabel()
init() {
super.init(frame: .zero)
prepareViews()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public func configure(type: MinutelyForecastType) {
switch type {
case .temperature:
imageView.image = UIImage(named: "temp_swipe_nudge")
label.textColor = kTemperatureColors[0]
case .precipitation:
imageView.image = UIImage(named: "precip_swipe_nudge")
label.textColor = kPrecipitationColors[0]
}
}
private func prepareViews() {
imageView.contentMode = .scaleAspectFit
addSubview(imageView)
label.font = AppFont.SFPro.regular(size: 10)
label.textAlignment = .center
label.numberOfLines = 0
label.text = "minutelty.swipeToSee".localized.uppercased()
addSubview(label)
//Constraitns
imageView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.centerX.equalToSuperview()
make.width.equalTo(36)
make.height.equalTo(17)
}
label.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(imageView.snp.bottom).offset(8)
make.bottom.equalToSuperview()
}
}
}
class MinutelyForecastView: UIView {
//Private
private let kLevelWidth = 3
private let detailsInfoView = MinutelyForecastDetailsView()
private let swipeNudgeView = SwipeNudgeView()
private let levelsStackView = UIStackView()
private let verticalStackView = UIStackView()
private let scrollView = UIScrollView()
......@@ -95,6 +146,7 @@ class MinutelyForecastView: UIView {
prepareCenterDashLine()
prepareScrollView()
prepareVerticalStackView()
prepareNudgeView()
}
......@@ -136,6 +188,8 @@ class MinutelyForecastView: UIView {
self.location = location
self.forecastType = forecastType
self.dateFormatter.timeZone = location.timeZone
swipeNudgeView.configure(type: forecastType)
swipeNudgeView.alpha = 1
centerDashline.strokeColor = forecastType == .temperature ? kTemperatureColors.last?.cgColor
: kPrecipitationColors.last?.cgColor
......@@ -432,6 +486,14 @@ private extension MinutelyForecastView {
}
}
func prepareNudgeView() {
addSubview(swipeNudgeView)
swipeNudgeView.snp.makeConstraints { make in
make.left.equalTo(scrollView).inset(40)
make.centerY.equalTo(scrollView)
}
}
func prepareCenterDashLine() {
centerDashline.lineWidth = 1
centerDashline.lineDashPattern = [4,2]
......@@ -445,6 +507,12 @@ extension MinutelyForecastView: UIScrollViewDelegate {
if scrollView.panGestureRecognizer.state == .began {
timer?.invalidate()
timer = nil
if swipeNudgeView.alpha == 1 {
UIView.animate(withDuration: 0.3) {
self.swipeNudgeView.alpha = 0
}
}
}
let targetPointX = Double(scrollView.contentInset.left + scrollView.contentOffset.x)
......
......@@ -29,7 +29,7 @@ class ShortsCollectionViewCell: UICollectionViewCell {
footerLabel.text = shortsItem.title
if let image = self.bestImageForCellSize(images: shortsItem.images) {
let resizeOptions = ImageProcessors.Resize(size: self.bounds.size, crop: true)
let resizeOptions = ImageProcessors.Resize(size: self.bounds.size, crop: false)
let cornerRadius = ImageProcessors.RoundedCorners(radius: 12)
let imageRequest = ImageRequest(url: image.url, processors: [resizeOptions, cornerRadius])
......
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