diff --git a/SodaLive/Resources/Assets.xcassets/splash/splash_bg.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/splash/splash_bg.imageset/Contents.json deleted file mode 100644 index 42acdde..0000000 --- a/SodaLive/Resources/Assets.xcassets/splash/splash_bg.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "splash_bg.jpg", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/SodaLive/Resources/Assets.xcassets/splash/splash_bg.imageset/splash_bg.jpg b/SodaLive/Resources/Assets.xcassets/splash/splash_bg.imageset/splash_bg.jpg deleted file mode 100644 index 2c4dd5e..0000000 Binary files a/SodaLive/Resources/Assets.xcassets/splash/splash_bg.imageset/splash_bg.jpg and /dev/null differ diff --git a/SodaLive/Resources/Assets.xcassets/splash/splash_logo.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/splash/splash_logo.imageset/Contents.json deleted file mode 100644 index ae9fc61..0000000 --- a/SodaLive/Resources/Assets.xcassets/splash/splash_logo.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "splash_logo.png", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/SodaLive/Resources/Assets.xcassets/splash/splash_logo.imageset/splash_logo.png b/SodaLive/Resources/Assets.xcassets/splash/splash_logo.imageset/splash_logo.png deleted file mode 100644 index 5d168e5..0000000 Binary files a/SodaLive/Resources/Assets.xcassets/splash/splash_logo.imageset/splash_logo.png and /dev/null differ diff --git a/SodaLive/Resources/Assets.xcassets/splash/splash_text.imageset/Contents.json b/SodaLive/Resources/Assets.xcassets/splash/splash_text.imageset/Contents.json deleted file mode 100644 index 1214b3d..0000000 --- a/SodaLive/Resources/Assets.xcassets/splash/splash_text.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "splash_text.png", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/SodaLive/Resources/Assets.xcassets/splash/splash_text.imageset/splash_text.png b/SodaLive/Resources/Assets.xcassets/splash/splash_text.imageset/splash_text.png deleted file mode 100644 index 8329b69..0000000 Binary files a/SodaLive/Resources/Assets.xcassets/splash/splash_text.imageset/splash_text.png and /dev/null differ diff --git a/SodaLive/Resources/video.mp4 b/SodaLive/Resources/video.mp4 new file mode 100644 index 0000000..fbcf9d6 Binary files /dev/null and b/SodaLive/Resources/video.mp4 differ diff --git a/SodaLive/Sources/Splash/SplashView.swift b/SodaLive/Sources/Splash/SplashView.swift index b9e31bd..6fa6bbb 100644 --- a/SodaLive/Sources/Splash/SplashView.swift +++ b/SodaLive/Sources/Splash/SplashView.swift @@ -8,8 +8,10 @@ import SwiftUI import FirebaseRemoteConfig +import AVKit + struct SplashView: View { - + @State private var player: AVPlayer? @State private var isShowForcedUpdatePopup = false @State private var isShowUpdatePopup = false @@ -17,19 +19,22 @@ struct SplashView: View { var body: some View { ZStack(alignment: .top) { - Image("splash_bg") - .resizable() - .scaledToFill() - .edgesIgnoringSafeArea(.all) - - VStack(spacing: 0) { - Image("splash_text") - .padding(.top, 130) - - Spacer() - - Image("splash_logo") - .padding(.bottom, 50) + VStack { + if let player = player { + VideoPlayer(player: player) + .ignoresSafeArea(.all) + .onAppear { + player.play() + } + .onDisappear { + player.pause() + } + } else { + Color(hex: "#ecedf3") + } + } + .onAppear { + loadVideo() } if isShowUpdatePopup { @@ -59,11 +64,20 @@ struct SplashView: View { } ) } - } - .onAppear { + } + + private func loadVideo() { + guard let url = Bundle.main.url(forResource: "video", withExtension: "mp4") else { fetchLastestVersion() + return } + + player = AVPlayer(url: url) + NotificationCenter.default + .addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: player?.currentItem, queue: .main) { _ in + fetchLastestVersion() + } } private func fetchLastestVersion() { @@ -78,18 +92,14 @@ struct SplashView: View { checkAppVersion(latestVersion: remoteConfig["ios_latest_version"].stringValue) } } else { - DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) { - withAnimation { - if AppState.shared.pushRoomId > 0 { - liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) - } else if AppState.shared.pushChannelId > 0 { - AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) - } else if AppState.shared.pushAudioContentId > 0 { - AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) - } else { - AppState.shared.setAppStep(step: .main) - } - } + if AppState.shared.pushRoomId > 0 { + liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) + } else if AppState.shared.pushChannelId > 0 { + AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) + } else if AppState.shared.pushAudioContentId > 0 { + AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) + } else { + AppState.shared.setAppStep(step: .main) } } } @@ -115,33 +125,25 @@ struct SplashView: View { } else if latestMajor == major && latestMinor == minor && latestPatch > patch { self.isShowUpdatePopup = true } else { - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - withAnimation { - if AppState.shared.pushRoomId > 0 { - liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) - } else if AppState.shared.pushChannelId > 0 { - AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) - } else if AppState.shared.pushAudioContentId > 0 { - AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) - } else { - AppState.shared.setAppStep(step: .main) - } - } + if AppState.shared.pushRoomId > 0 { + liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) + } else if AppState.shared.pushChannelId > 0 { + AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) + } else if AppState.shared.pushAudioContentId > 0 { + AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) + } else { + AppState.shared.setAppStep(step: .main) } } } else { - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - withAnimation { - if AppState.shared.pushRoomId > 0 { - liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) - } else if AppState.shared.pushChannelId > 0 { - AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) - } else if AppState.shared.pushAudioContentId > 0 { - AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) - } else { - AppState.shared.setAppStep(step: .main) - } - } + if AppState.shared.pushRoomId > 0 { + liveViewModel.enterLiveRoom(roomId: AppState.shared.pushRoomId) + } else if AppState.shared.pushChannelId > 0 { + AppState.shared.setAppStep(step: .creatorDetail(userId: AppState.shared.pushChannelId)) + } else if AppState.shared.pushAudioContentId > 0 { + AppState.shared.setAppStep(step: .contentDetail(contentId: AppState.shared.pushAudioContentId)) + } else { + AppState.shared.setAppStep(step: .main) } } }