Skip to content

Develop#9

Open
Adletski wants to merge 15 commits intomainfrom
develop
Open

Develop#9
Adletski wants to merge 15 commits intomainfrom
develop

Conversation

@Adletski
Copy link
Owner

all app logic finished, ready merge to main branch

import SnapKit

class ViewController: UIViewController, CAAnimationDelegate {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// MARK: - Properties

let backgroundProgressLayer = CAShapeLayer()
let animationOfProgressLayer = CABasicAnimation(keyPath: "strokeEnd")

var timer = Timer()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все свойства private

workModeButton.addTarget(self, action: #selector(workModeButtonTapped), for: .touchUpInside)
return workModeButton
}()
private lazy var restModeButton: UIButton = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спейсы перед свойтвами

restModeButton.addTarget(self, action: #selector(restModeButtonTapped), for: .touchUpInside)
return restModeButton
}()
private lazy var appLabel: UILabel = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спейсы перед свойтвами

appLabel.font = UIFont(name: "Marker Felt", size: 30)
return appLabel
}()
private lazy var timerLabel: UILabel = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спейсы перед свойтвами

restartButton.setTitle("Restart", for: .normal)
restartButton.setTitleColor(.black, for: .normal)
restartButton.titleLabel?.font = UIFont(name: "Times New Roman", size: 30)
// restModeButton.backgroundColor = .blue
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удаляем dead code

return startButton
}()

override func viewDidLoad() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// MARK: - Lifecycle


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не пишем логику внутри viewdidLoad, тут только вызов методов

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view.backgroundColor = .white
setupHierarchy -> переименуй лучше на setupViews и туда добавь эту настройку

}
appLabel.snp.makeConstraints { appLabel in
appLabel.centerX.equalTo(view)
appLabel.top.equalTo(view).offset(view.frame.height*0.117)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

опять magic numbers, след дз не приму работы с магическами цифрами

}
}

internal func animationDidStop(_ anim: CAAnimation, finished flag: Bool) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем internal?

}
}

extension Int {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выносим в отдельную папку Foundation+Extensions внутри файл Int+Extensions

startButton.setTitleColor(.green, for: .normal)
}
}
@objc private func restartButtonTapped() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спейсы не забываем перед методами и свойствами, читать сложно

timer.invalidate()
workModeButton.backgroundColor = .gray
restModeButton.backgroundColor = .white
time = 25
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

25 -> нужно сделать константой

drawBackgroundLayer()
}

@objc private func startButtonTapped() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// MARK: - Actions

return String(format: "%02i:%02i", minutes, seconds)
}
func drawBackgroundLayer() {
backgroundProgressLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX, y: view.frame.midY), radius: view.frame.width*0.381, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

очень длинный
можно в константу отдельную, линия не должна быть больше 120
UIBezierPath(arcCenter: CGPoint(x: view.frame.midX, y: view.frame.midY), radius: view.frame.width*0.381, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath

view.layer.addSublayer(backgroundProgressLayer)
}
func drawForegroundLayer() {
foregroundProgressLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX, y: view.frame.midY), radius: view.frame.width*0.381, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь тоже самое, очень сложно читать магические числа
https://gist.github.com/mouselangelo/4d8abf2a49cd202773d4e0ba3b0701dd

foregroundProgressLayer.removeAllAnimations()
isAnimationStarted = false
}
@objc private func workModeButtonTapped() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// MARK: - Actions

все клики лучше вместо собрать и добавить марку

timerLabel.text = formatTime()
}

private func setupHierarchy() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// MARK: - Setup Views

let views = [timerLabel,appLabel,restartButton,startButton,workModeButton,restModeButton]
views.forEach { view.addSubview($0) }
}
private func setupLayout() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// MARK: - Setup Constraints


setupHierarchy()
setupLayout()
drawBackgroundLayer()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

структура контроллера должна быть такой:

// MARK: UI -> тут у тебя все UI элементы
// MARK: Properties -> тут у тебя все приватные свойства

// MARK: - Lifecycle
// MARK: - SetupViews
// MARK: - Setup Constraints
// MARK: - Actions
а потом все доп хелпер методы

у тебя все методы в разброс

@aitemr
Copy link

aitemr commented Mar 3, 2023

салем! дз принято, очень круто сделал progress bar, нужно порабоать над струтурой проекта

  1. не используй magic цифры
  2. нужно добавить метки // MARK: -
  3. нужно сделать вызов методов более структурной, в твоем когда сложно искать методы, всегда верх и вниз

@Adletski
Copy link
Owner Author

Adletski commented Mar 3, 2023

салем! дз принято, очень круто сделал progress bar, нужно порабоать над струтурой проекта

  1. не используй magic цифры
  2. нужно добавить метки // MARK: -
  3. нужно сделать вызов методов более структурной, в твоем когда сложно искать методы, всегда верх и вниз

@Adletski Adletski closed this Mar 3, 2023
@Adletski Adletski reopened this Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants