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

[stable-5.2.7] NMC/1971 - Onboarding #201

Closed
wants to merge 1 commit into from
Closed
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
114 changes: 63 additions & 51 deletions Brand/Intro/NCIntro.storyboard

Large diffs are not rendered by default.

43 changes: 22 additions & 21 deletions Brand/Intro/NCIntroCollectionViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="introCell" id="gTV-IL-0wX" customClass="NCIntroCollectionViewCell" customModule="Nextcloud" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="introCell" id="W7v-l7-ZRn" customClass="NCIntroCollectionViewCell" customModule="Nextcloud" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="337" height="462"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="337" height="462"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bZc-Ai-h3y">
<rect key="frame" x="8" y="426.5" width="321" height="27.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hg2-1f-a5q">
<rect key="frame" x="8" y="426" width="321" height="28"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="28" id="gRQ-4D-JAn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="23"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" image="intro1" translatesAutoresizingMaskIntoConstraints="NO" id="f3T-nC-cwA">
<rect key="frame" x="93.5" y="156" width="150" height="150"/>
<constraints>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="150" id="jne-Xj-IAh"/>
<constraint firstAttribute="width" secondItem="f3T-nC-cwA" secondAttribute="height" multiplier="1:1" id="mhZ-Cn-42Q"/>
</constraints>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" image="introSlide1" translatesAutoresizingMaskIntoConstraints="NO" id="0Rr-r4-4Vb">
<rect key="frame" x="0.0" y="0.0" width="337" height="462"/>
</imageView>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<viewLayoutGuide key="safeArea" id="gxu-Sr-0Za"/>
<color key="backgroundColor" red="1" green="0.57637232540000005" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="f3T-nC-cwA" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="4le-ih-K34"/>
<constraint firstAttribute="bottom" secondItem="bZc-Ai-h3y" secondAttribute="bottom" constant="8" id="YBJ-eg-EmZ"/>
<constraint firstItem="bZc-Ai-h3y" firstAttribute="top" relation="greaterThanOrEqual" secondItem="f3T-nC-cwA" secondAttribute="bottom" constant="16" id="av5-zS-GLQ"/>
<constraint firstItem="bZc-Ai-h3y" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="eNj-fx-een"/>
<constraint firstItem="f3T-nC-cwA" firstAttribute="centerY" secondItem="gTV-IL-0wX" secondAttribute="centerY" priority="250" id="haX-eS-EOe"/>
<constraint firstAttribute="trailing" secondItem="bZc-Ai-h3y" secondAttribute="trailing" constant="8" id="uif-cW-sAI"/>
<constraint firstItem="0Rr-r4-4Vb" firstAttribute="top" secondItem="W7v-l7-ZRn" secondAttribute="top" id="6WN-hZ-AN9"/>
<constraint firstAttribute="trailing" secondItem="0Rr-r4-4Vb" secondAttribute="trailing" id="QXs-dx-A3z"/>
<constraint firstAttribute="trailing" secondItem="Hg2-1f-a5q" secondAttribute="trailing" constant="8" id="aAC-jn-k9B"/>
<constraint firstItem="0Rr-r4-4Vb" firstAttribute="centerX" secondItem="W7v-l7-ZRn" secondAttribute="centerX" id="aII-UM-z5q"/>
<constraint firstAttribute="bottom" secondItem="Hg2-1f-a5q" secondAttribute="bottom" constant="8" id="eji-6u-PTG"/>
<constraint firstAttribute="bottom" secondItem="0Rr-r4-4Vb" secondAttribute="bottom" id="rt9-yh-5MB"/>
<constraint firstItem="0Rr-r4-4Vb" firstAttribute="leading" secondItem="W7v-l7-ZRn" secondAttribute="leading" id="tge-XP-XUp"/>
<constraint firstItem="Hg2-1f-a5q" firstAttribute="leading" secondItem="W7v-l7-ZRn" secondAttribute="leading" constant="8" id="trc-Dm-XnV"/>
</constraints>
<size key="customSize" width="337" height="428"/>
<connections>
<outlet property="imageView" destination="f3T-nC-cwA" id="aRR-4x-Dwk"/>
<outlet property="titleLabel" destination="bZc-Ai-h3y" id="WAd-FO-VtY"/>
<outlet property="imageView" destination="0Rr-r4-4Vb" id="1bz-Zu-mk7"/>
<outlet property="titleLabel" destination="Hg2-1f-a5q" id="K6V-hD-bwj"/>
</connections>
<point key="canvasLocation" x="339.85507246376812" y="223.66071428571428"/>
</collectionViewCell>
</objects>
<resources>
<image name="intro1" width="256" height="128"/>
<image name="introSlide1" width="375" height="667"/>
</resources>
</document>
65 changes: 60 additions & 5 deletions Brand/Intro/NCIntroViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//

import UIKit
import NextcloudKit

