Skip to content
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
134 changes: 60 additions & 74 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>
91 changes: 68 additions & 23 deletions Brand/Intro/NCIntroViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,35 @@
//

import UIKit
import NextcloudKit

class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
@IBOutlet weak var buttonLogin: UIButton!
@IBOutlet weak var buttonSignUp: UIButton!
@IBOutlet weak var buttonHost: UIButton!
@IBOutlet weak var introCollectionView: UICollectionView!
@IBOutlet weak var pageControl: UIPageControl!
@IBOutlet weak var contstraintBottomLoginButton: NSLayoutConstraint!

weak var delegate: NCIntroViewController?
/// Controller
var controller: NCMainTabBarController?

@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 var timer: Timer?
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 Down Expand Up @@ -79,7 +85,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 @@ -105,7 +111,8 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol

view.backgroundColor = NCBrandColor.shared.customer

self.timer = Timer.scheduledTimer(timeInterval: 4, target: self, selector: (#selector(self.autoScroll(_:))), userInfo: nil, repeats: true)
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 @@ -116,20 +123,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)

timer?.invalidate()
timer = nil
timerAutoScroll?.invalidate()
AppUtility.lockOrientation(UIInterfaceOrientationMask.all)
navigationController?.setNavigationBarHidden(false, animated: animated)
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)

coordinator.animate(alongsideTransition: nil) { _ in
self.pageControl?.currentPage = 0
self.introCollectionView?.collectionViewLayout.invalidateLayout()
}
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(_ sender: Any?) {
Expand All @@ -156,6 +181,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 @@ -164,8 +190,14 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
}

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
timer = Timer.scheduledTimer(timeInterval: 4, target: self, selector: (#selector(autoScroll(_:))), userInfo: nil, repeats: true)
pageControl.currentPage = Int(scrollView.contentOffset.x) / Int(scrollView.frame.width)
timerAutoScroll = Timer.scheduledTimer(timeInterval: 5, target: self, selector: (#selector(NCIntroViewController.autoScroll)), userInfo: nil, repeats: true)
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) {
Expand All @@ -180,11 +212,24 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
}

@IBAction func login(_ sender: Any) {
if let viewController = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLogin") as? NCLogin {
viewController.controller = self.controller
self.navigationController?.pushViewController(viewController, animated: true)
if NCBrandOptions.shared.use_AppConfig {
let loginViewPage = UIStoryboard(name: "NCLogin", bundle: Bundle.main).instantiateViewController(identifier: "NCLogin")
navigationController?.pushViewController(loginViewPage, animated: true)
} else {
if NextcloudKit.shared.isNetworkReachable() {
// appDelegate.openLogin(selector: NCGlobal.shared.introLogin)
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 signupWithProvider(_ sender: Any) {
if let viewController = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginProvider") as? NCLoginProvider {
Expand Down
Loading