Skip to content

Conversation

@MaxCode2023
Copy link
Owner

No description provided.


import UIKit

class AuthViewController: UIViewController {

Choose a reason for hiding this comment

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

final
Не забывайте проставлять данное ключевое слово для ускорения работы компилятора. Это оптимизация его работы. В таком случае он будет быстрее при вызове функции находить адрес ячейки памяти, где лежит реализации вызванной функции.
https://habr.com/ru/post/673400/

case tokenKey = "BearerToken"
}

class OAuth2TokenStorage {

Choose a reason for hiding this comment

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

final

}

final class OAuth2Service {
static let shared = OAuth2Service()

Choose a reason for hiding this comment

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

Раз синглтон, то должен быть
private init() {}


guard let window = UIApplication.shared.windows.first else { fatalError("Invalid Configuration") }
let splashViewController = SplashViewController()
window.rootViewController = splashViewController
Copy link

@tsaidov7 tsaidov7 Feb 13, 2023

Choose a reason for hiding this comment

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

Ой-ей-ей. Сервис не должен никак касаться презентейшена и порождать контроллеры. Тем более устанавливать их)
Я бы советовал тебе здесь комплишн пробросить наверх, и тот, кто вызвал этот метод, как раз и устанавливал новый рутовый контроллер в своей кложуре

case .success(let body):
let authToken = body.accessToken
self.authToken = authToken
completion(.success(authToken))

Choose a reason for hiding this comment

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

Вот здесь же ты комплишн передаешь наверх)

//

import Foundation
import UIKit

Choose a reason for hiding this comment

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

UIKit содержит в себе Foundation. Поэтому оставляй только UIKit

final class WebViewViewController: UIViewController {

@IBOutlet private weak var webView: WKWebView!
@IBOutlet weak var progressView: UIProgressView!

Choose a reason for hiding this comment

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

Почему одна приватная, а другая internal?

Choose a reason for hiding this comment

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

Не должен прогресс наружу торчать

let SecretKey = "b99lHBvBrUgVpF70lQFrvKJ3hyyCCQMA0tk28nVoTB4"
let RedirectURI = "urn:ietf:wg:oauth:2.0:oob"
let AccessScope = "public+read_user+write_likes"
let DefaultBaseURL = URL(string: "https://api.unsplash.com")!

Choose a reason for hiding this comment

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

С маленькой буквы, это же не типы данных)


import Foundation

class ImageListService {

Choose a reason for hiding this comment

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

final

request = makeRequest(path: "/photos/\(photoId)/like", httpMethod: "POST", baseURL: DefaultBaseURL)
} else {
request = makeRequest(path: "/photos/\(photoId)/like", httpMethod: "DELETE", baseURL: DefaultBaseURL)
}

Choose a reason for hiding this comment

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

Тернарный оператор лучше будет тут + isLike и так булево значение, не нужно его сравнивать с true/false
true == true -> true
false == true -> false
То есть можно просто записать
if isLike { ... }

import UIKit
import Kingfisher

class ImagesListCell: UITableViewCell {

Choose a reason for hiding this comment

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

final

import UIKit
import Kingfisher

class ImagesListViewController: UIViewController {

Choose a reason for hiding this comment

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

final


class ImagesListViewController: UIViewController {

@IBOutlet private var tableViewImage: UITableView!

Choose a reason for hiding this comment

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

private weak var


final class ProfileImageService {

static let shared = ProfileImageService()

Choose a reason for hiding this comment

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

private init() {}

import UIKit
import Kingfisher

class ProfileViewController: UIViewController {

Choose a reason for hiding this comment

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

final


import UIKit

class SingleImageViewController: UIViewController {

Choose a reason for hiding this comment

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

final

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak private var scrollView: UIScrollView!

@IBOutlet weak var sharingButton: UIButton!

Choose a reason for hiding this comment

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

Все приватные должны быть

UIBlockingProgressHUD.dismiss()
self.switchToTabBarController()
case .failure:
UIBlockingProgressHUD.dismiss()

Choose a reason for hiding this comment

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

Дублируется код. Можно вынести после switch

URLQueryItem(name: "code", value: code),
URLQueryItem(name: "grant_type", value: "authorization_code")
]
let url = urlComponents.url!

Choose a reason for hiding this comment

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

В продакшн коде не используется принудительное извлечение значения. Разворачивай опционалы безопасно, пожалуйста

case width = "width"
case height = "height"
case color = "color"
case likes = "likes"

Choose a reason for hiding this comment

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

Не нужно указывать значения кейсам, названия которых совпадают) Только тем, поля которых отличаются в json

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