Conversation
deleted Main storyboard and created scene delegate window
added background image and assets for bgImage and icons
added loginLabel and layout for Login label
addeed noAccount label and sign up button
develop finished
edit UIImage force unwrap to default
| @@ -0,0 +1,21 @@ | |||
| { | |||
There was a problem hiding this comment.
лучше сделай картинку single scale, и в swift лучше загружать картинки в pdf формате
| // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). | ||
| guard let _ = (scene as? UIWindowScene) else { return } | ||
|
|
||
| guard let windowScene = (scene as? UIWindowScene) else { return } |
|
|
||
| class ViewController: UIViewController { | ||
|
|
||
| private lazy var viewBackgroundImage: UIImageView = { |
| imageView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height) | ||
| return imageView | ||
| }() | ||
| private lazy var loginLabel: UILabel = { |
| loginLabel.font = UIFont(name: "Futura", size: CGFloat(30)) | ||
| return loginLabel | ||
| }() | ||
| private lazy var usernameTextField: UITextField = { |
| usernameTextField.layer.cornerRadius = view.frame.width*0.063613 | ||
| return usernameTextField | ||
| }() | ||
| private lazy var passwordTextField: UITextField = { |
| loginButton.layer.rasterizationScale = UIScreen.main.scale | ||
| loginButton.backgroundColor = .purple | ||
| loginButton.setTitleColor(.white, for: .normal) | ||
| loginButton.layer.cornerRadius = view.frame.width*0.063613 |
There was a problem hiding this comment.
если хочешь сделать закругленные края, достачтоно view.frame.heigth/2
0.063613 магические числа лучше не используй, или сделай enum или struct с константой
| loginButton.layer.cornerRadius = view.frame.width*0.063613 | ||
| return loginButton | ||
| }() | ||
| private lazy var forgotPasswordButton: UIButton = { |
| return loginButton | ||
| }() | ||
| private lazy var forgotPasswordButton: UIButton = { | ||
| let forgotPasswordButton = UIButton() |
| return view2 | ||
| }() | ||
| private lazy var facebookButton: UIButton = { | ||
| let facebookButton = UIButton() |
There was a problem hiding this comment.
лучше все кнопки создавать через UIButton(type: .system)
| return twitterButton | ||
| }() | ||
| private lazy var facebookView: UIImageView = { | ||
| let facebookView = UIImageView(frame: CGRect(x: 10, y: 5, width: 20, height: 20)) |
There was a problem hiding this comment.
фреймы это хорошо, но лучше все делать через snapkit
| return facebookView | ||
| }() | ||
| private lazy var twitterView: UIImageView = { | ||
| let twitterView = UIImageView(frame: CGRect(x: 10, y: 5, width: 20, height: 20)) |
There was a problem hiding this comment.
фреймы это хорошо, но лучше все делать через snapkit
| super.viewDidLoad() | ||
| // Do any additional setup after loading the view. | ||
|
|
||
| setupHierarchy() |
| // Do any additional setup after loading the view. | ||
|
|
||
| setupHierarchy() | ||
| setupLayout() |
| let subviews = [viewBackgroundImage,loginLabel,usernameTextField,passwordTextField,loginButton, | ||
| forgotPasswordButton,view1,connectLabel,view2,facebookButton,facebookView, | ||
| twitterButton,twitterView,noAccount,signupButton] | ||
| subviews.forEach { view.addSubview($0) } |
|
|
||
| loginLabel.snp.makeConstraints { loginLabel in | ||
| loginLabel.centerX.equalTo(view) | ||
| loginLabel.top.equalTo(view).offset(view.frame.height*0.117) |
There was a problem hiding this comment.
магическая математика плохая практика при верстке с кодом, подумай как бы ты сделал по другому
|
|
||
| } | ||
|
|
||
| extension UITextField { |
There was a problem hiding this comment.
extension сделай лучше отдельный файлом, можешь сделать папки Foundation+Extension и UIKit+Extensions
| forgotPasswordButton.centerX.equalTo(view) | ||
| forgotPasswordButton.top.equalTo(loginButton.snp.bottom).offset(view.frame.height*0.006) | ||
| } | ||
| view1.snp.makeConstraints { view1 in |
There was a problem hiding this comment.
view1 -> нужно переименовать, плохой нейминг
| connectLabel.centerX.equalTo(view) | ||
| connectLabel.bottom.equalTo(view).inset(view.frame.height*0.235) | ||
| } | ||
| view2.snp.makeConstraints { view2 in |
There was a problem hiding this comment.
view2-> нужно переименовать, плохой нейминг
| print(view.frame.height) | ||
| } | ||
| facebookButton.snp.makeConstraints { facebookButton in | ||
| facebookButton.centerX.equalTo(view).offset(-view.frame.width/2*0.407) |
There was a problem hiding this comment.
лучше сделать без математики, подумай как убрать ratio везде
| twitterButton,twitterView,noAccount,signupButton] | ||
| subviews.forEach { view.addSubview($0) } | ||
| } | ||
| private func setupLayout() { |
| setupHierarchy() | ||
| setupLayout() | ||
| } | ||
| private func setupHierarchy() { |
| return signupButton | ||
| }() | ||
|
|
||
| override func viewDidLoad() { |
| twitterButton.layer.shadowOffset = .zero | ||
| twitterButton.layer.shadowRadius = 10 | ||
| twitterButton.layer.shouldRasterize = true | ||
| twitterButton.layer.rasterizationScale = UIScreen.main.scale |
There was a problem hiding this comment.
а что делает это свойство rasterizationScale?
| connectLabel.font = .systemFont(ofSize: 15) | ||
| return connectLabel | ||
| }() | ||
| private lazy var view2: UIView = { |
There was a problem hiding this comment.
нужно переименовать, назови лучше container
|
Салем! ДЗ принято
|
| view2.height.equalTo(1) | ||
| view2.width.equalTo(view.frame.width*0.178) | ||
| view2.bottom.equalTo(view).inset(view.frame.height*0.242) | ||
| print(view.frame.width) |
| connectLabel.bottom.equalTo(view).inset(view.frame.height*0.235) | ||
| } | ||
| view2.snp.makeConstraints { view2 in | ||
| view2.centerX.equalTo(view).offset(-view.frame.width/2*0.509) |
There was a problem hiding this comment.
лучше сделать константы view.frame.width и view.frame.height
let width = view.frame.width
а потом везде его использовать
|
дз сделано отлично |

finished all tasks, ready to merge from develop to main branch