Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created Video Player for Onboarding and Upgrade Screens #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions QBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
FFB6EA8D25EAEC3300290F89 /* FooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB6EA8C25EAEC3300290F89 /* FooterView.swift */; };
FFB8A38F25E9BF1B00DA1E67 /* PrivacyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB8A38E25E9BF1B00DA1E67 /* PrivacyViewController.swift */; };
FFD7E69725F31FEF00B176F4 /* UpgradeFromSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD7E69625F31FEF00B176F4 /* UpgradeFromSettingsViewController.swift */; };
FFDEC3A1269BBCA6005BF738 /* VideoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFDEC3A0269BBCA6005BF738 /* VideoView.swift */; };
FFDEC3AB269BBDB5005BF738 /* video1.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = FFDEC3A9269BBDB3005BF738 /* video1.mp4 */; };
FFDEC3AC269BBDB5005BF738 /* video2.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = FFDEC3AA269BBDB5005BF738 /* video2.mp4 */; };
FFE4128B25F07BD30025662E /* PremiumTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFE4128A25F07BD30025662E /* PremiumTitle.swift */; };
FFE4129025F087100025662E /* RecentsDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFE4128F25F087100025662E /* RecentsDetailViewController.swift */; };
FFE4129525F091570025662E /* UITextField+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFE4129425F091570025662E /* UITextField+Extension.swift */; };
Expand Down Expand Up @@ -218,6 +221,9 @@
FFB6EA8C25EAEC3300290F89 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = "<group>"; };
FFB8A38E25E9BF1B00DA1E67 /* PrivacyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyViewController.swift; sourceTree = "<group>"; };
FFD7E69625F31FEF00B176F4 /* UpgradeFromSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeFromSettingsViewController.swift; sourceTree = "<group>"; };
FFDEC3A0269BBCA6005BF738 /* VideoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoView.swift; sourceTree = "<group>"; };
FFDEC3A9269BBDB3005BF738 /* video1.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = video1.mp4; sourceTree = "<group>"; };
FFDEC3AA269BBDB5005BF738 /* video2.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = video2.mp4; sourceTree = "<group>"; };
FFE4128A25F07BD30025662E /* PremiumTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PremiumTitle.swift; sourceTree = "<group>"; };
FFE4128F25F087100025662E /* RecentsDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentsDetailViewController.swift; sourceTree = "<group>"; };
FFE4129425F091570025662E /* UITextField+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Extension.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -523,6 +529,7 @@
FFA0F0E125E8CD3900C79D8C /* Helpers */ = {
isa = PBXGroup;
children = (
FFDEC39F269BBC98005BF738 /* VideoView */,
FF4884FE2635F069001F7D9C /* FirebaseAnalytics */,
FFA0F0E225E8CD4600C79D8C /* Switcher.swift */,
FF601C7F25EEDC950015DD22 /* Cache.swift */,
Expand Down Expand Up @@ -560,6 +567,7 @@
FFA0F0F825E8CE4300C79D8C /* Resources */ = {
isa = PBXGroup;
children = (
FFDEC3A8269BBD97005BF738 /* Video */,
FFA0F0F925E8CE5000C79D8C /* Fonts */,
);
path = Resources;
Expand Down Expand Up @@ -631,6 +639,23 @@
path = FooterView;
sourceTree = "<group>";
};
FFDEC39F269BBC98005BF738 /* VideoView */ = {
isa = PBXGroup;
children = (
FFDEC3A0269BBCA6005BF738 /* VideoView.swift */,
);
path = VideoView;
sourceTree = "<group>";
};
FFDEC3A8269BBD97005BF738 /* Video */ = {
isa = PBXGroup;
children = (
FFDEC3A9269BBDB3005BF738 /* video1.mp4 */,
FFDEC3AA269BBDB5005BF738 /* video2.mp4 */,
);
path = Video;
sourceTree = "<group>";
};
FFF7146725EDB11600983624 /* User */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -747,10 +772,12 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FFDEC3AC269BBDB5005BF738 /* video2.mp4 in Resources */,
FFA0F0F425E8CDD600C79D8C /* Slide.xib in Resources */,
FFA0F11D25E8CE9400C79D8C /* SF-Pro-Display-Ultralight.otf in Resources */,
FFA0F11025E8CE9300C79D8C /* SF-Pro-Display-Heavy.otf in Resources */,
FF8D44EB25F022AD00964BAA /* Premium.storyboard in Resources */,
FFDEC3AB269BBDB5005BF738 /* video1.mp4 in Resources */,
FFA0F13425E8CEEF00C79D8C /* SF-Pro-Text-Medium.otf in Resources */,
FFA0F13825E8CEEF00C79D8C /* SF-Pro-Text-Bold.otf in Resources */,
FFA0F0A525E8CC0000C79D8C /* LaunchScreen.storyboard in Resources */,
Expand Down Expand Up @@ -914,6 +941,7 @@
FF197D3525EC8CDC002439D4 /* QRBarcodeScannerViewController.swift in Sources */,
FF197D2325EC8B21002439D4 /* Functions.swift in Sources */,
FFA0F16425E8E42400C79D8C /* UIColor+Extension.swift in Sources */,
FFDEC3A1269BBCA6005BF738 /* VideoView.swift in Sources */,
FF4BB4A725EAB90900A461D4 /* MainSegmentedViewController.swift in Sources */,
FF601CB325EEFC300015DD22 /* UIImage+Extension.swift in Sources */,
FFA0F15F25E8E3BF00C79D8C /* UIViewController+Extension.swift in Sources */,
Expand Down Expand Up @@ -1137,6 +1165,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 9487YL2FBF;
INFOPLIST_FILE = "$(SRCROOT)/QBar/Supporting Files/Info.plist";
Expand All @@ -1145,9 +1174,10 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
PRODUCT_BUNDLE_IDENTIFIER = "com.pcmrail.qr-bar";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
Expand All @@ -1159,6 +1189,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 9487YL2FBF;
INFOPLIST_FILE = "$(SRCROOT)/QBar/Supporting Files/Info.plist";
Expand All @@ -1167,9 +1198,10 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
PRODUCT_BUNDLE_IDENTIFIER = "com.pcmrail.qr-bar";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
Expand Down
19 changes: 17 additions & 2 deletions QBar/Controllers/Onboarding/OnboardingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class OnboardingViewController: UIViewController {
print("viewWillDisappear")
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
slides.last?.videoView.stop()
}

deinit {
NotificationCenter.default.removeObserver(self, name: dismissNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: subTypeNotificationIndex, object: nil)
Expand Down Expand Up @@ -111,12 +116,14 @@ class OnboardingViewController: UIViewController {
snakePageControl.isHidden = true
nextButton.isHidden = true
nextButton.isEnabled = false
slides.last?.videoView.play()
} else {
nextButton.isHidden = false
nextButton.isEnabled = true
snakePageControl.isHidden = false
nextButton.setImage(UIImage(named: "arrowRight"), for: .normal)
nextButton.setTitle(nil, for: .normal)
slides.last?.videoView.stop()
}
}

Expand Down Expand Up @@ -175,6 +182,10 @@ class OnboardingViewController: UIViewController {
}
}
}

