Skip to content

Commit

Permalink
Fix build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangatuan committed Dec 17, 2023
1 parent 24a4726 commit b05d742
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 78 deletions.
2 changes: 1 addition & 1 deletion Core/CommonUI/Sources/CommonUI/Extensions/View+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public extension View {
public struct EdgeBorder: Shape {
var width: CGFloat
var edges: [Edge]

public init(width: CGFloat, edges: [Edge]) {
self.width = width
self.edges = edges
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ final class PersonDetailViewModel: ObservableObject {
guard let detail = try? await personDetail,
let images = try? await images,
let movies = try? await creditMovies,
let tv = try? await creditTV else {
let tvSeries = try? await creditTV else {
state = .error
return
}

let result: [SectionType] = [
.detailInfo(detail, numberOfFilms: movies.count + tv.count),
.detailInfo(detail, numberOfFilms: movies.count + tvSeries.count),
.images(images),
.movies(movies),
.tvSeries(tv)
.tvSeries(tvSeries)
]

state = .display(data: result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import CommonUI

struct CreditImagesSectionView: View {
let images: [MovieImage]

private let rows = [
GridItem(.flexible()),
]

var body: some View {
Section {
ScrollView(.horizontal, showsIndicators: false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import Router

struct CreditMoviesSectionView: View {
@EnvironmentObject private var router: Router

let movies: [Movie]

private let rows = [
GridItem(.flexible()),
]

var body: some View {
Section {
ScrollView(.horizontal, showsIndicators: false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import Router

struct CreditTVSeriesSectionView: View {
@EnvironmentObject private var router: Router

let tvSeries: [TVSeries]

private let rows = [
GridItem(.flexible()),
]

var body: some View {
Section {
ScrollView(.horizontal, showsIndicators: false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extension SearchViewModelTests {
}
}

// swiftlint:disable force_cast
extension SearchViewModel.State: Equatable {
public static func == (lhs: SearchViewModel.State, rhs: SearchViewModel.State) -> Bool {
if case .emptyInput = lhs, case .emptyInput = rhs { return true }
Expand All @@ -57,3 +58,4 @@ extension SearchViewModel.State: Equatable {
return false
}
}
// swiftlint: enable force_cast
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import Domain
import CommonUI

struct AiringTodayTVSeriesView: View {

enum ButtonType: String {
case favorite = "Favorite"
case share = "Share"

var imageName: String {
switch self {
case .favorite:
Expand All @@ -23,7 +23,7 @@ struct AiringTodayTVSeriesView: View {
return "share"
}
}

var primaryColor: Color {
switch self {
case .favorite:
Expand All @@ -33,12 +33,12 @@ struct AiringTodayTVSeriesView: View {
}
}
}

private let tvseries: [TVSeries]
init(tvseries: [TVSeries]) {
self.tvseries = tvseries
}

var body: some View {
Section {
VStack(spacing: 8) {
Expand All @@ -52,42 +52,42 @@ struct AiringTodayTVSeriesView: View {
}
.modifier(DefaultListModifier())
}

private var shortInfoView: some View {
VStack(alignment: .leading, spacing: 8) {
HStack {
Text(tvseries[0].originalName ?? "")
.font(.bold20)
.foregroundColor(.white)

Spacer()

Image("play")
.frame(width: 24, height: 24)
}

HStack(spacing: 8) {
createButton(for: .favorite)
createButton(for: .share)
}
}
}

private func createButton(for type: ButtonType) -> some View {
HStack {
ZStack(alignment: .center) {
type.primaryColor
.frame(width: 24, height: 24)
.cornerRadius(4)

Image(type.imageName)
.frame(width: 16, height: 16)
}

Text(type.rawValue)
.font(.regular14)
.foregroundColor(.white)

Spacer()
}
.padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Domain
import DesignSystem
import SwiftUI
import Router
import Network

extension TVSeries: ImageHolder {
public var imageURL: URL? {
Expand Down
24 changes: 12 additions & 12 deletions Foundation/Domain/Sources/DomainData/Repository/APIEndpoints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enum APIEndpoints {
httpMethod: .get
)
}

static func addMovieRating(movieId: Int, value: Double) -> APIEndpoint {
return .init(
path: "/3/movie/\(movieId)/rating",
Expand Down Expand Up @@ -159,21 +159,21 @@ extension APIEndpoints {
httpMethod: .get
)
}

static var airingTodayEndpoint: APIEndpoint {
return .init(
path: "/3/tv/airing_today",
httpMethod: .get
)
}

static var topRatedEndpoint: APIEndpoint {
return .init(
path: "/3/tv/top_rated",
httpMethod: .get
)
}

static func addMovieTVSeries(id: Int, value: Double) -> APIEndpoint {
return .init(
path: "/3/tv/\(id)/rating",
Expand Down Expand Up @@ -202,7 +202,7 @@ extension APIEndpoints {
)
)
}

static func addToWatchlist(mediaType: String, mediaId: Int, watchlist: Bool) -> APIEndpoint {
return .init(
path: "/3/account/20023836/watchlist",
Expand All @@ -216,28 +216,28 @@ extension APIEndpoints {
)
)
}

static var fetchFavoriteMoviesEndpoint: APIEndpoint {
.init(
path: "/3/account/20023836/favorite/movies",
httpMethod: .get
)
}

static var fetchFavoriteTVSeriesEndpoint: APIEndpoint {
.init(
path: "/3/account/20023836/favorite/tv",
httpMethod: .get
)
}

static var fetchWatchlistMoviesEndpoint: APIEndpoint {
.init(
path: "/3/account/20023836/watchlist/movies",
httpMethod: .get
)
}

static var fetchWatchlistTVEndpoint: APIEndpoint {
.init(
path: "/3/account/20023836/watchlist/tv",
Expand All @@ -254,21 +254,21 @@ extension APIEndpoints {
httpMethod: .get
)
}

static func fetchPersonImages(personId: Int) -> APIEndpoint {
.init(
path: "/3/person/\(personId)/images",
httpMethod: .get
)
}

static func fetchPersonMovieCredit(personId: Int) -> APIEndpoint {
.init(
path: "/3/person/\(personId)/movie_credits",
httpMethod: .get
)
}

static func fetchPersonTVCredit(personId: Int) -> APIEndpoint {
.init(
path: "/3/person/\(personId)/tv_credits",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,54 @@ public final class AccountRepository: IAccountRepository {
public init(apiClientService: IAPIClientService) {
self.apiClientService = apiClientService
}

public func addToWatchList(mediaType: String, mediaId: Int, watchlist: Bool) async -> Bool {
do {
let result = try await apiClientService.request(
APIEndpoints.addToWatchlist(mediaType: mediaType, mediaId: mediaId, watchlist: watchlist),
for: Result.self
)

return result.success
} catch {
return false
}
}

public func addFavorite(mediaType: String, mediaId: Int, favorite: Bool) async -> Bool {
do {
let result = try await apiClientService.request(
APIEndpoints.addFavorite(mediaType: mediaType, mediaId: mediaId, favorite: favorite),
for: Result.self
)

return result.success
} catch {
return false
}
}

public func fetchFavoriteMovies() async throws -> [Movie] {
try await apiClientService.request(
APIEndpoints.fetchFavoriteMoviesEndpoint,
mapper: TrendingMovieResponseMapper()
)
}

public func fetchFavoriteTV() async throws -> [TVSeries] {
try await apiClientService.request(
APIEndpoints.fetchFavoriteTVSeriesEndpoint,
mapper: TVSeriesListResponseMapper()
)
}

public func fetchWatchlistMovies() async throws -> [Movie] {
try await apiClientService.request(
APIEndpoints.fetchWatchlistMoviesEndpoint,
mapper: TrendingMovieResponseMapper()
)
}

public func fetchWatchlistTV() async throws -> [TVSeries] {
try await apiClientService.request(
APIEndpoints.fetchWatchlistTVEndpoint,
Expand Down
3 changes: 0 additions & 3 deletions Foundation/HelperMacros/Sources/HelperMacrosClient/main.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import HelperMacros
import Foundation

let a = 17
let b = 25

let (result, code) = #stringify(a + b)

print("The value \(result) was produced by the code \"\(code)\"")
Expand Down
Loading

0 comments on commit b05d742

Please sign in to comment.