KFImage를 이용하여 불러오는 이미지 다운샘플링

This commit is contained in:
Yu Sung
2024-10-11 18:16:24 +09:00
parent eba9e4dec2
commit 9a461f14ad
64 changed files with 527 additions and 0 deletions

View File

@@ -23,6 +23,13 @@ struct SectionEventBannerView: View {
let item = items[index]
if let url = item.thumbnailImageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
KFImage(URL(string: url))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: proxy.size.width,
height: proxy.size.height
)
)
.resizable()
.frame(width: proxy.size.width, height: proxy.size.height, alignment: .center)
.tag(index)
@@ -35,6 +42,13 @@ struct SectionEventBannerView: View {
}
} else {
KFImage(URL(string: item.thumbnailImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: proxy.size.width,
height: proxy.size.height
)
)
.resizable()
.frame(width: proxy.size.width, height: proxy.size.height, alignment: .center)
.tag(index)

View File

@@ -17,6 +17,13 @@ struct LiveNowAllItemView: View {
VStack(alignment: .leading, spacing: 8) {
ZStack {
KFImage(URL(string: item.coverImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: itemWidth,
height: itemWidth * 144 / 102
)
)
.resizable()
.scaledToFill()
.frame(width: itemWidth, height: itemWidth * 144 / 102, alignment: .center)
@@ -100,6 +107,13 @@ struct LiveNowAllItemView: View {
HStack(spacing: 5.3) {
KFImage(URL(string: item.creatorProfileImage))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 21.3,
height: 21.3
)
)
.resizable()
.scaledToFill()
.frame(width: 21.3, height: 21.3, alignment: .center)

View File

@@ -19,6 +19,13 @@ struct LiveNowItemView: View {
VStack(alignment: .leading, spacing: 8) {
ZStack {
KFImage(URL(string: item.coverImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: width,
height: height
)
)
.resizable()
.scaledToFill()
.frame(width: width, height: height, alignment: .center)
@@ -80,6 +87,13 @@ struct LiveNowItemView: View {
HStack(spacing: 5.3) {
KFImage(URL(string: item.creatorProfileImage))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 21.3,
height: 21.3
)
)
.resizable()
.scaledToFill()
.frame(width: 21.3, height: 21.3, alignment: .center)

View File

@@ -32,6 +32,13 @@ struct SectionRecommendLiveView: View {
let item = items[index]
if let url = item.imageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
KFImage(URL(string: url))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: screenSize().width - 26.7,
height: (screenSize().width - 26.7) * 0.53
)
)
.resizable()
.scaledToFill()
.frame(
@@ -44,6 +51,13 @@ struct SectionRecommendLiveView: View {
.cornerRadius(4.7)
} else {
KFImage(URL(string: item.imageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: screenSize().width - 26.7,
height: (screenSize().width - 26.7) * 0.53
)
)
.resizable()
.scaledToFill()
.frame(

View File

@@ -55,6 +55,13 @@ struct SectionRecommendChannelView: View {
VStack(spacing: 13.3) {
ZStack(alignment: .bottom) {
KFImage(URL(string: item.profileImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: screenSize().width * 0.18,
height: screenSize().width * 0.18
)
)
.resizable()
.scaledToFill()
.frame(width: screenSize().width * 0.18, height: screenSize().width * 0.18, alignment: .center)

View File

@@ -17,6 +17,13 @@ struct LiveReservationAllItemView: View {
HStack(spacing: 20) {
ZStack(alignment: .topLeading) {
KFImage(URL(string: item.coverImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 80,
height: 116
)
)
.resizable()
.scaledToFill()
.frame(width: 80, height: 116.7, alignment: .top)

View File

@@ -17,6 +17,13 @@ struct LiveReservationItemView: View {
HStack(spacing: 20) {
ZStack(alignment: .topLeading) {
KFImage(URL(string: item.coverImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 80,
height: 116
)
)
.resizable()
.scaledToFill()
.frame(width: 80, height: 116, alignment: .top)

View File

@@ -29,6 +29,13 @@ struct MyLiveReservationItemView: View {
HStack(alignment: .top, spacing: 20) {
ZStack(alignment: .topLeading) {
KFImage(URL(string: item.coverImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 80,
height: 116
)
)
.resizable()
.scaledToFill()
.frame(width: 80, height: 116, alignment: .top)

View File

@@ -49,6 +49,13 @@ struct LiveRoomChatItemView: View {
}
KFImage(URL(string: chatMessage.profileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 30,
height: 30
)
)
.resizable()
.scaledToFill()
.frame(width: 30, height: 30, alignment: .top)

View File

@@ -16,6 +16,13 @@ struct LiveRoomDonationChatItemView: View {
HStack(spacing: 13.3) {
ZStack(alignment: .bottomTrailing) {
KFImage(URL(string: chatMessage.profileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 33.3,
height: 33.3
)
)
.resizable()
.scaledToFill()
.frame(width: 33.3, height: 33.3, alignment: .top)

View File

@@ -16,6 +16,13 @@ struct LiveRoomRouletteDonationChatItemView: View {
HStack(spacing: 13.3) {
ZStack(alignment: .bottomTrailing) {
KFImage(URL(string: chatMessage.profileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 33.3,
height: 33.3
)
)
.resizable()
.scaledToFill()
.frame(width: 33.3, height: 33.3, alignment: .top)

View File

@@ -85,6 +85,13 @@ struct LiveRoomCreateView: View {
.cornerRadius(10)
} else if let coverImageUrl = viewModel.coverImageUrl {
KFImage(URL(string: coverImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 80,
height: 116.8
)
)
.resizable()
.scaledToFill()
.frame(width: 80, height: 116.8, alignment: .top)

View File

@@ -56,6 +56,13 @@ struct LiveRoomCreateTagView: View {
VStack(spacing: 16.7) {
ZStack {
KFImage(URL(string: tag.image))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 60,
height: 60
)
)
.resizable()
.scaledToFill()
.frame(width: 60, height: 60, alignment: .top)

View File

@@ -138,6 +138,13 @@ struct LiveDetailView: View {
let manager = room.manager
KFImage(URL(string: manager.profileImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 60,
height: 60
)
)
.resizable()
.scaledToFill()
.frame(width: 60, height: 60, alignment: .top)
@@ -427,6 +434,13 @@ struct LiveDetailView: View {
ForEach(room.participatingUsers, id: \.self) { user in
VStack(spacing: 6.7) {
KFImage(URL(string: user.profileImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 46.7,
height: 46.7
)
)
.resizable()
.scaledToFill()
.frame(width: 46.7, height: 46.7, alignment: .top)
@@ -447,6 +461,13 @@ struct LiveDetailView: View {
ForEach(0..<userCount, id: \.self) { index in
let user = room.participatingUsers[index]
KFImage(URL(string: user.profileImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 33.3,
height: 33.3
)
)
.resizable()
.scaledToFill()
.frame(width: 33.3, height: 33.3, alignment: .top)

View File

@@ -84,6 +84,13 @@ struct LiveRoomInfoEditDialog: View {
.cornerRadius(10)
} else if let coverImageUrl = coverImageUrl {
KFImage(URL(string: coverImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 80,
height: 116.8
)
)
.resizable()
.scaledToFill()
.frame(width: 80, height: 116.8, alignment: .top)

View File

@@ -28,6 +28,13 @@ struct LiveRoomNoChattingDialogView: View {
HStack(spacing: 8) {
KFImage(URL(string: profileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 26.7,
height: 26.7
)
)
.resizable()
.frame(width: 26.7, height: 26.7)

View File

@@ -29,6 +29,13 @@ struct LiveRoomProfileDialog: View {
HStack(spacing: 13.3) {
KFImage(URL(string: profileInfo.profileImage))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 80,
height: 116.7
)
)
.resizable()
.frame(width: 80, height: 116.7, alignment: .top)
.clipped()

View File

@@ -49,6 +49,13 @@ struct LiveRoomProfileItemMasterView: View {
VStack(alignment: .leading, spacing: 20) {
HStack(spacing: 0) {
KFImage(URL(string: profileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 60,
height: 60
)
)
.resizable()
.frame(width: 60, height: 60)
.clipShape(Circle())
@@ -90,6 +97,13 @@ struct LiveRoomProfileItemUserView: View {
VStack(spacing: 10) {
HStack(spacing: 0) {
KFImage(URL(string: profileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 46.7,
height: 46.7
)
)
.resizable()
.frame(width: 46.7, height: 46.7)
.clipShape(Circle())

View File

@@ -21,6 +21,13 @@ struct LiveRoomTopCreatorView: View {
var body: some View {
HStack(spacing: 5.3) {
KFImage(URL(string: profileImageUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 33.3,
height: 33.3
)
)
.resizable()
.scaledToFill()
.frame(width: 33.3, height: 33.3)

View File

@@ -27,6 +27,13 @@ struct LiveRoomInfoCreatorView: View {
HStack(spacing: 5.3) {
ZStack(alignment: .center) {
KFImage(URL(string: creatorProfileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 33.3,
height: 33.3
)
)
.resizable()
.frame(width: 33.3, height: 33.3)
.clipShape(Circle())

View File

@@ -22,6 +22,13 @@ struct LiveRoomInfoSpeakerView: View {
VStack(spacing: 5) {
ZStack(alignment: .center) {
KFImage(URL(string: profileUrl))
.cancelOnDisappear(true)
.downsampling(
size: CGSize(
width: 25,
height: 25
)
)
.resizable()
.frame(width: 25, height: 25)
.clipShape(Circle())