콘텐츠 메인, 라이브 메인, 오디션 메인, 마이페이지

- 로그인 하지 않고 페이지 조회가 되도록 수정
This commit is contained in:
Yu Sung
2025-03-24 18:32:27 +09:00
parent fa94c5447f
commit 80cb19a1c7
32 changed files with 874 additions and 595 deletions

View File

@@ -12,6 +12,7 @@ struct SectionEventBannerView: View {
@State private var currentIndex = 0
@State private var timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect()
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
let items: [EventItem]
@@ -38,10 +39,14 @@ struct SectionEventBannerView: View {
)
.tag(index)
.onTapGesture {
if let _ = item.detailImageUrl {
AppState.shared.setAppStep(step: .eventDetail(event: item))
} else if let link = item.link, link.trimmingCharacters(in: .whitespaces).count > 0, let url = URL(string: link), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
if let _ = item.detailImageUrl {
AppState.shared.setAppStep(step: .eventDetail(event: item))
} else if let link = item.link, link.trimmingCharacters(in: .whitespaces).count > 0, let url = URL(string: link), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}
} else {
AppState.shared.setAppStep(step: .login)
}
}
} else {
@@ -62,10 +67,14 @@ struct SectionEventBannerView: View {
)
.tag(index)
.onTapGesture {
if let _ = item.detailImageUrl {
AppState.shared.setAppStep(step: .eventDetail(event: item))
} else if let link = item.link, link.trimmingCharacters(in: .whitespaces).count > 0, let url = URL(string: link), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
if let _ = item.detailImageUrl {
AppState.shared.setAppStep(step: .eventDetail(event: item))
} else if let link = item.link, link.trimmingCharacters(in: .whitespaces).count > 0, let url = URL(string: link), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}
} else {
AppState.shared.setAppStep(step: .login)
}
}
}

View File

@@ -12,6 +12,7 @@ struct LiveView: View {
@StateObject var viewModel = LiveViewModel()
@StateObject var appState = AppState.shared
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
var body: some View {
ZStack {
@@ -44,9 +45,13 @@ struct LiveView: View {
}
.padding(.horizontal, 13.3)
.onTapGesture {
AppState.shared.setAppStep(
step: .contentAllByTheme(themeId: 7)
)
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(
step: .contentAllByTheme(themeId: 7)
)
} else {
AppState.shared.setAppStep(step: .login)
}
}
if viewModel.recommendChannelItems.count > 0 {
@@ -61,10 +66,18 @@ struct LiveView: View {
SectionLiveNowView(
items: viewModel.liveNowItems,
onClickParticipant: {
viewModel.enterLiveRoom(roomId: $0)
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
viewModel.enterLiveRoom(roomId: $0)
} else {
AppState.shared.setAppStep(step: .login)
}
},
onTapCreateLive: {
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: onCreateSuccess))
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: onCreateSuccess))
} else {
AppState.shared.setAppStep(step: .login)
}
},
onClickRefresh: {
viewModel.getSummary()
@@ -82,12 +95,26 @@ struct LiveView: View {
SectionLiveReservationView(
items: viewModel.liveReservationItems,
onClickCancel: { viewModel.getSummary() },
onClickStart: { roomId in processStart(roomId: roomId) },
onClickStart: { roomId in
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
processStart(roomId: roomId)
} else {
AppState.shared.setAppStep(step: .login)
}
},
onClickReservation: { roomId in
viewModel.reservationLiveRoom(roomId: roomId)
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
viewModel.reservationLiveRoom(roomId: roomId)
} else {
AppState.shared.setAppStep(step: .login)
}
},
onTapCreateLive: {
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .RESERVATION, onSuccess: onCreateSuccess))
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .RESERVATION, onSuccess: onCreateSuccess))
} else {
AppState.shared.setAppStep(step: .login)
}
}
)
}
@@ -102,7 +129,11 @@ struct LiveView: View {
.padding(.trailing, 16)
.padding(.bottom, 16)
.onTapGesture {
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: onCreateSuccess))
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: onCreateSuccess))
} else {
AppState.shared.setAppStep(step: .login)
}
}
}
}

View File

@@ -84,10 +84,17 @@ final class LiveViewModel: ObservableObject {
}
func getSummary() {
getFollowedChannelList()
if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
getFollowedChannelList()
}
getRecommendChannelList()
getRecommendLive()
getLatestPostListFromCreatorsYouFollow()
if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
getLatestPostListFromCreatorsYouFollow()
}
isLoading = true
eventBannerItems.removeAll()

View File

@@ -15,6 +15,8 @@ struct SectionLiveNowView: View {
let onTapCreateLive: () -> Void
let onClickRefresh: () -> Void
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
var body: some View {
LazyVStack(spacing: 13.3) {
HStack(spacing: 0) {
@@ -45,20 +47,24 @@ struct SectionLiveNowView: View {
LiveNowItemView(item: item)
.contentShape(Rectangle())
.onTapGesture {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: item.roomId,
onClickParticipant: {
AppState.shared.isShowPlayer = false
onClickParticipant(item.roomId)
},
onClickReservation: {},
onClickStart: {
},
onClickCancel: {
}
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: item.roomId,
onClickParticipant: {
AppState.shared.isShowPlayer = false
onClickParticipant(item.roomId)
},
onClickReservation: {},
onClickStart: {
},
onClickCancel: {
}
)
)
)
} else {
AppState.shared.setAppStep(step: .login)
}
}
}
}

View File

