Skip to content

Commit

Permalink
tvOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
rafiki270 committed May 31, 2018
1 parent 50faa72 commit ea36f39
Show file tree
Hide file tree
Showing 98 changed files with 1,875 additions and 2,888 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

@_exported import Foundation
#if os(iOS) || os(tvOS)
@_exported import UIKit
#endif


extension GridView {
Expand Down Expand Up @@ -37,18 +39,6 @@ extension GridView {
drawColumnNumber(in: i, color: color)
}
}

// var y: CGFloat = 0
// for _ in 0...Int(rect.size.height / config.columnWidth) {
// let bezierPath = UIBezierPath()
// bezierPath.move(to: CGPoint(x: 0, y: y))
// bezierPath.addLine(to: CGPoint(x: bounds.size.width, y: y))
// color.setStroke()
// bezierPath.lineWidth = 1
// bezierPath.stroke()
//
// y += config.columnWidth
// }
}
}

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

@_exported import Foundation
#if os(iOS) || os(tvOS)
@_exported import UIKit
#endif


extension UIColor {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

@_exported import Foundation
#if os(iOS) || os(tvOS)
@_exported import UIKit
#endif


public protocol ScrollViewForwarder {
Expand All @@ -33,6 +35,29 @@ extension GridScrollView {
set { scrollView.contentInset = newValue }
}

#if os(iOS)

@available(iOS 5.0, *)
open var pinchGestureRecognizer: UIPinchGestureRecognizer? {
return scrollView.pinchGestureRecognizer
}

open var scrollsToTop: Bool {
get { return scrollView.scrollsToTop }
set { scrollView.scrollsToTop = newValue }
}

@available(iOS 10.0, *)
open var refreshControl: UIRefreshControl? {
get { return scrollView.refreshControl }
set { scrollView.refreshControl = newValue }
}

open var isPagingEnabled: Bool {
get { return scrollView.isPagingEnabled }
set { scrollView.isPagingEnabled = newValue }
}

@available(iOS 11.0, *)
open var adjustedContentInset: UIEdgeInsets {
return scrollView.adjustedContentInset
Expand Down Expand Up @@ -60,6 +85,37 @@ extension GridScrollView {
return scrollView.frameLayoutGuide
}

#elseif os(tvOS)

@available(tvOS 11.0, *)
open var adjustedContentInset: UIEdgeInsets {
return scrollView.adjustedContentInset
}


@available(tvOS 11.0, *)
open func adjustedContentInsetDidChange() {
scrollView.adjustedContentInsetDidChange()
}

@available(tvOS 11.0, *)
open var contentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentBehavior {
get { return scrollView.contentInsetAdjustmentBehavior }
set { scrollView.contentInsetAdjustmentBehavior = newValue }
}

@available(tvOS 11.0, *)
open var contentLayoutGuide: UILayoutGuide {
return scrollView.contentLayoutGuide
}

@available(tvOS 11.0, *)
open var frameLayoutGuide: UILayoutGuide {
return scrollView.frameLayoutGuide
}

#endif

weak open var delegate: UIScrollViewDelegate? {
get { return scrollView.delegate }
set { scrollView.delegate = newValue }
Expand All @@ -85,11 +141,6 @@ extension GridScrollView {
set { scrollView.alwaysBounceHorizontal = newValue }
}

open var isPagingEnabled: Bool {
get { return scrollView.isPagingEnabled }
set { scrollView.isPagingEnabled = newValue }
}

open var isScrollEnabled: Bool {
get { return scrollView.isScrollEnabled }
set { scrollView.isScrollEnabled = newValue }
Expand Down Expand Up @@ -209,21 +260,11 @@ extension GridScrollView {
return scrollView.isZoomBouncing
}

open var scrollsToTop: Bool {
get { return scrollView.scrollsToTop }
set { scrollView.scrollsToTop = newValue }
}

@available(iOS 5.0, *)
open var panGestureRecognizer: UIPanGestureRecognizer {
return scrollView.panGestureRecognizer
}

@available(iOS 5.0, *)
open var pinchGestureRecognizer: UIPinchGestureRecognizer? {
return scrollView.pinchGestureRecognizer
}

open var directionalPressGestureRecognizer: UIGestureRecognizer {
return scrollView.directionalPressGestureRecognizer
}
Expand All @@ -234,10 +275,4 @@ extension GridScrollView {
set { scrollView.keyboardDismissMode = newValue }
}

@available(iOS 10.0, *)
open var refreshControl: UIRefreshControl? {
get { return scrollView.refreshControl }
set { scrollView.refreshControl = newValue }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

@_exported import Foundation
#if os(iOS) || os(tvOS)
@_exported import UIKit
#endif


/// Grid view view controller
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions TheGrid/Views/GridView.swift → Classes/Views/GridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

@_exported import Foundation
#if os(iOS) || os(tvOS)
@_exported import UIKit
#endif


/// Grid view
Expand Down
14 changes: 5 additions & 9 deletions Hagrid Demo/View controllers/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
// Copyright © 2018 LiveUI. All rights reserved.
//

import UIKit
import TheGrid
import Modular
import Hagrid


class ViewController: GridScrollViewController {
Expand All @@ -34,17 +32,15 @@ class ViewController: GridScrollViewController {
make.height.equalTo(self.albumCover.snp.width)
}

let albumCoverRelation: Position = .relation(albumCover)

gridView.add(subview: albumTitleLabel, from: albumCoverRelation, space: .last, padding: .left(12))
gridView.add(subview: albumTitleLabel, from: .relation(albumCover), space: .last, padding: .left(12))

let subtitlesLast: Position = .custom { _ in
return self.gridView.bounds.size.width <= 414 ? .last : .reversed(2)
}

gridView.add(subview: artistLabel, .below(albumTitleLabel, margin: 2), from: albumCoverRelation, space: subtitlesLast, padding: .horizontal(left: 12, right: 0))
gridView.add(subview: artistLabel, .below(albumTitleLabel, margin: 2), from: .match(artistLabel), space: subtitlesLast, padding: .horizontal(left: 12, right: 0))

gridView.add(subview: yearLabel, .below(artistLabel, margin: 2), from: albumCoverRelation, space: subtitlesLast, padding: .horizontal(left: 12, right: 0))
gridView.add(subview: yearLabel, .below(artistLabel, margin: 2), from: .match(artistLabel), space: subtitlesLast, padding: .horizontal(left: 12, right: 0))

gridView.add(subview: purchaseButton, .custom({ _ in
if self.gridView.bounds.size.width <= 414 {
Expand Down Expand Up @@ -152,7 +148,7 @@ class ViewController: GridScrollViewController {
}

func setupNavBar() {
title = "HaGrid"
title = "Hagrid"

let columns = UISegmentedControl(items: ["12", "15", "18"])
columns.addTarget(self, action: #selector(selectColumns(_:)), for: .valueChanged)
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions Hagrid-tvOS/Supporting files/Hagrid_appleTV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Hagrid_appleTV.h
// Hagrid-appleTV
//
// Created by Ondrej Rafaj on 31/05/2018.
// Copyright © 2018 LiveUI. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for Hagrid_appleTV.
FOUNDATION_EXPORT double Hagrid_appleTVVersionNumber;

//! Project version string for Hagrid_appleTV.
FOUNDATION_EXPORT const unsigned char Hagrid_appleTVVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <Hagrid_appleTV/PublicHeader.h>


Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
41 changes: 41 additions & 0 deletions Hagrid.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Be sure to run `pod lib lint Reloaded.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
s.name = 'Hagrid'
s.version = '1.0.0'
s.summary = 'Brings proper grid layout to the Apple platforms!'
s.swift_version = '4.1'

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!

s.description = <<-DESC
Hagrid is a simple to use grid layout engine based on SnapKit. Written purely in swift and with a great amount of love!
DESC

s.homepage = 'https://github.com/LiveUI/Hagrid'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'rafiki270' => 'dev@liveui.io' }
s.source = { :git => 'https://github.com/LiveUI/Hagrid.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/rafiki270'

s.ios.deployment_target = '9.3'
s.tvos.deployment_target = '10.2'
#s.macos.deployment_target = '10.12'

s.source_files = 'Classes/**/*'

# s.public_header_files = 'Pod/Classes/**/*.h'
s.frameworks = 'UIKit'
s.dependency 'SnapKit', '~> 4.0.0'
end
Loading

0 comments on commit ea36f39

Please sign in to comment.