diff --git a/Veloria.xcodeproj/project.pbxproj b/Veloria.xcodeproj/project.pbxproj index 2e3bf2c..284e864 100644 --- a/Veloria.xcodeproj/project.pbxproj +++ b/Veloria.xcodeproj/project.pbxproj @@ -305,7 +305,6 @@ 1B056E762DDB3641007EE38D /* VPTabBarItemNormalVew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPTabBarItemNormalVew.swift; sourceTree = ""; }; 1B056E782DDB365A007EE38D /* VPTabBarItemSelectedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPTabBarItemSelectedView.swift; sourceTree = ""; }; 1B056E7A2DDB37BA007EE38D /* VPGradientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPGradientView.swift; sourceTree = ""; }; - 316330F9CC4DB54283ADC8A9 /* Pods-VideoPlayer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VideoPlayer.release.xcconfig"; path = "Target Support Files/Pods-VideoPlayer/Pods-VideoPlayer.release.xcconfig"; sourceTree = ""; }; 34F57E87E765BF8D72A43DCA /* Pods_Veloria.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Veloria.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 831DCE145EAEF22088BB06E4 /* Pods-Veloria.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Veloria.debug.xcconfig"; path = "Target Support Files/Pods-Veloria/Pods-Veloria.debug.xcconfig"; sourceTree = ""; }; AA827CC8ACC3AE70E33A0EEB /* Pods-Veloria.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Veloria.release.xcconfig"; path = "Target Support Files/Pods-Veloria/Pods-Veloria.release.xcconfig"; sourceTree = ""; }; @@ -524,7 +523,6 @@ BFF5B2782DF679720044227A /* VPMoreVideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPMoreVideoViewController.swift; sourceTree = ""; }; BFF5B4AE2DF6B6630044227A /* VPMutualCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPMutualCollectionView.swift; sourceTree = ""; }; BFF5B6E42DF7C8580044227A /* VPEmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPEmptyView.swift; sourceTree = ""; }; - E0BDA3570E00C90877E45AA0 /* Pods-VideoPlayer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VideoPlayer.debug.xcconfig"; path = "Target Support Files/Pods-VideoPlayer/Pods-VideoPlayer.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -806,8 +804,6 @@ 97790501CCBF987017A55C80 /* Pods */ = { isa = PBXGroup; children = ( - E0BDA3570E00C90877E45AA0 /* Pods-VideoPlayer.debug.xcconfig */, - 316330F9CC4DB54283ADC8A9 /* Pods-VideoPlayer.release.xcconfig */, 831DCE145EAEF22088BB06E4 /* Pods-Veloria.debug.xcconfig */, AA827CC8ACC3AE70E33A0EEB /* Pods-Veloria.release.xcconfig */, ); diff --git a/Veloria/AppDelegate/AppDelegate+Open.swift b/Veloria/AppDelegate/AppDelegate+Open.swift index d02e8ba..45c7661 100644 --- a/Veloria/AppDelegate/AppDelegate+Open.swift +++ b/Veloria/AppDelegate/AppDelegate+Open.swift @@ -7,6 +7,7 @@ import UIKit import FacebookCore +import AdjustSdk extension SceneDelegate { @@ -17,25 +18,30 @@ extension SceneDelegate { //facebook let result = ApplicationDelegate.shared.application(UIApplication.shared, open: url, sourceApplication: nil, annotation: [UIApplication.OpenURLOptionsKey.annotation]) - if !result { + if let link = ADJDeeplink(deeplink: url) { + Adjust.processDeeplink(link) + } vp_handleOpenAppMessage(webpageURL: url) } } func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { guard let webpageURL = userActivity.webpageURL else { return } - vp_handleOpenAppMessage(webpageURL: webpageURL) + let result = ApplicationDelegate.shared.application(UIApplication.shared, continue: userActivity) + + if !result { + vp_handleOpenAppMessage(webpageURL: webpageURL) + } } } extension SceneDelegate { - ///是否有正在打开的消息 - static var hasOpenMessage = false + ///是否允许打开消息(每次打开APP只允许打开一次消息) + static var allowOpenMessage = true ///是否需要重试 static var isNeedRetry = false - private static var webpageURL: URL? func vp_handleOpenAppMessage(webpageURL: URL?) { @@ -60,21 +66,16 @@ extension SceneDelegate { } private func _handleOpenAppMessage(webpageURL: URL?) { - if Self.hasOpenMessage { return } - Self.hasOpenMessage = true - - DispatchQueue.main.asyncAfter(deadline: .now() + 3) { - Self.hasOpenMessage = false - } + guard SceneDelegate.allowOpenMessage else { return } + SceneDelegate.allowOpenMessage = false //统计用URL var statUrlStr: String? = webpageURL?.absoluteString var data: [String : Any]? = webpageURL?.query?.vp_urlQuryToDictionary() - if let pasteStr = UIPasteboard.general.string, pasteStr.contains("veloriaapp") { - UIPasteboard.general.string = nil + if statUrlStr == nil, let pasteStr = UIPasteboard.general.string, pasteStr.contains("veloriaapp") { let tempArr = pasteStr.components(separatedBy: "?") let query = tempArr.last @@ -85,7 +86,7 @@ extension SceneDelegate { } } - + UIPasteboard.general.string = nil diff --git a/Veloria/AppDelegate/AppDelegate+Thirdparty.swift b/Veloria/AppDelegate/AppDelegate+Thirdparty.swift index 565f9f9..b9acb48 100644 --- a/Veloria/AppDelegate/AppDelegate+Thirdparty.swift +++ b/Veloria/AppDelegate/AppDelegate+Thirdparty.swift @@ -19,7 +19,25 @@ extension AppDelegate { MJRefreshConfig.default.languageCode = VPLocalizedManager.shared.mjLocalizedKey //Adjust +#if DEBUG + let config = ADJConfig(appToken: "jmtc740fki68", environment: ADJEnvironmentSandbox) + config?.logLevel = .verbose +#else let config = ADJConfig(appToken: "jmtc740fki68", environment: ADJEnvironmentProduction) +#endif + config?.delegate = self Adjust.initSdk(config) + + AppLinkUtility.fetchDeferredAppLink { url, error in + if let url = url, error != nil { + VPAppTool.sceneDelegate?.vp_handleOpenAppMessage(webpageURL: url) + } + } + } +} + +extension AppDelegate: AdjustDelegate { + func adjustDeferredDeeplinkReceived(_ deeplink: URL?) -> Bool { + return true } } diff --git a/Veloria/AppDelegate/SceneDelegate.swift b/Veloria/AppDelegate/SceneDelegate.swift index 76bd7b6..c27ac8f 100644 --- a/Veloria/AppDelegate/SceneDelegate.swift +++ b/Veloria/AppDelegate/SceneDelegate.swift @@ -71,6 +71,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { func sceneDidEnterBackground(_ scene: UIScene) { vpLog(message: "++++++++++++++sceneDidEnterBackground") + SceneDelegate.allowOpenMessage = true } diff --git a/Veloria/Base/WebView/VPWebView.swift b/Veloria/Base/WebView/VPWebView.swift index 8c4f029..64aea19 100644 --- a/Veloria/Base/WebView/VPWebView.swift +++ b/Veloria/Base/WebView/VPWebView.swift @@ -77,7 +77,8 @@ class VPWebView: WKWebView { func load(urlStr: String) { guard let url = URL(string: urlStr) else { return } - let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 30) +// let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 30) + let request = URLRequest(url: url, cachePolicy: .returnCacheDataElseLoad, timeoutInterval: 30) self.load(request) } diff --git a/Veloria/Class/Player/View/VPPlayerRechargeView.swift b/Veloria/Class/Player/View/VPPlayerRechargeView.swift index 1149e68..ad22abb 100644 --- a/Veloria/Class/Player/View/VPPlayerRechargeView.swift +++ b/Veloria/Class/Player/View/VPPlayerRechargeView.swift @@ -38,27 +38,33 @@ class VPPlayerRechargeView: HWPanModalContentView { self.coinsView.dataArr = list } - if self.stackView.arrangedSubviews.count == 1, - let view = self.stackView.arrangedSubviews.first, - view == self.coinsView { - scrollView.snp.updateConstraints { make in - make.top.equalToSuperview().offset(56) - } - } else { - scrollView.snp.updateConstraints { make in - make.top.equalToSuperview().offset(41) - } - } - - self.stackView.addArrangedSubview(tipView) } - DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self] in + + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in self?.panModalSetNeedsLayoutUpdate() + } } } + var unlockCoin: Int? { + didSet { + let coinCountStr = " \(unlockCoin ?? 0)" + let text = "veloria_unlock".localized + coinCountStr + let coinRange = text.ocString().range(of: coinCountStr) + + let string = NSMutableAttributedString(string: text) + string.color = .colorFFFFFF() + string.font = .fontRegular(ofSize: 13) + string.setColor(.color05CEA0(), range: coinRange) + string.setFont(.fontMedium(ofSize: 13), range: coinRange) + + + unlockCoinLabel.attributedText = string + } + } + var buyFinishBlock: (() -> Void)? var vipBuyFinishBlock: (() -> Void)? @@ -81,6 +87,22 @@ class VPPlayerRechargeView: HWPanModalContentView { return label }() + private lazy var unlockCoinBgView: UIView = { + let view = VPGradientView() + view.colors = [UIColor.color05CEA0(alpha: 0.5).cgColor, UIColor.color7C174F(alpha: 0.5).cgColor] + view.locations = [0, 1] + view.startPoint = .init(x: 0, y: 0.3) + view.endPoint = .init(x: 1, y: 0.8) + view.layer.cornerRadius = 13 + view.layer.masksToBounds = true + return view + }() + + private lazy var unlockCoinLabel: UILabel = { + let label = UILabel() + return label + }() + private lazy var coinIconImageView: UIImageView = { let imageView = UIImageView(image: UIImage(named: "coin_icon_07")) return imageView @@ -88,6 +110,7 @@ class VPPlayerRechargeView: HWPanModalContentView { private lazy var scrollView: VPScrollView = { let scrollView = VPScrollView() + scrollView.isScrollEnabled = true return scrollView }() @@ -265,7 +288,10 @@ extension VPPlayerRechargeView { addSubview(bgView) addSubview(closeButton) addSubview(coinLabel) - addSubview(coinIconImageView) +// addSubview(coinIconImageView) + addSubview(unlockCoinBgView) + unlockCoinBgView.addSubview(unlockCoinLabel) + unlockCoinBgView.addSubview(coinIconImageView) addSubview(scrollView) scrollView.addSubview(stackView) @@ -282,17 +308,29 @@ extension VPPlayerRechargeView { coinLabel.snp.makeConstraints { make in make.left.equalToSuperview().offset(15) - make.centerY.equalTo(coinIconImageView) + make.centerY.equalTo(closeButton) + } + + unlockCoinBgView.snp.makeConstraints { make in + make.left.equalTo(coinLabel.snp.right).offset(6) + make.centerY.equalTo(coinLabel) + make.height.equalTo(26) + } + + unlockCoinLabel.snp.makeConstraints { make in + make.centerY.equalToSuperview() + make.left.equalToSuperview().offset(12) } coinIconImageView.snp.makeConstraints { make in - make.left.equalTo(coinLabel.snp.right).offset(3) - make.centerY.equalTo(closeButton) + make.centerY.equalToSuperview() + make.left.equalTo(unlockCoinLabel.snp.right).offset(2) + make.right.equalToSuperview().offset(-12) } scrollView.snp.makeConstraints { make in make.left.right.equalToSuperview() - make.top.equalToSuperview().offset(41) + make.top.equalToSuperview().offset(48) make.bottom.equalToSuperview() } diff --git a/Veloria/Class/Player/ViewModel/VPVideoPlayViewModel.swift b/Veloria/Class/Player/ViewModel/VPVideoPlayViewModel.swift index 8576ecd..17d0d7b 100644 --- a/Veloria/Class/Player/ViewModel/VPVideoPlayViewModel.swift +++ b/Veloria/Class/Player/ViewModel/VPVideoPlayViewModel.swift @@ -88,6 +88,7 @@ extension VPVideoPlayViewModel { let view = VPPlayerRechargeView() view.model = model + view.unlockCoin = videoInfo.coins view.shortPlayId = videoInfo.short_play_id view.videoId = videoInfo.short_play_video_id view.buyFinishBlock = { [weak self] in diff --git a/Veloria/Class/Wallet/View/VPStoreCoinsBuyView.swift b/Veloria/Class/Wallet/View/VPStoreCoinsBuyView.swift index 2552299..a292bb3 100644 --- a/Veloria/Class/Wallet/View/VPStoreCoinsBuyView.swift +++ b/Veloria/Class/Wallet/View/VPStoreCoinsBuyView.swift @@ -30,13 +30,15 @@ class VPStoreCoinsBuyView: UIView { } } - CATransaction.setCompletionBlock { [weak self] in - guard let self = self else { return } - self.updateLayout() + UIView.performWithoutAnimation { [weak self] in + self?.reloadData() + } + self.bigCollectionView.performBatchUpdates(nil) { [weak self] _ in + self?.updateLayout() + } + self.smallCollectionView.performBatchUpdates(nil) { [weak self] _ in + self?.updateLayout() } - CATransaction.begin() - self.reloadData() - CATransaction.commit() } } diff --git a/Veloria/Class/Wallet/View/VPStoreVipBuyView.swift b/Veloria/Class/Wallet/View/VPStoreVipBuyView.swift index 0e88821..f7c84cd 100644 --- a/Veloria/Class/Wallet/View/VPStoreVipBuyView.swift +++ b/Veloria/Class/Wallet/View/VPStoreVipBuyView.swift @@ -39,6 +39,14 @@ class VPStoreVipBuyView: UIView { private var currentIndex: Int? + private lazy var titleLabel: UILabel = { + let label = UILabel() + label.font = .fontMedium(ofSize: 13) + label.textColor = .colorFFFFFF() + label.text = "VIP |" + "veloria_store_auto_renew".localized + return label + }() + private lazy var collectionViewLayout: UICollectionViewFlowLayout = { let layout = UICollectionViewFlowLayout() layout.itemSize = .init(width: UIScreen.width - 30, height: 130) @@ -71,10 +79,17 @@ class VPStoreVipBuyView: UIView { extension VPStoreVipBuyView { private func vp_setupUI() { + addSubview(titleLabel) addSubview(collectionView) + titleLabel.snp.makeConstraints { make in + make.left.equalToSuperview().offset(15) + make.top.equalToSuperview() + } + collectionView.snp.makeConstraints { make in - make.edges.equalToSuperview() + make.left.right.bottom.equalToSuperview() + make.top.equalTo(titleLabel.snp.bottom) } } diff --git a/Veloria/Source/en.lproj/Localizable.strings b/Veloria/Source/en.lproj/Localizable.strings index d21e6bf..6011c7e 100644 --- a/Veloria/Source/en.lproj/Localizable.strings +++ b/Veloria/Source/en.lproj/Localizable.strings @@ -101,6 +101,7 @@ "veloria_vip_activate_content" = "Activate vip and enjoy HD video privileges."; "veloria_later" = "Later"; "veloria_go" = "Go"; +"veloria_unlock" = "Unlock:"; "veloria_bonus_count_text" = "+## Bonus"; diff --git a/Veloria/Veloria.entitlements b/Veloria/Veloria.entitlements index ccba362..367c14b 100644 --- a/Veloria/Veloria.entitlements +++ b/Veloria/Veloria.entitlements @@ -12,6 +12,7 @@ applinks:qjwl168.com applinks:veloriaapp.go.link + applinks:lxjg.adj.st keychain-access-groups