스플래시 2024/09

This commit is contained in:
Yu Sung 2024-08-27 00:06:10 +09:00
parent 534a6e737e
commit f5445a3c48
8 changed files with 113 additions and 54 deletions

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "splash_bg.jpg",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "splash_text.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "splash_title.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

View File

@ -8,10 +8,7 @@
import SwiftUI import SwiftUI
import FirebaseRemoteConfig import FirebaseRemoteConfig
import AVKit
struct SplashView: View { struct SplashView: View {
@State private var player: AVPlayer?
@State private var isShowForcedUpdatePopup = false @State private var isShowForcedUpdatePopup = false
@State private var isShowUpdatePopup = false @State private var isShowUpdatePopup = false
@ -19,22 +16,19 @@ struct SplashView: View {
var body: some View { var body: some View {
ZStack(alignment: .top) { ZStack(alignment: .top) {
VStack { Image("splash_bg")
if let player = player { .resizable()
VideoPlayer(player: player) .scaledToFill()
.ignoresSafeArea(.all) .edgesIgnoringSafeArea(.all)
.onAppear {
player.play() VStack(spacing: 0) {
} Image("splash_title")
.onDisappear { .padding(.top, 60)
player.pause()
} Spacer()
} else {
Color(hex: "#ecedf3") Image("splash_text")
} .padding(.bottom, 36)
}
.onAppear {
loadVideo()
} }
if isShowUpdatePopup { if isShowUpdatePopup {
@ -65,19 +59,9 @@ struct SplashView: View {
) )
} }
} }
} .onAppear {
private func loadVideo() {
guard let url = Bundle.main.url(forResource: "video", withExtension: "mp4") else {
fetchLastestVersion() fetchLastestVersion()
return
} }
player = AVPlayer(url: url)
NotificationCenter.default
.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: player?.currentItem, queue: .main) { _ in
fetchLastestVersion()
}
} }
private func fetchLastestVersion() { private func fetchLastestVersion() {
@ -92,14 +76,18 @@ struct SplashView: View {
checkAppVersion(latestVersion: remoteConfig["ios_latest_version"].stringValue) checkAppVersion(latestVersion: remoteConfig["ios_latest_version"].stringValue)
} }
} else { } else {
if AppState.shared.pushRoomId > 0 { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) withAnimation {
} else if AppState.shared.pushChannelId > 0 { if AppState.shared.pushRoomId > 0 {
AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId)
} else if AppState.shared.pushAudioContentId > 0 { } else if AppState.shared.pushChannelId > 0 {
AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId))
} else { } else if AppState.shared.pushAudioContentId > 0 {
AppState.shared.setAppStep(step: .main) AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId))
} else {
AppState.shared.setAppStep(step: .main)
}
}
} }
} }
} }
@ -125,25 +113,33 @@ struct SplashView: View {
} else if latestMajor == major && latestMinor == minor && latestPatch > patch { } else if latestMajor == major && latestMinor == minor && latestPatch > patch {
self.isShowUpdatePopup = true self.isShowUpdatePopup = true
} else { } else {
if AppState.shared.pushRoomId > 0 { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) withAnimation {
} else if AppState.shared.pushChannelId > 0 { if AppState.shared.pushRoomId > 0 {
AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId)
} else if AppState.shared.pushAudioContentId > 0 { } else if AppState.shared.pushChannelId > 0 {
AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId))
} else { } else if AppState.shared.pushAudioContentId > 0 {
AppState.shared.setAppStep(step: .main) AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId))
} else {
AppState.shared.setAppStep(step: .main)
}
}
} }
} }
} else { } else {
if AppState.shared.pushRoomId > 0 { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) withAnimation {
} else if AppState.shared.pushChannelId > 0 { if AppState.shared.pushRoomId > 0 {
AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId)
} else if AppState.shared.pushAudioContentId > 0 { } else if AppState.shared.pushChannelId > 0 {
AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId))
} else { } else if AppState.shared.pushAudioContentId > 0 {
AppState.shared.setAppStep(step: .main) AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId))
} else {
AppState.shared.setAppStep(step: .main)
}
}
} }
} }
} }