From 41d5bad46ff7b8e091218d90e3604e1517ffc053 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Sat, 14 Oct 2023 18:34:10 +0900 Subject: [PATCH] =?UTF-8?q?=ED=83=90=EC=83=89=20-=20=ED=81=AC=EB=A6=AC?= =?UTF-8?q?=EC=97=90=EC=9D=B4=ED=84=B0=20=EB=9E=AD=ED=82=B9=20UI=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Detail/ContentDetailView.swift | 1 - .../Content/Main/ContentMainView.swift | 1 - .../Explorer/ExplorerSectionView.swift | 137 ++++++++++++++++++ SodaLive/Sources/Explorer/ExplorerView.swift | 64 +------- .../Explorer/GetExplorerResponse.swift | 1 + SodaLive/Sources/Live/Room/LiveRoomView.swift | 1 - 6 files changed, 139 insertions(+), 66 deletions(-) create mode 100644 SodaLive/Sources/Explorer/ExplorerSectionView.swift diff --git a/SodaLive/Sources/Content/Detail/ContentDetailView.swift b/SodaLive/Sources/Content/Detail/ContentDetailView.swift index 092ccc4..dd3b05b 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailView.swift @@ -7,7 +7,6 @@ import SwiftUI import Kingfisher -import GoogleMobileAds import RefreshableScrollView struct ContentDetailView: View { diff --git a/SodaLive/Sources/Content/Main/ContentMainView.swift b/SodaLive/Sources/Content/Main/ContentMainView.swift index 6b924f9..44f05f3 100644 --- a/SodaLive/Sources/Content/Main/ContentMainView.swift +++ b/SodaLive/Sources/Content/Main/ContentMainView.swift @@ -6,7 +6,6 @@ // import SwiftUI -import GoogleMobileAds import RefreshableScrollView struct ContentMainView: View { diff --git a/SodaLive/Sources/Explorer/ExplorerSectionView.swift b/SodaLive/Sources/Explorer/ExplorerSectionView.swift new file mode 100644 index 0000000..8899031 --- /dev/null +++ b/SodaLive/Sources/Explorer/ExplorerSectionView.swift @@ -0,0 +1,137 @@ +// +// ExplorerSectionView.swift +// SodaLive +// +// Created by klaus on 2023/10/14. +// + +import SwiftUI +import Kingfisher + +struct ExplorerSectionView: View { + + let section: GetExplorerSectionResponse + let rankingCrawns = ["ic_crown_1", "ic_crown_2", "ic_crown_3"] + let rankingColors = [ + [Color(hex: "ffdc00"), Color(hex: "ffb600")], + [Color(hex: "ffffff"), Color(hex: "9f9f9f")], + [Color(hex: "e6a77a"), Color(hex: "c67e4a")], + [Color(hex: "ffffff").opacity(0), Color(hex: "ffffff").opacity(0)] + ] + + var body: some View { + VStack(alignment: .leading, spacing: 13.3) { + VStack(alignment: .leading, spacing: 4) { + if let coloredTitle = section.coloredTitle, let color = section.color { + let titleArray = section.title.components(separatedBy: coloredTitle) + HStack(spacing: 0) { + Text(titleArray[0]) + .font(.custom(Font.bold.rawValue, size: 18.3)) + .foregroundColor(Color(hex: "eeeeee")) + + Text(coloredTitle) + .font(.custom(Font.bold.rawValue, size: 18.3)) + .foregroundColor(Color(hex: color)) + + if titleArray.count > 1 { + Text(titleArray[1]) + .font(.custom(Font.bold.rawValue, size: 18.3)) + .foregroundColor(Color(hex: "eeeeee")) + } + } + } else { + Text(section.title) + .font(.custom(Font.bold.rawValue, size: 18.3)) + .foregroundColor(Color(hex: "eeeeee")) + } + + if let desc = section.desc { + Text(desc) + .font(.custom(Font.medium.rawValue, size: 11)) + .foregroundColor(Color(hex: "777777")) + } + } + .frame(width: screenSize().width - 26.7, alignment: .leading) + + ScrollView(.horizontal, showsIndicators: false) { + HStack(spacing: 13.3) { + ForEach(0.. 1 { - Text(titleArray[1]) - .font(.custom(Font.bold.rawValue, size: 18.3)) - .foregroundColor(Color(hex: "eeeeee")) - } - } - .frame(width: screenSize().width - 26.7, alignment: .leading) - } else { - Text(section.title) - .font(.custom(Font.bold.rawValue, size: 18.3)) - .foregroundColor(Color(hex: "eeeeee")) - .frame(width: screenSize().width - 26.7, alignment: .leading) - } - - ScrollView(.horizontal, showsIndicators: false) { - HStack(spacing: 13.3) { - ForEach(section.creators, id: \.self) { creator in - VStack(spacing: 0) { - KFImage(URL(string: creator.profileImageUrl)) - .cancelOnDisappear(true) - .downsampling(size: CGSize(width: 93.3, height: 93.3)) - .resizable() - .frame(width: 93.3, height: 93.3) - .clipShape(Circle()) - - Text(creator.nickname) - .font(.custom(Font.medium.rawValue, size: 11.3)) - .foregroundColor(Color(hex: "eeeeee")) - .lineLimit(1) - .frame(width: 93.3) - .padding(.top, 13.3) - - Text(creator.tags) - .font(.custom(Font.medium.rawValue, size: 10)) - .foregroundColor(Color(hex: "9970ff")) - .lineLimit(1) - .frame(width: 93.3) - .padding(.top, 3.3) - } - .contentShape(Rectangle()) - .onTapGesture { - AppState.shared - .setAppStep(step: .creatorDetail(userId: creator.id)) - } - } - } - } - .frame(width: screenSize().width - 26.7, alignment: .leading) - } + ExplorerSectionView(section: viewModel.explorerSections[index]) } } .padding(.vertical, 40) diff --git a/SodaLive/Sources/Explorer/GetExplorerResponse.swift b/SodaLive/Sources/Explorer/GetExplorerResponse.swift index 9d8ae6c..f6f9cd8 100644 --- a/SodaLive/Sources/Explorer/GetExplorerResponse.swift +++ b/SodaLive/Sources/Explorer/GetExplorerResponse.swift @@ -15,6 +15,7 @@ struct GetExplorerSectionResponse: Decodable, Hashable { let title: String let coloredTitle: String? let color: String? + let desc: String? let creators: [GetExplorerSectionCreatorResponse] } diff --git a/SodaLive/Sources/Live/Room/LiveRoomView.swift b/SodaLive/Sources/Live/Room/LiveRoomView.swift index 0d24d6a..f827154 100644 --- a/SodaLive/Sources/Live/Room/LiveRoomView.swift +++ b/SodaLive/Sources/Live/Room/LiveRoomView.swift @@ -8,7 +8,6 @@ import SwiftUI import Kingfisher import PopupView -import GoogleMobileAds struct LiveRoomView: View { @State private var isShowingNewChat = false