feat(main): 메인 탭 화면을 추가한다
21
SodaLive/Resources/Assets.xcassets/ic_nav_chat.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_nav_chat.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/ic_nav_chat.imageset/ic_nav_chat.png
vendored
Normal file
|
After Width: | Height: | Size: 602 B |
21
SodaLive/Resources/Assets.xcassets/ic_nav_chat_selected.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_nav_chat_selected.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/ic_nav_chat_selected.imageset/ic_nav_chat_selected.png
vendored
Normal file
|
After Width: | Height: | Size: 446 B |
21
SodaLive/Resources/Assets.xcassets/ic_nav_content.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_nav_content.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/ic_nav_content.imageset/ic_nav_content.png
vendored
Normal file
|
After Width: | Height: | Size: 537 B |
21
SodaLive/Resources/Assets.xcassets/ic_nav_content_selected.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_nav_content_selected.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/ic_nav_content_selected.imageset/ic_nav_content_selected.png
vendored
Normal file
|
After Width: | Height: | Size: 378 B |
21
SodaLive/Resources/Assets.xcassets/ic_nav_home.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_nav_home.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/ic_nav_home.imageset/ic_nav_home.png
vendored
Normal file
|
After Width: | Height: | Size: 564 B |
21
SodaLive/Resources/Assets.xcassets/ic_nav_home_selected.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_nav_home_selected.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/ic_nav_home_selected.imageset/ic_nav_home_selected.png
vendored
Normal file
|
After Width: | Height: | Size: 408 B |
21
SodaLive/Resources/Assets.xcassets/ic_nav_my.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_nav_my.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/ic_nav_my.imageset/ic_nav_my.png
vendored
Normal file
|
After Width: | Height: | Size: 723 B |
6
SodaLive/Resources/Assets.xcassets/v2/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ struct ContentView: View {
|
||||
if appState.isRestartApp {
|
||||
EmptyView()
|
||||
} else {
|
||||
HomeView()
|
||||
MainView()
|
||||
}
|
||||
|
||||
if case .splash = appState.rootStep {
|
||||
|
||||
@@ -2983,6 +2983,7 @@ If you block this user, the following features will be restricted.
|
||||
|
||||
enum Tab {
|
||||
static var home: String { pick(ko: "홈", en: "Home", ja: "ホーム") }
|
||||
static var content: String { pick(ko: "콘텐츠", en: "Content", ja: "コンテンツ") }
|
||||
static var live: String { pick(ko: "라이브", en: "Live", ja: "ライブ") }
|
||||
static var chat: String { pick(ko: "채팅", en: "Chat", ja: "チャット") }
|
||||
static var my: String { pick(ko: "마이", en: "My", ja: "マイ") }
|
||||
|
||||
@@ -56,7 +56,7 @@ struct EventPopupDialogView: View {
|
||||
.padding(.horizontal, 26.7)
|
||||
.padding(.bottom, 13.3)
|
||||
}
|
||||
.background(Color(hex: "222222"))
|
||||
.background(Color.black)
|
||||
.cornerRadius(16.7, corners: [.topLeft, .topRight])
|
||||
}
|
||||
}
|
||||
|
||||
27
SodaLive/Sources/V2/Main/MainPlaceholderTabView.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// MainPlaceholderTabView.swift
|
||||
// SodaLive
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MainPlaceholderTabView: View {
|
||||
let title: String
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color.black
|
||||
.ignoresSafeArea()
|
||||
|
||||
Text(title)
|
||||
.appFont(size: 20, weight: .bold)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MainPlaceholderTabView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainPlaceholderTabView(title: "홈")
|
||||
}
|
||||
}
|
||||
52
SodaLive/Sources/V2/Main/MainTab.swift
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// MainTab.swift
|
||||
// SodaLive
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum MainTab: CaseIterable, Hashable {
|
||||
case home
|
||||
case content
|
||||
case chat
|
||||
case my
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .home:
|
||||
return I18n.Main.Tab.home
|
||||
case .content:
|
||||
return I18n.Main.Tab.content
|
||||
case .chat:
|
||||
return I18n.Main.Tab.chat
|
||||
case .my:
|
||||
return I18n.Main.Tab.my
|
||||
}
|
||||
}
|
||||
|
||||
var selectedIconName: String {
|
||||
switch self {
|
||||
case .home:
|
||||
return "ic_nav_home_selected"
|
||||
case .content:
|
||||
return "ic_nav_content_selected"
|
||||
case .chat:
|
||||
return "ic_nav_chat_selected"
|
||||
case .my:
|
||||
return "ic_tabbar_my_selected"
|
||||
}
|
||||
}
|
||||
|
||||
var unselectedIconName: String {
|
||||
switch self {
|
||||
case .home:
|
||||
return "ic_nav_home"
|
||||
case .content:
|
||||
return "ic_nav_content"
|
||||
case .chat:
|
||||
return "ic_nav_chat"
|
||||
case .my:
|
||||
return "ic_nav_my"
|
||||
}
|
||||
}
|
||||
}
|
||||
45
SodaLive/Sources/V2/Main/MainTabBarButton.swift
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// MainTabBarButton.swift
|
||||
// SodaLive
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MainTabBarButton: View {
|
||||
let tab: MainTab
|
||||
let isSelected: Bool
|
||||
let width: CGFloat
|
||||
let action: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
VStack(spacing: 4) {
|
||||
ZStack(alignment: .center) {
|
||||
Image(isSelected ? tab.selectedIconName : tab.unselectedIconName)
|
||||
}
|
||||
.frame(height: 24)
|
||||
|
||||
Text(tab.title)
|
||||
.appFont(.caption3)
|
||||
.foregroundColor(isSelected ? Color.white : Color.gray600)
|
||||
.frame(height: 12, alignment: .bottom)
|
||||
}
|
||||
.frame(width: width, alignment: .center)
|
||||
.frame(minHeight: 50)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
|
||||
struct MainTabBarButton_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainTabBarButton(
|
||||
tab: .home,
|
||||
isSelected: true,
|
||||
width: UIScreen.main.bounds.width / 4,
|
||||
action: {}
|
||||
)
|
||||
.background(Color.black)
|
||||
}
|
||||
}
|
||||
40
SodaLive/Sources/V2/Main/MainTabBarView.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// MainTabBarView.swift
|
||||
// SodaLive
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MainTabBarView: View {
|
||||
let width: CGFloat
|
||||
@Binding var currentTab: MainTab
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
let tabWidth = width / CGFloat(MainTab.allCases.count)
|
||||
|
||||
ForEach(MainTab.allCases, id: \.self) { tab in
|
||||
MainTabBarButton(
|
||||
tab: tab,
|
||||
isSelected: currentTab == tab,
|
||||
width: tabWidth,
|
||||
action: {
|
||||
currentTab = tab
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
.padding(.top, 8)
|
||||
.padding(.bottom, 8)
|
||||
.background(Color.black.ignoresSafeArea(edges: .bottom))
|
||||
}
|
||||
}
|
||||
|
||||
struct MainTabBarView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainTabBarView(
|
||||
width: UIScreen.main.bounds.width,
|
||||
currentTab: .constant(.home)
|
||||
)
|
||||
}
|
||||
}
|
||||
447
SodaLive/Sources/V2/Main/MainView.swift
Normal file
@@ -0,0 +1,447 @@
|
||||
//
|
||||
// MainView.swift
|
||||
// SodaLive
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
import Bootpay
|
||||
import BootpayUI
|
||||
import Kingfisher
|
||||
|
||||
struct MainView: View {
|
||||
@StateObject private var viewModel = MainViewModel()
|
||||
@StateObject private var legacyHomeViewModel = HomeViewModel()
|
||||
@StateObject private var liveViewModel = LiveViewModel()
|
||||
@StateObject private var mypageViewModel = MyPageViewModel()
|
||||
@StateObject private var appState = AppState.shared
|
||||
@StateObject private var contentPlayManager = ContentPlayManager.shared
|
||||
@StateObject private var contentPlayerPlayManager = ContentPlayerPlayManager.shared
|
||||
|
||||
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
|
||||
@AppStorage("auth") private var auth: Bool = UserDefaults.bool(forKey: UserDefaultsKey.auth)
|
||||
|
||||
@State private var isShowPlayer = false
|
||||
@State private var isShowAuthView = false
|
||||
@State private var isShowAuthConfirmView = false
|
||||
@State private var pendingAction: (() -> Void)? = nil
|
||||
@State private var isShowLeaveLiveNavigationDialog = false
|
||||
@State private var pendingExternalNavigationAction: (() -> Void)? = nil
|
||||
@State private var pendingExternalNavigationCancelAction: (() -> Void)? = nil
|
||||
@State private var payload = Payload()
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
ZStack(alignment: .bottom) {
|
||||
VStack(spacing: 0) {
|
||||
contentView
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.padding(.bottom, appState.isShowPlayer ? 72 : 0)
|
||||
|
||||
if contentPlayerPlayManager.isShowingMiniPlayer {
|
||||
contentPlayerMiniPlayerView
|
||||
}
|
||||
|
||||
if contentPlayManager.isShowingMiniPlayer {
|
||||
previewContentMiniPlayerView
|
||||
}
|
||||
}
|
||||
.safeAreaInset(edge: .bottom, spacing: 0) {
|
||||
MainTabBarView(
|
||||
width: proxy.size.width,
|
||||
currentTab: $viewModel.currentTab
|
||||
)
|
||||
}
|
||||
.onAppear {
|
||||
configurePayload()
|
||||
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
pushTokenUpdate()
|
||||
legacyHomeViewModel.getMemberInfo()
|
||||
legacyHomeViewModel.getEventPopup()
|
||||
legacyHomeViewModel.addAllPlaybackTracking()
|
||||
}
|
||||
}
|
||||
|
||||
if appState.isShowNotificationSettingsDialog {
|
||||
NotificationSettingsDialog()
|
||||
}
|
||||
|
||||
if isShowAuthConfirmView {
|
||||
authConfirmDialog
|
||||
}
|
||||
|
||||
if liveViewModel.isShowPaymentDialog {
|
||||
LivePaymentDialog(
|
||||
title: liveViewModel.paymentDialogTitle,
|
||||
desc: liveViewModel.paymentDialogDesc,
|
||||
desc2: liveViewModel.paymentDialogDesc2,
|
||||
confirmButtonTitle: liveViewModel.paymentDialogConfirmTitle,
|
||||
confirmButtonAction: liveViewModel.paymentDialogConfirmAction,
|
||||
cancelButtonTitle: liveViewModel.paymentDialogCancelTitle,
|
||||
cancelButtonAction: liveViewModel.hidePopup,
|
||||
startDateTime: liveViewModel.liveStartDate,
|
||||
nowDateTime: liveViewModel.nowDate
|
||||
)
|
||||
}
|
||||
|
||||
if liveViewModel.isShowPasswordDialog {
|
||||
LiveRoomPasswordDialog(
|
||||
isShowing: $liveViewModel.isShowPasswordDialog,
|
||||
can: liveViewModel.secretOrPasswordDialogCan,
|
||||
confirmAction: liveViewModel.passwordDialogConfirmAction
|
||||
)
|
||||
}
|
||||
|
||||
if let eventItem = appState.eventPopup {
|
||||
VStack(spacing: 0) {
|
||||
Spacer()
|
||||
EventPopupDialogView(eventPopup: eventItem)
|
||||
}
|
||||
.background(Color.black)
|
||||
.onTapGesture {
|
||||
appState.eventPopup = nil
|
||||
}
|
||||
}
|
||||
|
||||
if isShowPlayer {
|
||||
ContentPlayerView(isShowing: $isShowPlayer, playlist: [])
|
||||
}
|
||||
|
||||
if appState.isShowPlayer {
|
||||
LiveRoomViewV2()
|
||||
}
|
||||
|
||||
if isShowLeaveLiveNavigationDialog {
|
||||
leaveLiveNavigationDialog
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $isShowAuthView) {
|
||||
authView
|
||||
}
|
||||
.valueChanged(value: appState.pushRoomId) { handlePushRoomId($0) }
|
||||
.valueChanged(value: appState.pushChannelId) { handlePushChannelId($0) }
|
||||
.valueChanged(value: appState.pushMessageId) { handlePushMessageId($0) }
|
||||
.valueChanged(value: appState.pushAudioContentId) { handlePushAudioContentId($0) }
|
||||
.valueChanged(value: appState.pushSeriesId) { handlePushSeriesId($0) }
|
||||
.valueChanged(value: appState.isShowPlayer) { isShowPlayer in
|
||||
guard !isShowPlayer,
|
||||
let pendingExternalNavigationAction = pendingExternalNavigationAction else {
|
||||
return
|
||||
}
|
||||
self.pendingExternalNavigationAction = nil
|
||||
self.pendingExternalNavigationCancelAction = nil
|
||||
DispatchQueue.main.async {
|
||||
pendingExternalNavigationAction()
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if appState.pushMessageId > 0 {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
appState.setAppStep(step: .message)
|
||||
}
|
||||
}
|
||||
}
|
||||
.sodaToast(
|
||||
isPresented: $liveViewModel.isShowPopup,
|
||||
message: liveViewModel.errorMessage,
|
||||
autohideIn: 2
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var contentView: some View {
|
||||
switch viewModel.currentTab {
|
||||
case .home:
|
||||
MainPlaceholderTabView(title: MainTab.home.title)
|
||||
case .content:
|
||||
MainPlaceholderTabView(title: MainTab.content.title)
|
||||
case .chat:
|
||||
MainPlaceholderTabView(title: MainTab.chat.title)
|
||||
case .my:
|
||||
MyPageView()
|
||||
}
|
||||
}
|
||||
|
||||
private var contentPlayerMiniPlayerView: some View {
|
||||
HStack(spacing: 0) {
|
||||
KFImage(URL(string: contentPlayerPlayManager.coverImageUrl))
|
||||
.cancelOnDisappear(true)
|
||||
.downsampling(size: CGSize(width: 36.7, height: 36.7))
|
||||
.resizable()
|
||||
.frame(width: 36.7, height: 36.7)
|
||||
.cornerRadius(5.3)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2.3) {
|
||||
Text(contentPlayerPlayManager.title)
|
||||
.appFont(size: 13, weight: .medium)
|
||||
.foregroundColor(Color.grayee)
|
||||
.lineLimit(2)
|
||||
|
||||
Text(contentPlayerPlayManager.nickname)
|
||||
.appFont(size: 11, weight: .medium)
|
||||
.foregroundColor(Color.grayd2)
|
||||
}
|
||||
.padding(.horizontal, 10.7)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(contentPlayerPlayManager.isPlaying ? "ic_noti_pause" : "btn_bar_play")
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.onTapGesture { contentPlayerPlayManager.playOrPause() }
|
||||
|
||||
Image("ic_noti_stop")
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.padding(.leading, 16)
|
||||
.onTapGesture { contentPlayerPlayManager.resetPlayer() }
|
||||
}
|
||||
.padding(.vertical, 10.7)
|
||||
.padding(.horizontal, 13.3)
|
||||
.background(Color.gray22)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { isShowPlayer = true }
|
||||
}
|
||||
|
||||
private var previewContentMiniPlayerView: some View {
|
||||
HStack(spacing: 0) {
|
||||
KFImage(URL(string: contentPlayManager.coverImage))
|
||||
.cancelOnDisappear(true)
|
||||
.downsampling(size: CGSize(width: 36.7, height: 36.7))
|
||||
.resizable()
|
||||
.frame(width: 36.7, height: 36.7)
|
||||
.cornerRadius(5.3)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2.3) {
|
||||
Text(contentPlayManager.title)
|
||||
.appFont(size: 13, weight: .medium)
|
||||
.foregroundColor(Color.grayee)
|
||||
.lineLimit(2)
|
||||
|
||||
Text(contentPlayManager.nickname)
|
||||
.appFont(size: 11, weight: .medium)
|
||||
.foregroundColor(Color.grayd2)
|
||||
}
|
||||
.padding(.horizontal, 10.7)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(contentPlayManager.isPlaying ? "ic_noti_pause" : "btn_bar_play")
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.onTapGesture {
|
||||
if contentPlayManager.isPlaying {
|
||||
contentPlayManager.pauseAudio()
|
||||
} else {
|
||||
contentPlayManager.playAudio(contentId: contentPlayManager.contentId)
|
||||
}
|
||||
}
|
||||
|
||||
Image("ic_noti_stop")
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.padding(.leading, 16)
|
||||
.onTapGesture { contentPlayManager.stopAudio() }
|
||||
}
|
||||
.padding(.vertical, 10.7)
|
||||
.padding(.horizontal, 13.3)
|
||||
.background(Color.gray22)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
appState.setAppStep(step: .contentDetail(contentId: contentPlayManager.contentId))
|
||||
}
|
||||
}
|
||||
|
||||
private var authConfirmDialog: some View {
|
||||
SodaDialog(
|
||||
title: I18n.Main.Auth.dialogTitle,
|
||||
desc: I18n.Main.Auth.liveEntryVerificationDescription,
|
||||
confirmButtonTitle: I18n.Main.Auth.goToVerification,
|
||||
confirmButtonAction: {
|
||||
isShowAuthConfirmView = false
|
||||
isShowAuthView = true
|
||||
},
|
||||
cancelButtonTitle: I18n.Common.cancel,
|
||||
cancelButtonAction: {
|
||||
isShowAuthConfirmView = false
|
||||
pendingAction = nil
|
||||
},
|
||||
textAlignment: .center
|
||||
)
|
||||
}
|
||||
|
||||
private var leaveLiveNavigationDialog: some View {
|
||||
SodaDialog(
|
||||
title: I18n.Common.alertTitle,
|
||||
desc: I18n.LiveRoom.leaveLiveForNavigationDesc,
|
||||
confirmButtonTitle: I18n.Common.confirm,
|
||||
confirmButtonAction: { confirmExternalNavigation() },
|
||||
cancelButtonTitle: I18n.Common.cancel,
|
||||
cancelButtonAction: { cancelExternalNavigation() }
|
||||
)
|
||||
}
|
||||
|
||||
private var authView: some View {
|
||||
BootpayUI(payload: payload, requestType: BootpayRequest.TYPE_AUTHENTICATION)
|
||||
.onConfirm { _ in true }
|
||||
.onCancel { _ in isShowAuthView = false }
|
||||
.onError { _ in
|
||||
appState.errorMessage = I18n.Main.Auth.authenticationError
|
||||
appState.isShowErrorPopup = true
|
||||
isShowAuthView = false
|
||||
}
|
||||
.onDone {
|
||||
DEBUG_LOG("onDone: \($0)")
|
||||
mypageViewModel.authVerify($0) {
|
||||
auth = true
|
||||
isShowAuthView = false
|
||||
if let action = pendingAction {
|
||||
pendingAction = nil
|
||||
action()
|
||||
}
|
||||
}
|
||||
}
|
||||
.onClose { isShowAuthView = false }
|
||||
}
|
||||
|
||||
private func configurePayload() {
|
||||
payload.applicationId = BOOTPAY_APP_ID
|
||||
payload.price = 0
|
||||
payload.pg = "다날"
|
||||
payload.method = "본인인증"
|
||||
payload.orderName = "본인인증"
|
||||
payload.authenticationId = "\(UserDefaults.string(forKey: .nickname))__\(String(NSTimeIntervalSince1970))"
|
||||
}
|
||||
|
||||
private func handlePushRoomId(_ value: Int) {
|
||||
guard value > 0 else { return }
|
||||
let roomId = value
|
||||
let isPushRoomFromDeepLink = appState.isPushRoomFromDeepLink
|
||||
appState.pushRoomId = 0
|
||||
appState.isPushRoomFromDeepLink = false
|
||||
DispatchQueue.main.async {
|
||||
handleExternalNavigationRequest(
|
||||
value: roomId,
|
||||
navigationAction: {
|
||||
if !isPushRoomFromDeepLink { appState.setAppStep(step: .main) }
|
||||
liveViewModel.enterLiveRoom(roomId: roomId)
|
||||
},
|
||||
cancelAction: {
|
||||
appState.pushRoomId = 0
|
||||
appState.isPushRoomFromDeepLink = false
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func handlePushChannelId(_ value: Int) {
|
||||
guard value > 0 else { return }
|
||||
let channelId = value
|
||||
appState.pushChannelId = 0
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
handleExternalNavigationRequest(
|
||||
value: channelId,
|
||||
navigationAction: {
|
||||
appState.setAppStep(step: .main)
|
||||
appState.setAppStep(step: .creatorDetail(userId: channelId))
|
||||
},
|
||||
cancelAction: { appState.pushChannelId = 0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func handlePushMessageId(_ value: Int) {
|
||||
guard value > 0 else { return }
|
||||
let messageId = value
|
||||
appState.pushMessageId = 0
|
||||
DispatchQueue.main.async {
|
||||
handleExternalNavigationRequest(
|
||||
value: messageId,
|
||||
navigationAction: {
|
||||
appState.setAppStep(step: .main)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
appState.setAppStep(step: .message)
|
||||
}
|
||||
},
|
||||
cancelAction: { appState.pushMessageId = 0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func handlePushAudioContentId(_ value: Int) {
|
||||
guard value > 0 else { return }
|
||||
let contentId = value
|
||||
appState.pushAudioContentId = 0
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
handleExternalNavigationRequest(
|
||||
value: contentId,
|
||||
navigationAction: {
|
||||
appState.setAppStep(step: .main)
|
||||
appState.setAppStep(step: .contentDetail(contentId: contentId))
|
||||
},
|
||||
cancelAction: { appState.pushAudioContentId = 0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func handlePushSeriesId(_ value: Int) {
|
||||
guard value > 0 else { return }
|
||||
let seriesId = value
|
||||
appState.pushSeriesId = 0
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
handleExternalNavigationRequest(
|
||||
value: seriesId,
|
||||
navigationAction: {
|
||||
appState.setAppStep(step: .main)
|
||||
appState.setAppStep(step: .seriesDetail(seriesId: seriesId))
|
||||
},
|
||||
cancelAction: { appState.pushSeriesId = 0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func handleExternalNavigationRequest(
|
||||
value: Int,
|
||||
navigationAction: @escaping () -> Void,
|
||||
cancelAction: @escaping () -> Void
|
||||
) {
|
||||
guard value > 0 else { return }
|
||||
if appState.isShowPlayer {
|
||||
pendingExternalNavigationAction = navigationAction
|
||||
pendingExternalNavigationCancelAction = cancelAction
|
||||
isShowLeaveLiveNavigationDialog = true
|
||||
return
|
||||
}
|
||||
navigationAction()
|
||||
}
|
||||
|
||||
private func confirmExternalNavigation() {
|
||||
guard pendingExternalNavigationAction != nil else {
|
||||
isShowLeaveLiveNavigationDialog = false
|
||||
return
|
||||
}
|
||||
isShowLeaveLiveNavigationDialog = false
|
||||
NotificationCenter.default.post(name: .requestLiveRoomQuitForExternalNavigation, object: nil)
|
||||
}
|
||||
|
||||
private func cancelExternalNavigation() {
|
||||
isShowLeaveLiveNavigationDialog = false
|
||||
pendingExternalNavigationAction = nil
|
||||
pendingExternalNavigationCancelAction?()
|
||||
pendingExternalNavigationCancelAction = nil
|
||||
}
|
||||
|
||||
private func pushTokenUpdate() {
|
||||
let pushToken = UserDefaults.string(forKey: .pushToken)
|
||||
if !pushToken.trimmingCharacters(in: .whitespaces).isEmpty {
|
||||
legacyHomeViewModel.pushTokenUpdate(pushToken: pushToken)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MainView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainView()
|
||||
}
|
||||
}
|
||||
11
SodaLive/Sources/V2/Main/MainViewModel.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// MainViewModel.swift
|
||||
// SodaLive
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
final class MainViewModel: ObservableObject {
|
||||
@Published var currentTab: MainTab = .home
|
||||
}
|
||||