-
Notifications
You must be signed in to change notification settings - Fork 3
Elvis/status button #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Elvis/status button #270
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "dropdown.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,8 @@ class HomeViewController: UIViewController { | |
|
|
||
| override func viewWillAppear(_ animated: Bool) { | ||
| super.viewWillAppear(animated) | ||
| navigationController?.tabBarController?.tabBar.isHidden = false | ||
| // navigationController?.tabBarController?.tabBar.isHidden = true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just double checking, this is a temporary change right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup! |
||
| navigationController?.isNavigationBarHidden = true | ||
| } | ||
|
|
||
| @objc func reloadUpliftData() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // | ||
| // CircularProgressView.swift | ||
| // Uplift | ||
| // | ||
| // Created by elvis on 10/18/23. | ||
| // Copyright © 2023 Cornell AppDev. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
| import UIKit | ||
| import SnapKit | ||
|
|
||
| class CircularProgressView: UIView { | ||
|
|
||
| private var progressLayer = CAShapeLayer() | ||
| private var trackLayer = CAShapeLayer() | ||
|
|
||
| private var progressColor: UIColor! | ||
| private var width: CGFloat! | ||
|
|
||
| init(progressColor: UIColor, width: CGFloat) { | ||
| super.init(frame: .zero) | ||
|
|
||
| self.progressColor = progressColor | ||
| self.width = width | ||
|
|
||
| createCircularPath() | ||
| } | ||
|
|
||
| private func createCircularPath() { | ||
| self.layer.cornerRadius = width!/2 | ||
| let circularPath = UIBezierPath(arcCenter: CGPoint(x: width/2, y: width/2) , radius: (width - 1.5)/2, startAngle: CGFloat(-0.5 * .pi), endAngle: CGFloat(2.0 * .pi), clockwise: true) | ||
|
|
||
|
Comment on lines
+30
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this going to be used for the capacities? If so, I think it would be cool to make this more generic maybe with a |
||
| trackLayer.path = circularPath.cgPath | ||
| trackLayer.fillColor = UIColor.clear.cgColor | ||
| trackLayer.strokeColor = UIColor.gray.cgColor | ||
| trackLayer.lineWidth = 5 | ||
| trackLayer.strokeEnd = 1.0 | ||
| layer.addSublayer(trackLayer) | ||
|
|
||
| progressLayer.path = circularPath.cgPath | ||
| progressLayer.fillColor = UIColor.clear.cgColor | ||
| progressLayer.strokeColor = progressColor?.cgColor | ||
| progressLayer.lineWidth = 5 | ||
| progressLayer.strokeEnd = 0.5 | ||
| layer.addSublayer(progressLayer) | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,17 +9,18 @@ import SnapKit | |
| import UIKit | ||
|
|
||
| class HomeScreenHeaderView: UIView { | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace; you should turn on the swiftlint and make sure there's no styling related warnings before PR. |
||
| var welcomeMessage: UILabel! | ||
|
|
||
| var statusButton: StatusButton! | ||
|
|
||
| var didSetupShadow = false | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace |
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace |
||
| // BACKGROUND COLOR | ||
| backgroundColor = .white | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace |
||
| // WELCOME MESSAGE | ||
| welcomeMessage = UILabel() | ||
| welcomeMessage.font = ._24MontserratBold | ||
|
|
@@ -28,29 +29,105 @@ class HomeScreenHeaderView: UIView { | |
| welcomeMessage.numberOfLines = 0 | ||
| welcomeMessage.text = getGreeting() | ||
| addSubview(welcomeMessage) | ||
|
|
||
|
|
||
| statusButton = StatusButton() | ||
| statusButton.layer.borderColor = UIColor.gray01.cgColor | ||
| statusButton.layer.borderWidth = 1 | ||
| statusButton.layer.cornerRadius = 12 | ||
| statusButton.addTarget(self, action: #selector(showCapacityView), for: .touchUpInside) | ||
| addSubview(statusButton) | ||
|
|
||
| setupLayout() | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace |
||
| required init?(coder aDecoder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
|
|
||
| @objc func showCapacityView() { | ||
| if (statusButton.tag == 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like it would enhance readability to use a boolean variable instead of the tag property. Maybe as a property of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To add on, you could also do this in a way which moves a lot of functionality into the status button. This function could literally have two lines: |
||
| statusButton.backgroundColor = .gray00 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the design has it as white? imo based on the video having that extra contrast of white feels like it would make it more noticeable. |
||
| statusButton.tag = 1 | ||
| } else { | ||
| statusButton.backgroundColor = .gray01 | ||
| statusButton.tag = 0 | ||
| } | ||
|
|
||
| statusButton.flipDropDown() | ||
| } | ||
|
|
||
| private func getGreeting() -> String { | ||
| let currDate = Date() | ||
| let hour = Calendar.current.component(.hour, from: currDate) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace |
||
| if hour < 12 { return ClientStrings.Home.greetingMorning } | ||
| if hour < 17 { return ClientStrings.Home.greetingAfternoon} | ||
| return ClientStrings.Home.greetingEvening | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace |
||
| // MARK: - LAYOUT | ||
| func setupLayout() { | ||
| welcomeMessage.snp.makeConstraints { make in | ||
| make.bottom.equalToSuperview().inset(20) | ||
| make.leading.equalTo(24) | ||
| make.trailing.lessThanOrEqualToSuperview().inset(24) | ||
|
|
||
| } | ||
|
|
||
| statusButton.snp.makeConstraints { make in | ||
| make.trailing.equalToSuperview().inset(24) | ||
| make.centerY.equalTo(welcomeMessage.snp.centerY) | ||
| make.width.equalTo(60) | ||
| make.height.equalTo(40) | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Insert line after this } |
||
| } | ||
|
|
||
|
|
||
| class StatusButton: UIButton { | ||
|
|
||
| var circularView: UIView! | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. of type CircleProgressView instead of UIView |
||
|
|
||
| var dropDownImageView = UIImageView() | ||
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: .zero) | ||
|
|
||
| circularView = CircularProgressView(progressColor: UIColor.accentOrange, width: 24) | ||
| circularView.isUserInteractionEnabled = false | ||
| addSubview(circularView) | ||
|
|
||
| dropDownImageView.image = UIImage(named: "dropdown") | ||
| addSubview(dropDownImageView) | ||
|
|
||
| setupConstraints() | ||
| } | ||
|
|
||
| func flipDropDown() { | ||
| UIView.animate(withDuration: 0.3) { | ||
| self.circularView.transform = self.circularView.transform.rotated(by: .pi) | ||
| self.dropDownImageView.transform = self.dropDownImageView.transform.rotated(by: .pi) | ||
| } | ||
| } | ||
|
|
||
| func setupConstraints() { | ||
| circularView.snp.makeConstraints { make in | ||
| make.width.equalTo(24) | ||
| make.height.equalTo(24) | ||
| make.centerY.equalToSuperview() | ||
| make.leading.equalToSuperview().offset(10) | ||
| } | ||
|
|
||
| dropDownImageView.snp.makeConstraints { make in | ||
| make.width.equalTo(8) | ||
| make.height.equalTo(8) | ||
| make.centerY.equalTo(circularView) | ||
| make.trailing.equalToSuperview().inset(10) | ||
|
Comment on lines
+115
to
+125
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like it could be good to separate out all the constants in an enum |
||
| } | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-check to see if this is not already in the assets folder. There is an asset titled "down-arrow-solid." Is this different than that?