class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {

Expand All @@ -32,19 +33,26 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
@IBOutlet weak var buttonHost: UIButton!
@IBOutlet weak var introCollectionView: UICollectionView!
@IBOutlet weak var pageControl: UIPageControl!
@IBOutlet weak var contstraintBottomLoginButton: NSLayoutConstraint!

@objc weak var delegate: NCIntroViewController?
private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
private let titles = [NSLocalizedString("_intro_1_title_", comment: ""), NSLocalizedString("_intro_2_title_", comment: ""), NSLocalizedString("_intro_3_title_", comment: ""), NSLocalizedString("_intro_4_title_", comment: "")]
private let images = [UIImage(named: "intro1"), UIImage(named: "intro2"), UIImage(named: "intro3"), UIImage(named: "intro4")]
private let titles = [NSLocalizedString("", comment: ""), NSLocalizedString("", comment: ""), NSLocalizedString("", comment: "")]
private var images:[UIImage?] = []
private var timerAutoScroll: Timer?
private var textColor: UIColor = .white
private var textColorOpponent: UIColor = .black
private let imagesLandscape = [UIImage(named: "introSlideLand1"), UIImage(named: "introSlideLand2"), UIImage(named: "introSlideLand3")]
private let imagesPortrait = [UIImage(named: "introSlide1"), UIImage(named: "introSlide2"), UIImage(named: "introSlide3")]
private let imagesEightPortrait = [UIImage(named: "introSlideEight1"), UIImage(named: "introSlideEight2"), UIImage(named: "introSlideEight3")]

// MARK: - View Life Cycle

override func viewDidLoad() {
super.viewDidLoad()

let isEightPlusDevice = UIScreen.main.bounds.height == 736
images = UIDevice.current.orientation.isLandscape ? imagesLandscape : (isEightPlusDevice ? imagesEightPortrait : imagesPortrait)

let isTooLight = NCBrandColor.shared.customer.isTooLight()
let isTooDark = NCBrandColor.shared.customer.isTooDark()
Expand All @@ -71,7 +79,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
pageControl.currentPageIndicatorTintColor = textColor
pageControl.pageIndicatorTintColor = .lightGray

buttonLogin.layer.cornerRadius = 20
buttonLogin.layer.cornerRadius = 4
buttonLogin.setTitleColor(NCBrandColor.shared.customer, for: .normal)
buttonLogin.backgroundColor = textColor
buttonLogin.setTitle(NSLocalizedString("_log_in_", comment: ""), for: .normal)
Expand All @@ -97,6 +105,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol

view.backgroundColor = NCBrandColor.shared.customer
timerAutoScroll = Timer.scheduledTimer(timeInterval: 5, target: self, selector: (#selector(NCIntroViewController.autoScroll)), userInfo: nil, repeats: true)
NotificationCenter.default.addObserver(self, selector: #selector(resetPageController(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
}

override var preferredStatusBarStyle: UIStatusBarStyle {
Expand All @@ -107,14 +116,38 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
}
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if (UIDevice.current.userInterfaceIdiom != .pad){
AppUtility.lockOrientation(UIInterfaceOrientationMask.portrait, andRotateTo: UIInterfaceOrientation.portrait)
}
navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewDidLayoutSubviews() {
if UIScreen.main.bounds.width < 350 || UIScreen.main.bounds.height > 800 {
contstraintBottomLoginButton.constant = 15
}
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
timerAutoScroll?.invalidate()
AppUtility.lockOrientation(UIInterfaceOrientationMask.all)
navigationController?.setNavigationBarHidden(false, animated: animated)
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
let isEightPlusDevice = UIScreen.main.bounds.height == 736
images = UIDevice.current.orientation.isLandscape ? imagesLandscape : (isEightPlusDevice ? imagesEightPortrait : imagesPortrait)
pageControl.currentPage = 0
introCollectionView.collectionViewLayout.invalidateLayout()
self.introCollectionView.reloadData()
}

@objc func resetPageController(_ notification: NSNotification){
pageControl.currentPage = 0
introCollectionView.scrollToItem(at: IndexPath(row: pageControl.currentPage, section: 0), at: .centeredHorizontally, animated: true)
}

@objc func autoScroll() {
Expand All @@ -141,6 +174,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
cell.titleLabel.textColor = textColor
cell.titleLabel.text = titles[indexPath.row]
cell.imageView.image = images[indexPath.row]
cell.imageView.contentMode = .scaleAspectFill
return cell
}

Expand All @@ -150,15 +184,36 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
timerAutoScroll = Timer.scheduledTimer(timeInterval: 5, target: self, selector: (#selector(NCIntroViewController.autoScroll)), userInfo: nil, repeats: true)
pageControl.currentPage = Int(scrollView.contentOffset.x) / Int(scrollView.frame.width)
let page = Int(scrollView.contentOffset.x) / Int(scrollView.frame.width)
if pageControl.currentPage == (images.count - 1), pageControl.currentPage <= page {
pageControl.currentPage = 0
introCollectionView.scrollToItem(at: IndexPath(row: pageControl.currentPage, section: 0), at: .centeredHorizontally, animated: false)
} else {
pageControl.currentPage = Int(scrollView.contentOffset.x) / Int(scrollView.frame.width)
}
}

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
timerAutoScroll?.invalidate()
}

@IBAction func login(_ sender: Any) {
appDelegate.openLogin(viewController: navigationController, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
if NCBrandOptions.shared.use_AppConfig == true {
let loginViewPage = UIStoryboard(name: "NCLogin", bundle: Bundle.main).instantiateViewController(identifier: "NCLogin")
navigationController?.pushViewController(loginViewPage, animated: true)
} else {
if NextcloudKit.shared.isNetworkReachable() {
appDelegate.openLogin(viewController: navigationController, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
} else {
showNoInternetAlert()
}
}
}

func showNoInternetAlert(){
let alertController = UIAlertController(title: NSLocalizedString("_no_internet_alert_title_", comment: ""), message: NSLocalizedString("_no_internet_alert_message_", comment: ""), preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in }))
self.present(alertController, animated: true)
}

@IBAction func signup(_ sender: Any) {
Expand Down
Loading