Skip to content
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

update cell models #46

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

aslanmehmetsalih
Copy link
Collaborator

No description provided.

let isEditorChoice: Bool
var followButtonTapped: VoidClosure?

lazy var recipeCommnetAndLikeCountText: String? = {
Copy link

Choose a reason for hiding this comment

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

Why need to use lazy var? both count variables were declared with var,

 var commentCount: Int
 var likeCount: Int

and here is the corner case:
if the count will change after the text was created, the string will look like the wrong count just because of lazy var.

I'm not sure your requirements here but, it's looking like a problematic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

both commentCount and likeCount both updated to let.

public var seeAllButtonTitle: String? = {
return Localizable.Favorites.seeAllButtonTitle
}()
public var seeAllButtonTapped: ((Int, String) -> Void)?
Copy link

@asilturk asilturk Aug 5, 2022

Choose a reason for hiding this comment

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

Think about using typealias like this kind of generic type requirements. would define it, in the global, could improve code reading. extensions are also helpful

Check it out:
SampleProject/SampleProject/Scenes/Recipes/Entity/RecipesCellModel.swift
L: 25 - VoidClosure

Copy link
Collaborator Author

@aslanmehmetsalih aslanmehmetsalih Oct 6, 2022

Choose a reason for hiding this comment

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

add public typealias TwoVariablesClosure<A, B> = ((A, B) -> Void) for this case

public var categoryImageURL: String?
public var categoryName: String?
public var seeAllButtonTitle: String? = {
return Localizable.Favorites.seeAllButtonTitle
Copy link

Choose a reason for hiding this comment

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

explicit return non required

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

explicit return remove ^^

Comment on lines 1 to 58
// swiftlint:disable all
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen

import Foundation

// swiftlint:disable superfluous_disable_command file_length implicit_return

// MARK: - Strings

// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
internal enum Localizable {
internal enum Favorites {
/// %d Yorum %d Beğeni
internal static func recipeStats(_ p1: Int, _ p2: Int) -> String {
return Localizable.tr("Favorites", "recipeStats", p1, p2)
}
/// TÜMÜNÜ GÖR
internal static let seeAllButtonTitle = Localizable.tr("Favorites", "seeAllButtonTitle")
/// %d Tarif %d Takipçi
internal static func userStats(_ p1: Int, _ p2: Int) -> String {
return Localizable.tr("Favorites", "userStats", p1, p2)
}
}
internal enum Recipes {
/// %d Yorum %d Beğeni
internal static func recipeStats(_ p1: Int, _ p2: Int) -> String {
return Localizable.tr("Recipes", "recipeStats", p1, p2)
}
/// %d Tarif %d Takipçi
internal static func userStats(_ p1: Int, _ p2: Int) -> String {
return Localizable.tr("Recipes", "userStats", p1, p2)
}
}
}
// swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces

// MARK: - Implementation Details

extension Localizable {
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
let format = BundleToken.bundle.localizedString(forKey: key, value: nil, table: table)
return String(format: format, locale: Locale.current, arguments: args)
}
}

// swiftlint:disable convenience_type
private final class BundleToken {
static let bundle: Bundle = {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}()
}
// swiftlint:enable convenience_type
Copy link

Choose a reason for hiding this comment

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

⚠️ In the rest of the project , I saw that 4 lines of indentation were used. But these lines it was 2. Maybe u need to fix that and wanna add to your guidelines for more readability.

https://github.com/mobillium/iOS-Guidelines/blob/master/swift-guideline.md

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is automatically generated by Swiftgen. We do not enforce any rules (swiftlint or style guide) for this file.

return Localizable.tr("Favorites", "userStats", p1, p2)
}
}
internal enum Recipes {
Copy link

Choose a reason for hiding this comment

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

need to explicit internal? I'm not sure your requirements right here but it is looking unnecessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is automatically generated by Swiftgen. We do not enforce any rules (swiftlint or style guide) for this file.

extension Localizable {
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
let format = BundleToken.bundle.localizedString(forKey: key, value: nil, table: table)
return String(format: format, locale: Locale.current, arguments: args)
Copy link

Choose a reason for hiding this comment

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

use shortened style rather than Locale.current

here is the rule:
Use compiler inferred context to write shorter, clear code.
https://github.com/mobillium/iOS-Guidelines/blob/master/swift-guideline.md

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is automatically generated by Swiftgen. We do not enforce any rules (swiftlint or style guide) for this file.

internal enum Favorites {
/// %d Yorum %d Beğeni
internal static func recipeStats(_ p1: Int, _ p2: Int) -> String {
return Localizable.tr("Favorites", "recipeStats", p1, p2)
Copy link

Choose a reason for hiding this comment

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

You can use Self.tr... for static method calls, rather than Localizable.tr("Favorites", "recipeStats", p1, p2) for more readability

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is automatically generated by Swiftgen. We do not enforce any rules (swiftlint or style guide) for this file.

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