-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Home notifications & refactor (#267)
* Rewrite home to use table view, add notifications * Animate notification dot
- Loading branch information
Showing
15 changed files
with
420 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
struct Alert { | ||
struct Alert: AutoEquatable { | ||
let id: String | ||
let contactTime: UnixTime | ||
let reportTime: UnixTime | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Generated using Sourcery 0.18.0 — https://github.com/krzysztofzablocki/Sourcery | ||
// DO NOT EDIT | ||
|
||
|
||
// MARK: Alert Equatable | ||
extension Alert: Equatable { | ||
static func ==(lhs: Alert, rhs: Alert) -> Bool { | ||
guard lhs.id == rhs.id else { return false } | ||
guard lhs.contactTime == rhs.contactTime else { return false } | ||
guard lhs.reportTime == rhs.reportTime else { return false } | ||
guard lhs.earliestSymptomTime == rhs.earliestSymptomTime else { return false } | ||
guard lhs.feverSeverity == rhs.feverSeverity else { return false } | ||
guard lhs.coughSeverity == rhs.coughSeverity else { return false } | ||
guard lhs.breathlessness == rhs.breathlessness else { return false } | ||
return true | ||
} | ||
} | ||
// MARK: UnixTime Equatable | ||
extension UnixTime: Equatable { | ||
static func ==(lhs: UnixTime, rhs: UnixTime) -> Bool { | ||
guard lhs.value == rhs.value else { return false } | ||
return true | ||
} | ||
} | ||
// MARK: UserInput Equatable | ||
extension UserInput: Equatable { | ||
static func ==(lhs: UserInput, rhs: UserInput) -> Bool { | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import UIKit | ||
|
||
class HomeItemCell: UITableViewCell { | ||
|
||
private var homeItemView: HomeItemView? | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
setupUI() | ||
|
||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setupUI() { | ||
backgroundColor = .clear | ||
contentView.backgroundColor = .clear | ||
|
||
selectionStyle = .none | ||
|
||
let view: HomeItemView = HomeItemView.fromNib() | ||
contentView.addSubview(view) | ||
view.pinAllEdgesToParent() | ||
self.homeItemView = view | ||
} | ||
|
||
public func setup(viewData: HomeItemViewData) { | ||
homeItemView?.setup(item: viewData) | ||
} | ||
} | ||
|
||
|
||
class HomeItemView: UIView { | ||
public var onAcknowledged: (() ->())? | ||
|
||
@IBOutlet weak var notificationView: UIView! | ||
@IBOutlet weak var notificationLabel: UILabel! | ||
@IBOutlet weak var titleLabel: UILabel! | ||
@IBOutlet weak var descrLabel: UILabel! | ||
@IBOutlet weak var backgroundView: UIView! | ||
|
||
override func awakeFromNib() { | ||
super.awakeFromNib() | ||
notificationView.layer.cornerRadius = 20 | ||
|
||
backgroundView.layer.cornerRadius = 15 | ||
backgroundView.layer.shadowColor = UIColor.black.cgColor | ||
backgroundView.layer.shadowOffset = CGSize(width: 4, height: 4) | ||
backgroundView.layer.shadowRadius = 4 | ||
backgroundView.layer.shadowOpacity = 0.25 | ||
} | ||
|
||
func setup(item: HomeItemViewData) { | ||
notificationView.isHidden = item.notification == nil | ||
notificationLabel.isHidden = item.notification == nil | ||
notificationLabel.text = item.notification?.text | ||
titleLabel.text = item.title | ||
descrLabel.text = item.descr | ||
|
||
if item.notification != nil { | ||
notificationView.transform = CGAffineTransform(scaleX: 0, y: 0) | ||
notificationLabel.alpha = 0 | ||
UIView.animate(withDuration: 0.5, delay: 0.5, usingSpringWithDamping: | ||
0.6, initialSpringVelocity: 0.6, options: .curveEaseOut, animations: { | ||
self.notificationView.transform = CGAffineTransform(scaleX: 1, y: 1) | ||
self.notificationLabel.alpha = 1 | ||
}, completion: nil) | ||
} | ||
} | ||
|
||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { | ||
super.touchesBegan(touches, with: event) | ||
backgroundView.backgroundColor = .coEpiLightGray | ||
} | ||
|
||
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { | ||
super.touchesEnded(touches, with: event) | ||
backgroundView.backgroundColor = .white | ||
} | ||
|
||
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { | ||
super.touchesCancelled(touches, with: event) | ||
backgroundView.backgroundColor = .white | ||
} | ||
} |
Oops, something went wrong.