@@ -13,6 +13,7 @@ struct SectionRecommendLiveView: View {
let items: [GetRecommendLiveResponse]
@State private var currentIndex = 0
@State private var timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect()
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
var body: some View {
VStack(spacing: 0) {
@@ -27,10 +28,12 @@ struct SectionRecommendLiveView: View {
Spacer()
Image("ic_message")
.onTapGesture {
AppState.shared.setAppStep(step: .message)
}
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
Image("ic_message")
.onTapGesture {
AppState.shared.setAppStep(step: .message)
}
}
}
.frame(width: screenSize().width - 26.7, alignment: .leading)
@@ -53,7 +56,11 @@ struct SectionRecommendLiveView: View {
height: (screenSize().width - 26.7) * 0.53
)
.onTapGesture {
AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId))
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId))
} else {
AppState.shared.setAppStep(step: .login)
}
}
.cornerRadius(4.7)
} else {
@@ -72,7 +79,11 @@ struct SectionRecommendLiveView: View {
height: (screenSize().width - 26.7) * 0.53
)
.onTapGesture {
AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId))
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId))
} else {
AppState.shared.setAppStep(step: .login)
}
}
.cornerRadius(4.7)
}

View File

@@ -13,6 +13,7 @@ struct SectionRecommendChannelView: View {
let items: [GetRecommendChannelResponse]
@Binding var isFollowingList: Bool
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
var body: some View {
VStack(spacing: 21.3) {
@@ -20,30 +21,32 @@ struct SectionRecommendChannelView: View {
if isFollowingList {
Text("팔로잉 ")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(.grayee)
} else {
Text("추천 ")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color(hex: "eeeeee"))
.foregroundColor(.grayee)
}
Text("채널")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color(hex: "3bb9f1"))
.foregroundColor(.button)
Spacer()
Text("팔로잉 채널")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "777777"))
Image(isFollowingList ? "btn_toggle_on_big" : "btn_toggle_off_big")
.resizable()
.frame(width: 33.3, height: 20)
.padding(.leading, 6.7)
.onTapGesture {
isFollowingList.toggle()
}
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
Text("팔로잉 채널")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(.gray77)
Image(isFollowingList ? "btn_toggle_on_big" : "btn_toggle_off_big")
.resizable()
.frame(width: 33.3, height: 20)
.padding(.leading, 6.7)
.onTapGesture {
isFollowingList.toggle()
}
}
}
.frame(width: screenSize().width - 26.7, alignment: .leading)
@@ -70,7 +73,7 @@ struct SectionRecommendChannelView: View {
Circle()
.strokeBorder(lineWidth: 3)
.foregroundColor(
Color(hex: "3bb9f1")
.button
.opacity(item.isOnAir ? 1 : 0)
)
)
@@ -81,21 +84,25 @@ struct SectionRecommendChannelView: View {
.foregroundColor(.white)
.padding(.vertical, 2.7)
.padding(.horizontal, 5.7)
.background(Color(hex: "3bb9f1"))
.background(Color.button)
.cornerRadius(6.7)
}
}
Text(item.nickname)
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color(hex: "bbbbbb"))
.foregroundColor(Color.graybb)
.frame(width: screenSize().width * 0.18)
.lineLimit(1)
}
.onTapGesture {
AppState.shared.setAppStep(
step: .creatorDetail(userId: item.creatorId)
)
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(
step: .creatorDetail(userId: item.creatorId)
)
} else {
AppState.shared.setAppStep(step: .login)
}
}
}
@@ -112,10 +119,15 @@ struct SectionRecommendChannelView: View {
.lineLimit(1)
}
.onTapGesture {
AppState.shared.setAppStep(step: .followingList)
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .followingList)
} else {
AppState.shared.setAppStep(step: .login)
}
}
}
}
.padding(.horizontal, 13.3)
}
}
}

View File

@@ -15,6 +15,7 @@ struct SectionLiveReservationView: View {
let onClickStart: (Int) -> Void
let onClickReservation: (Int) -> Void
let onTapCreateLive: () -> Void
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
var body: some View {
VStack(spacing: 13.3) {
@@ -34,14 +35,18 @@ struct SectionLiveReservationView: View {
.font(.custom(Font.light.rawValue, size: 11.3))
.foregroundColor(Color(hex: "bbbbbb"))
.onTapGesture {
AppState.shared.setAppStep(
step: .liveReservationAll(
onClickReservation: onClickReservation,
onClickStart: onClickStart,
onClickCancel: onClickCancel,
onTapCreateLive: onTapCreateLive
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(
step: .liveReservationAll(
onClickReservation: onClickReservation,
onClickStart: onClickStart,
onClickCancel: onClickCancel,
onTapCreateLive: onTapCreateLive
)
)
)
} else {
AppState.shared.setAppStep(step: .login)
}
}
}
}
@@ -57,29 +62,37 @@ struct SectionLiveReservationView: View {
MyLiveReservationItemView(item: item, index: index)
.contentShape(Rectangle())
.onTapGesture {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: item.roomId,
onClickParticipant: {},
onClickReservation: {},
onClickStart: { onClickStart(item.roomId) },
onClickCancel: onClickCancel
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: item.roomId,
onClickParticipant: {},
onClickReservation: {},
onClickStart: { onClickStart(item.roomId) },
onClickCancel: onClickCancel
)
)
)
} else {
AppState.shared.setAppStep(step: .login)
}
}
} else {
LiveReservationItemView(item: item)
.contentShape(Rectangle())
.onTapGesture {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: item.roomId,
onClickParticipant: {},
onClickReservation: { onClickReservation(item.roomId) },
onClickStart: { onClickStart(item.roomId) },
onClickCancel: onClickCancel
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: item.roomId,
onClickParticipant: {},
onClickReservation: { onClickReservation(item.roomId) },
onClickStart: { onClickStart(item.roomId) },
onClickCancel: onClickCancel
)
)
)
} else {
AppState.shared.setAppStep(step: .login)
}
}
}
}