Skip to content
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>
103 changes: 63 additions & 40 deletions Brand/Intro/NCIntroViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,34 @@
//

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?

@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 +78,7 @@
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,34 +104,7 @@

view.backgroundColor = NCBrandColor.shared.customer
timerAutoScroll = Timer.scheduledTimer(timeInterval: 5, target: self, selector: (#selector(NCIntroViewController.autoScroll)), userInfo: nil, repeats: true)

NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeUser), object: nil, queue: nil) { notification in
if let userInfo = notification.userInfo,
let account = userInfo["account"] as? String {
let window = UIApplication.shared.firstWindow
if let controller = window?.rootViewController as? NCMainTabBarController {
controller.account = account
self.dismiss(animated: true)
} else {
if let controller = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() as? NCMainTabBarController {
controller.account = account
controller.modalPresentationStyle = .fullScreen
controller.view.alpha = 0

window?.rootViewController = controller
window?.makeKeyAndVisible()

if let scene = window?.windowScene {
SceneManager.shared.register(scene: scene, withRootViewController: controller)
}

UIView.animate(withDuration: 0.5) {
controller.view.alpha = 1
}
}
}
}
}
NotificationCenter.default.addObserver(self, selector: #selector(resetPageController(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
}

override var preferredStatusBarStyle: UIStatusBarStyle {
Expand All @@ -135,17 +115,38 @@
}
}

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

Check failure on line 121 in Brand/Intro/NCIntroViewController.swift

View workflow job for this annotation

GitHub Actions / Build and Test

cannot find 'AppUtility' in scope
}
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)

Check failure on line 135 in Brand/Intro/NCIntroViewController.swift

View workflow job for this annotation

GitHub Actions / Build and Test

cannot find 'AppUtility' in scope
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() {
Expand All @@ -172,6 +173,7 @@
cell.titleLabel.textColor = textColor
cell.titleLabel.text = titles[indexPath.row]
cell.imageView.image = images[indexPath.row]
cell.imageView.contentMode = .scaleAspectFill
return cell
}

Expand All @@ -181,15 +183,36 @@

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(selector: NCGlobal.shared.introLogin)
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)
} 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
Loading