diff --git a/dimensionhub/Views/DetailView.swift b/dimensionhub/Views/DetailView.swift index cd36dda..5a56ffa 100644 --- a/dimensionhub/Views/DetailView.swift +++ b/dimensionhub/Views/DetailView.swift @@ -294,7 +294,7 @@ extension DetailView { AsyncImage(url: URL(string: episode.thumb)) { image in image .resizable() - .aspectRatio(contentMode: .fit) + .aspectRatio(contentMode: .fill) .frame(width: 90, height: 70) .clipped() } placeholder: { diff --git a/dimensionhub/Views/IndexView.swift b/dimensionhub/Views/IndexView.swift index 9b9c758..af2352c 100644 --- a/dimensionhub/Views/IndexView.swift +++ b/dimensionhub/Views/IndexView.swift @@ -390,8 +390,7 @@ extension IndexView { AsyncImage(url: URL(string: item.thumb)) { image in image .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: geometry.frame(in: .local).width, height: 80) + .aspectRatio(contentMode: .fill) .clipped() } placeholder: { ProgressView() @@ -450,23 +449,34 @@ extension IndexView { ForEach(group.items, id: \.id) { item in NavigationLink(destination: DetailView(id: item.id)) { AsyncImage(url: URL(string: item.thumb)) { image in - image.resizable() + image + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: 370, height: 180) + .clipped() } placeholder: { ProgressView() } .frame(width: 370, height: 180) .overlay { HStack { - VStack(alignment: .leading, spacing: 8) { - Text(item.name) - .font(.system(size: 16)) - .foregroundColor(Color(hex: "#333333")) - .lineLimit(1) - - Text(item.status) - .font(.system(size: 12)) - .foregroundColor(Color(hex: "#333333")) - .lineLimit(1) + VStack { + VStack(alignment: .leading, spacing: 8) { + Text(item.name) + .font(.system(size: 16)) + .foregroundColor(.white) + .lineLimit(1) + + Text(item.status) + .font(.system(size: 12)) + .foregroundColor(.white) + .lineLimit(1) + } + .padding(5) + .background( + Color.black.opacity(0.6) + ) + .cornerRadius(5) Spacer() } diff --git a/dimensionhub/Views/ListView.swift b/dimensionhub/Views/ListView.swift index bba4fab..e93317c 100644 --- a/dimensionhub/Views/ListView.swift +++ b/dimensionhub/Views/ListView.swift @@ -109,31 +109,7 @@ struct ListView: View { ScrollView(.vertical, showsIndicators: false) { LazyVStack(alignment: .center, spacing: 15) { ForEach(detailModel.selectedEpisodes) { episode in - HStack(alignment: .center) { - AsyncImage(url: URL(string: episode.thumb)) { image in - image.resizable() - } placeholder: { - ProgressView() - } - .frame(width: 90, height: 60) - - VStack(alignment: .leading, spacing: 20) { - Text(episode.num_name) - .font(.system(size: 12)) - .foregroundColor(Color(hex: "#333333")) - - Text(episode.name) - .font(.system(size: 12)) - .foregroundColor(Color(hex: "#333333")) - .lineLimit(1) - } - Spacer() - } - .onTapGesture { - if let playUrl = URL(string: episode.play) { - UIApplication.shared.open(playUrl) - } - } + EpisodeView(episode: episode) } } } @@ -165,6 +141,46 @@ struct ListView: View { } +extension ListView { + + struct EpisodeView: View { + let episode: ListModel.Episode + + var body: some View { + HStack(alignment: .center) { + AsyncImage(url: URL(string: episode.thumb)) { image in + image + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: 90, height: 60) + .clipped() + } placeholder: { + ProgressView() + } + .frame(width: 90, height: 60) + + VStack(alignment: .leading, spacing: 20) { + Text(episode.num_name) + .font(.system(size: 12)) + .foregroundColor(Color(hex: "#333333")) + + Text(episode.name) + .font(.system(size: 12)) + .foregroundColor(Color(hex: "#333333")) + .lineLimit(1) + } + Spacer() + } + .onTapGesture { + if let playUrl = URL(string: episode.play) { + UIApplication.shared.open(playUrl) + } + } + } + } +} + + #Preview { ListView(id: 19625) }