-
Notifications
You must be signed in to change notification settings - Fork 24
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
base: master
Are you sure you want to change the base?
Changes from all commits
461f042
d61aff4
bec796e
bfa7d7d
7307e45
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 |
---|---|---|
|
@@ -74,4 +74,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: 240bbaaf597009e1611ff399ef5269ba297f09b1 | ||
|
||
COCOAPODS: 1.11.2 | ||
COCOAPODS: 1.11.3 |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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 CommentList { | ||
/// %d Tarif %d Takipçi | ||
internal static func userStats(_ p1: Int, _ p2: Int) -> String { | ||
return Localizable.tr("CommentList", "userStats", p1, p2) | ||
} | ||
} | ||
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 RecipeDetail { | ||
/// %d Tarif %d Takipçi | ||
internal static func userStats(_ p1: Int, _ p2: Int) -> String { | ||
return Localizable.tr("RecipeDetail", "userStats", p1, p2) | ||
} | ||
} | ||
internal enum Recipes { | ||
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. need to explicit internal? I'm not sure your requirements right here but it is looking unnecessary. 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. This file is automatically generated by Swiftgen. We do not enforce any rules (swiftlint or style guide) for this file. |
||
/// %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) | ||
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. use shortened style rather than Locale.current here is the rule: 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. This file is automatically generated by Swiftgen. We do not enforce any rules (swiftlint or style guide) for this file. |
||
} | ||
} | ||
|
||
// 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// CommentListCellModel.swift | ||
// SampleProject | ||
// | ||
// Created by Mehmet Salih Aslan on 11.08.2022. | ||
// Copyright © 2022 Mobillium. All rights reserved. | ||
// | ||
|
||
import MobilliumUserDefaults | ||
|
||
class CommentListCellModel: CommentCellProtocol { | ||
|
||
let commentId: Int | ||
let userId: Int | ||
var imageUrl: String? | ||
var username: String? | ||
var userFollowerCount: Int | ||
var userRecipeCount: Int | ||
var userRecipeAndFollowerCountText: String? { | ||
return Localizable.CommentList.userStats(userRecipeCount, userFollowerCount) | ||
} | ||
var timeDifferenceText: String? | ||
var commentText: String? | ||
var isOwner: Bool | ||
var moreButtonTapped: VoidClosure? | ||
var commentTextDidChanged: VoidClosure? | ||
|
||
public init(comment: RecipeComment) { | ||
self.userId = comment.user.id | ||
self.imageUrl = comment.user.image?.url | ||
self.username = comment.user.username | ||
self.userFollowerCount = comment.user.followedCount | ||
self.userRecipeCount = comment.user.recipeCount | ||
|
||
let isOwner = comment.user.id == DefaultsKey.userId.value | ||
self.commentId = comment.id | ||
self.timeDifferenceText = comment.timeDifference | ||
self.commentText = comment.text | ||
self.isOwner = isOwner | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
CommentList.strings | ||
SampleProject | ||
|
||
Created by Mehmet Salih Aslan on 11.08.2022. | ||
Copyright © 2022 Mobillium. All rights reserved. | ||
*/ | ||
|
||
"userStats" = "%d Tarif %d Takipçi"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// FavoritesCellModel.swift | ||
// SampleProject | ||
// | ||
// Created by Mehmet Salih Aslan on 27.07.2022. | ||
// Copyright © 2022 Mobillium. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public final class FavoritesCellModel: CategoryWithRecipesCellProtocol { | ||
public let categoryId: Int | ||
public let categoryImageURL: String? | ||
public let categoryName: String? | ||
public let seeAllButtonTitle: String? = Localizable.Favorites.seeAllButtonTitle | ||
public var seeAllButtonTapped: TwoVariablesClosure<Int, String>? | ||
public let cellItems: [RecipeSmallCellProtocol] | ||
public var didSelectRecipe: IntClosure? | ||
|
||
init(category: MainCategory) { | ||
let cellItems = category.recipes.map({ FavoritesRecipeCellModel(recipe: $0) }) | ||
self.categoryId = category.id | ||
self.categoryImageURL = nil | ||
self.categoryName = category.name | ||
self.cellItems = cellItems | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// FavoritesRecipeCellModel.swift | ||
// SampleProject | ||
// | ||
// Created by Mehmet Salih Aslan on 27.07.2022. | ||
// Copyright © 2022 Mobillium. All rights reserved. | ||
// | ||
|
||
class FavoritesRecipeCellModel: RecipeSmallCellProtocol { | ||
|
||
let recipeId: Int | ||
let userId: Int | ||
let userImageUrl: String? | ||
let username: String? | ||
let recipeTitle: String? | ||
let categoryName: String? | ||
let recipeImageUrl: String? | ||
let commentCount: Int | ||
let likeCount: Int | ||
lazy var recipeCommnetAndLikeCountText: String? = { | ||
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. Why need to use lazy var? both count variables were declared with var,
and here is the corner case: I'm not sure your requirements here but, it's looking like a problematic 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. both commentCount and likeCount both updated to let. |
||
return Localizable.Recipes.recipeStats(commentCount, likeCount) | ||
}() | ||
let isEditorChoice: Bool | ||
var followButtonTapped: VoidClosure? | ||
|
||
init(recipe: Recipe) { | ||
self.recipeId = recipe.id | ||
self.userId = recipe.user.id | ||
self.userImageUrl = recipe.user.image?.url | ||
self.username = recipe.user.username | ||
self.recipeTitle = recipe.title | ||
self.categoryName = recipe.category.name | ||
self.recipeImageUrl = recipe.images.first?.url | ||
self.commentCount = recipe.commentCount | ||
self.likeCount = recipe.likeCount | ||
self.isEditorChoice = recipe.isEditorChoice | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
Favorites.strings | ||
SampleProject | ||
|
||
Created by Mehmet Salih Aslan on 4.08.2022. | ||
Copyright © 2022 Mobillium. All rights reserved. | ||
*/ | ||
|
||
"userStats" = "%d Tarif %d Takipçi"; | ||
"recipeStats" = "%d Yorum %d Beğeni"; | ||
"seeAllButtonTitle" = "TÜMÜNÜ GÖR"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// RecipeDetailComentCellModel.swift | ||
// SampleProject | ||
// | ||
// Created by Mehmet Salih Aslan on 11.08.2022. | ||
// Copyright © 2022 Mobillium. All rights reserved. | ||
// | ||
|
||
import MobilliumUserDefaults | ||
|
||
class RecipeDetailComentCellModel: CommentCellProtocol { | ||
|
||
let commentId: Int | ||
let userId: Int | ||
var imageUrl: String? | ||
var username: String? | ||
var userFollowerCount: Int | ||
var userRecipeCount: Int | ||
var userRecipeAndFollowerCountText: String? { | ||
return Localizable.RecipeDetail.userStats(userRecipeCount, userFollowerCount) | ||
} | ||
var timeDifferenceText: String? | ||
var commentText: String? | ||
var isOwner: Bool | ||
var moreButtonTapped: VoidClosure? | ||
var commentTextDidChanged: VoidClosure? | ||
|
||
public init(comment: RecipeComment) { | ||
self.userId = comment.user.id | ||
self.imageUrl = comment.user.image?.url | ||
self.username = comment.user.username | ||
self.userFollowerCount = comment.user.followedCount | ||
self.userRecipeCount = comment.user.recipeCount | ||
|
||
let isOwner = comment.user.id == DefaultsKey.userId.value | ||
self.commentId = comment.id | ||
self.timeDifferenceText = comment.timeDifference | ||
self.commentText = comment.text | ||
self.isOwner = isOwner | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// RecipeDetailCommentHeaderCell.swift | ||
// SampleProject | ||
// | ||
// Created by Mehmet Salih Aslan on 11.08.2022. | ||
// Copyright © 2022 Mobillium. All rights reserved. | ||
// | ||
|
||
final class RecipeDetailCommentHeaderCell: RecipeHeaderCellProtocol { | ||
var imageUrl: String | ||
var isEditorChoice: Bool | ||
|
||
init?(imageUrl: String?, isEditorChoice: Bool) { | ||
guard let imageUrl = imageUrl else { | ||
return nil | ||
} | ||
self.imageUrl = imageUrl | ||
self.isEditorChoice = isEditorChoice | ||
} | ||
} |
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.
You can use
Self.tr...
for static method calls, rather thanLocalizable.tr("Favorites", "recipeStats", p1, p2)
for more readabilityThere 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.
This file is automatically generated by Swiftgen. We do not enforce any rules (swiftlint or style guide) for this file.