/// Configuring Video Preview
slides.last?.videoView.configure(resource: "video2")
slides.last?.videoView.isLoop = true
}

private func configureSlideLabels(slide: Slide, onboarding: OnboardingTitle, subscriptions: Subscriptions) {
Expand Down Expand Up @@ -203,12 +214,16 @@ class OnboardingViewController: UIViewController {
slide.startYearlyButton.setTitle(onboarding.startYearlyFirstTitle, for: UIControl.State())
slide.privacyEulaLabel.text = onboarding.privacyEulaTitle

slides.last?.thenLabel.isHidden = onboarding.fourthTitleIsHidden
slides.last?.startYearlySecondButton.isHidden = onboarding.startYearlySecondTitleIsHIdden
// slides.last?.thenLabel.isHidden = onboarding.fourthTitleIsHidden
slides.last?.thenLabel.isHidden = true
// slides.last?.startYearlySecondButton.isHidden = onboarding.startYearlySecondTitleIsHIdden
slides.last?.startYearlySecondButton.isHidden = true
slides[0].closeButton.isHidden = true
slides[0].closeButton.isEnabled = false
slides[1].closeButton.isHidden = true
slides[1].closeButton.isEnabled = false
slides[2].proceedWithBasicButton.isHidden = true
slides[2].proceedWithBasicButton.isEnabled = false
}

/// Purchasing product
Expand Down
111 changes: 74 additions & 37 deletions QBar/Controllers/UpgradeToPremiumViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ protocol UpgradeFromRecentsDelegate: class {
class UpgradeToPremiumViewController: UIViewController {

// MARK: - IBOutlets
@IBOutlet weak var upgradeLabel: UILabel!
@IBOutlet weak var enjoyLabel: UILabel!
// @IBOutlet weak var upgradeLabel: UILabel!
// @IBOutlet weak var enjoyLabel: UILabel!
@IBOutlet weak var startFreeLabel: UILabel!
@IBOutlet weak var thenLabel: UILabel!
@IBOutlet weak var proceedWithBasicButton: UIButton!
// @IBOutlet weak var proceedWithBasicButton: UIButton!
@IBOutlet weak var tryFreeButton: UIButton!
@IBOutlet weak var startMonthlyView: UIView!
@IBOutlet weak var startYearlyButton: UIButton!
@IBOutlet weak var priceAYearButton: UIButton!
// @IBOutlet weak var startMonthlyView: UIView!
// @IBOutlet weak var startYearlyButton: UIButton!
// @IBOutlet weak var priceAYearButton: UIButton!
@IBOutlet weak var trialLabel: UILabel!
@IBOutlet weak var privacyButton: UIButton!
@IBOutlet weak var eulaButton: UIButton!
@IBOutlet weak var closeButton: UIButton!

@IBOutlet weak var videoView: VideoView!
@IBOutlet weak var videoHeightConstraint: NSLayoutConstraint!

// MARK: - Properties
let service = Service()
Expand All @@ -53,15 +55,47 @@ class UpgradeToPremiumViewController: UIViewController {
configureView()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
/// Configuring Video Preview
videoView.play()
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
/// Configuring Video Preview
videoView.stop()
}

// MARK: - Private Functions
private func configureView() {
proceedWithBasicButton.addLine(position: .LINE_POSITION_BOTTOM, color: .mainGrayAverage, width: 0.5)
// proceedWithBasicButton.addLine(position: .LINE_POSITION_BOTTOM, color: .mainGrayAverage, width: 0.5)
tryFreeButton.cornerRadius(to: 20)
privacyButton.addLine(position: .LINE_POSITION_BOTTOM, color: .mainGrayAverage, width: 0.5)
eulaButton.addLine(position: .LINE_POSITION_BOTTOM, color: .mainGrayAverage, width: 0.5)
startMonthlyView.cornerRadius(to: 20)
startMonthlyView.addBorder(width: 2.0, color: .mainBlack)
// startMonthlyView.cornerRadius(to: 20)
// startMonthlyView.addBorder(width: 2.0, color: .mainBlack)

switch type {
case .iPhone5_5S_5C_SE:
videoHeightConstraint.constant = 261
case .iPhone6_6S_7_8_SE2:
videoHeightConstraint.constant = 360
case .iPhone6Plus_6SPlus_7Plus_8Plus:
videoHeightConstraint.constant = 400
case .iPhone12Mini:
videoHeightConstraint.constant = 460
case .iPhoneX_XS_11Pro:
videoHeightConstraint.constant = 490
case .iPhone12_12Pro:
videoHeightConstraint.constant = 520
case .iPhoneXR_XSMax_11_11ProMax:
videoHeightConstraint.constant = 560
case .iPhone12ProMax:
videoHeightConstraint.constant = 560
default:
break
}

service.getOnboardingTitles(for: PremiumTab.Onboarding.rawValue) { (onboarding, error) in
if let error = error {
Expand All @@ -76,6 +110,9 @@ class UpgradeToPremiumViewController: UIViewController {
}
}
}
/// Configuring Video Preview
videoView.configure(resource: "video2")
videoView.isLoop = true
}

private func configureSubscribeTitles(for onboarding: OnboardingTitle, subscriptions: Subscriptions) {
Expand All @@ -84,28 +121,28 @@ class UpgradeToPremiumViewController: UIViewController {
if title.contains("Monthly") {
self.thenLabel.text = "\(onboarding.fourthTitle) \(price) a month"
} else if title.contains("Yearly") {
self.priceAYearButton.setTitle("\(price) \(onboarding.startYearlySecondTitle)", for: UIControl.State())
// self.priceAYearButton.setTitle("\(price) \(onboarding.startYearlySecondTitle)", for: UIControl.State())
}
}
} else {
self.thenLabel.text = "\(onboarding.fourthTitle) $7.99 a month"
self.priceAYearButton.setTitle("$32.99 \(onboarding.startYearlySecondTitle)", for: UIControl.State())
// self.priceAYearButton.setTitle("$32.99 \(onboarding.startYearlySecondTitle)", for: UIControl.State())
}

self.closeButton.isHidden = !onboarding.closeButton
self.closeButton.isEnabled = onboarding.closeButton
self.proceedWithBasicButton.isHidden = onboarding.proceedIsHidden
self.proceedWithBasicButton.isEnabled = !onboarding.proceedIsHidden
self.upgradeLabel.text = onboarding.firstTitle
self.enjoyLabel.text = onboarding.secondTitle
// self.proceedWithBasicButton.isHidden = onboarding.proceedIsHidden
// self.proceedWithBasicButton.isEnabled = !onboarding.proceedIsHidden
// self.upgradeLabel.text = onboarding.firstTitle
// self.enjoyLabel.text = onboarding.secondTitle
self.startFreeLabel.text = onboarding.thirdTitle
self.proceedWithBasicButton.setTitle(onboarding.basicTitle, for: UIControl.State())
// self.proceedWithBasicButton.setTitle(onboarding.basicTitle, for: UIControl.State())
self.tryFreeButton.setTitle(onboarding.tryFreeTitle, for: UIControl.State())
self.startYearlyButton.setTitle(onboarding.startYearlyFirstTitle, for: UIControl.State())
// self.startYearlyButton.setTitle(onboarding.startYearlyFirstTitle, for: UIControl.State())
self.trialLabel.text = onboarding.privacyEulaTitle

self.thenLabel.isHidden = onboarding.fourthTitleIsHidden
self.priceAYearButton.isHidden = onboarding.startYearlySecondTitleIsHIdden
// self.priceAYearButton.isHidden = onboarding.startYearlySecondTitleIsHIdden
}

/// Purchasing product
Expand Down Expand Up @@ -156,12 +193,12 @@ class UpgradeToPremiumViewController: UIViewController {
}
}

// MARK: - IBActions
@IBAction func proceedWithBasicTapped(_ sender: Any) {
// NotificationCenter.default.post(name: dismissNotification, object: nil)
dismiss(animated: true, completion: nil)
self.delegate?.dismissFromUpgrade()
}
// // MARK: - IBActions
// @IBAction func proceedWithBasicTapped(_ sender: Any) {
//// NotificationCenter.default.post(name: dismissNotification, object: nil)
// dismiss(animated: true, completion: nil)
// self.delegate?.dismissFromUpgrade()
// }

@IBAction func tryFreeTapped(_ sender: Any) {
// purchase(index: 1)
Expand All @@ -178,19 +215,19 @@ class UpgradeToPremiumViewController: UIViewController {
}
}

@IBAction func startYearlyTapped(_ sender: Any) {
print("Start Yearly Tapped")
QRAnalytics.shared.tappedToSubscribeButton(userID: User.currentUser?.uid ?? "", button: "Start Yearly Button")
if service.isConnectedToInternet {
for productID in productIDs {
if productID.contains("year") {
purchaseItem(productID: productID)
}
}
} else {
ErrorHandling.showError(message: "Check Internet Connection and try again.", controller: self)
}
}
// @IBAction func startYearlyTapped(_ sender: Any) {
// print("Start Yearly Tapped")
// QRAnalytics.shared.tappedToSubscribeButton(userID: User.currentUser?.uid ?? "", button: "Start Yearly Button")
// if service.isConnectedToInternet {
// for productID in productIDs {
// if productID.contains("year") {
// purchaseItem(productID: productID)
// }
// }
// } else {
// ErrorHandling.showError(message: "Check Internet Connection and try again.", controller: self)
// }
// }

@IBAction func startMonthlyTapped(_ sender: Any) {
// purchase(index: 0)
Expand Down
Loading