Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f6ff38a71 | |||
| e072b40ea5 | |||
| de1e60ee6b | |||
| f469bd70ab | |||
| 8d19bad3e9 | |||
| 689f0b1bfb | |||
| fcdf49d4a4 | |||
| 52b001769e | |||
| 09aa06bec1 | |||
| 35c8f76b22 | |||
| 249fd977e3 | |||
| f61639a53f | |||
| cebff16524 | |||
| 03d73775f2 | |||
| 3a45fcc386 | |||
| efc710363e |
+3
-3
@@ -1,7 +1,7 @@
|
||||
Pod::Spec.new do |spec|
|
||||
|
||||
spec.name = "Glideshow"
|
||||
spec.version = "1.0.0"
|
||||
spec.version = "1.1.1"
|
||||
spec.summary = "A slideshow written in Swift 5 that adds transitions to labels within a slide"
|
||||
|
||||
spec.description = <<-DESC
|
||||
@@ -12,8 +12,8 @@ Pod::Spec.new do |spec|
|
||||
spec.license = { :type => "MIT", :file => "LICENSE" }
|
||||
spec.author = { "Visal Rajapakse" => "visalrajapakse@gmail.com" }
|
||||
|
||||
spec.platform = :ios, "13.0"
|
||||
spec.ios.deployment_target = "13.0"
|
||||
spec.platform = :ios, "11.0"
|
||||
spec.ios.deployment_target = "11.0"
|
||||
spec.swift_version = "5"
|
||||
|
||||
spec.source = { :git => "https://github.com/v15a1/Glideshow.git", :tag => "#{spec.version}" }
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
4B0CF41A25EBD590005975B1 /* GlideCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B0CF41925EBD590005975B1 /* GlideCell.swift */; };
|
||||
4B3447F525F7CD6D00A713F2 /* ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3447F425F7CD6D00A713F2 /* ImageCache.swift */; };
|
||||
4BB22DFB25F7D35800B6FD9D /* ImageLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB22DFA25F7D35800B6FD9D /* ImageLoader.swift */; };
|
||||
6E82188B2666B6450012A2CD /* GlideCellTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E82188A2666B6450012A2CD /* GlideCellTests.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -78,6 +79,7 @@
|
||||
4B0CF41925EBD590005975B1 /* GlideCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlideCell.swift; sourceTree = "<group>"; };
|
||||
4B3447F425F7CD6D00A713F2 /* ImageCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCache.swift; sourceTree = "<group>"; };
|
||||
4BB22DFA25F7D35800B6FD9D /* ImageLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageLoader.swift; sourceTree = "<group>"; };
|
||||
6E82188A2666B6450012A2CD /* GlideCellTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlideCellTests.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -148,6 +150,7 @@
|
||||
children = (
|
||||
4B0739F425EB56BD003FF9C1 /* GlideshowTests.swift */,
|
||||
4B0739F625EB56BD003FF9C1 /* Info.plist */,
|
||||
6E82188A2666B6450012A2CD /* GlideCellTests.swift */,
|
||||
);
|
||||
path = GlideshowTests;
|
||||
sourceTree = "<group>";
|
||||
@@ -329,6 +332,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4B0739F525EB56BD003FF9C1 /* GlideshowTests.swift in Sources */,
|
||||
6E82188B2666B6450012A2CD /* GlideCellTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
BIN
Binary file not shown.
@@ -140,7 +140,7 @@ class GlideCell: UICollectionViewCell {
|
||||
}()
|
||||
|
||||
/// Spacing between labels of the slide. Default value : 8
|
||||
public var labelSpacing : CGFloat!
|
||||
public var labelSpacing : CGFloat = 8
|
||||
|
||||
/// Animateable GlideLabels for gliding
|
||||
public var animateableViews : [GlideLabel]?
|
||||
@@ -152,14 +152,14 @@ class GlideCell: UICollectionViewCell {
|
||||
}
|
||||
}
|
||||
|
||||
/// glide factor for the description lable. Default: 2
|
||||
/// glide factor for the description lable. Default: 3
|
||||
public var descriptionGlideFactor : CGFloat = 3 {
|
||||
didSet{
|
||||
slideDescription.glideFactor = titleGlideFactor
|
||||
}
|
||||
}
|
||||
|
||||
/// glide factor for the title lable. Default: 2
|
||||
/// glide factor for the title lable. Default: 1
|
||||
public var captionGlideFactor : CGFloat = 1 {
|
||||
didSet{
|
||||
slideCaption.glideFactor = titleGlideFactor
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
// Magic number used to give the user the feeling they are able to swipe infinitely
|
||||
fileprivate let kInifiniteSwipingMultiplier = 55
|
||||
|
||||
@objc
|
||||
/// The delegate protocol that notifies slideshow state changes
|
||||
public protocol GlideshowProtocol : AnyObject {
|
||||
@@ -463,7 +466,7 @@ public class Glideshow: UIView {
|
||||
extension Glideshow : UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return (items?.count ?? 0) * (isCircular ? 55 : 1)
|
||||
return (items?.count ?? 0) * (isCircular ? kInifiniteSwipingMultiplier : 1)
|
||||
}
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
@@ -573,6 +576,7 @@ extension Glideshow : UICollectionViewDelegate, UICollectionViewDataSource, UICo
|
||||
}
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
delegate?.glideshowDidSelecteRowAt?(indexPath: indexPath, self)
|
||||
let index = IndexPath(item: ((pageByMidSection) % items!.count), section: 0)
|
||||
delegate?.glideshowDidSelecteRowAt?(indexPath: index, self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "dish_default_image.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
@@ -34,8 +34,9 @@ class ViewController: UIViewController {
|
||||
GlideItem(caption : "Hello in Chinese",title : "你好", description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", backgroundImage: #imageLiteral(resourceName: "image7")),
|
||||
GlideItem(caption : "Hello in Thai",title : "สวัสดี", description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.", backgroundImage: #imageLiteral(resourceName: "image9"))
|
||||
]
|
||||
glideshow.delegate = self
|
||||
glideshow.isCircular = true
|
||||
glideshow.placeHolderImage = #imageLiteral(resourceName: "placeholder")
|
||||
glideshow.placeHolderImage = #imageLiteral(resourceName: "dish_default_image")
|
||||
glideshow.gradientColor =
|
||||
UIColor.black.withAlphaComponent(0.8)
|
||||
glideshow.captionFont = UIFont.systemFont(ofSize: 16, weight: .light)
|
||||
@@ -57,3 +58,13 @@ class ViewController: UIViewController {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extension ViewController : GlideshowProtocol {
|
||||
func glideshowDidSelecteRowAt(indexPath: IndexPath, _ glideshow: Glideshow) {
|
||||
print(indexPath)
|
||||
}
|
||||
|
||||
func pageDidChange(_ glideshow: Glideshow, didChangePageTo page: Int) {
|
||||
print(page)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// GlideCellTests.swift
|
||||
// GlideshowTests
|
||||
//
|
||||
// Created by Jesus Andres Bernal Lopez on 6/1/21.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Glideshow
|
||||
|
||||
class GlideCellTests: XCTestCase {
|
||||
|
||||
func test_configureWithBackgroundImage() {
|
||||
let cell = GlideCell()
|
||||
|
||||
let testItem = GlideItem(caption: "a-caption", title: "a-title", description: "a-description", backgroundImage: UIImage.checkmark)
|
||||
|
||||
cell.configure(with: testItem, placeholderImage: nil)
|
||||
|
||||
XCTAssertEqual(cell.slideCaption.text, testItem.caption)
|
||||
XCTAssertEqual(cell.slideTitle.text, testItem.title)
|
||||
XCTAssertEqual(cell.slideDescription.text, testItem.description)
|
||||
XCTAssertEqual(cell.backgroundImage, testItem.backgroundImage)
|
||||
}
|
||||
|
||||
func test_configureWithImageURL() {
|
||||
let cell = GlideCell()
|
||||
|
||||
let testItem = GlideItem(caption: "a-caption", title: "a-title", description: "a-description", imageURL: "a-url")
|
||||
|
||||
let placeholderImage = UIImage.checkmark
|
||||
|
||||
cell.configure(with: testItem, placeholderImage: placeholderImage)
|
||||
|
||||
XCTAssertEqual(cell.slideCaption.text, testItem.caption)
|
||||
XCTAssertEqual(cell.slideTitle.text, testItem.title)
|
||||
XCTAssertEqual(cell.slideDescription.text, testItem.description)
|
||||
XCTAssertEqual(cell.backgroundImage, placeholderImage)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,4 +13,102 @@ class GlideshowTests: XCTestCase {
|
||||
override func setUp() {
|
||||
glideshow = Glideshow()
|
||||
}
|
||||
|
||||
func test_interval() {
|
||||
XCTAssertEqual(glideshow.interval, 0)
|
||||
}
|
||||
|
||||
func test_slideMargin() {
|
||||
XCTAssertEqual(glideshow.slideMargin, UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20))
|
||||
}
|
||||
|
||||
func test_slidePadding() {
|
||||
XCTAssertEqual(glideshow.slidePadding, UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20))
|
||||
}
|
||||
|
||||
func test_defaultSldeColor() {
|
||||
XCTAssertEqual(glideshow.defaultSlideColor, .lightGray)
|
||||
}
|
||||
|
||||
func test_placeHolderImage() {
|
||||
XCTAssertEqual(glideshow.placeHolderImage, nil)
|
||||
}
|
||||
|
||||
func test_labelSpacing() {
|
||||
XCTAssertEqual(glideshow.labelSpacing, 8)
|
||||
}
|
||||
|
||||
func test_isGradientEnabled() {
|
||||
XCTAssertEqual(glideshow.isGradientEnabled, false)
|
||||
}
|
||||
|
||||
func test_titleFont() {
|
||||
XCTAssertEqual(glideshow.titleFont, UIFont.systemFont(ofSize: 20, weight: .black))
|
||||
}
|
||||
|
||||
func test_descriptionGlideFactor() {
|
||||
XCTAssertEqual(glideshow.descriptionGlideFactor, 3)
|
||||
}
|
||||
|
||||
func test_titleGlideFactor() {
|
||||
XCTAssertEqual(glideshow.titleGlideFactor, 2)
|
||||
}
|
||||
|
||||
func test_captionGlideFactor() {
|
||||
XCTAssertEqual(glideshow.captionGlideFactor, 1)
|
||||
}
|
||||
|
||||
func test_descriptionFont() {
|
||||
XCTAssertEqual(glideshow.descriptionFont, UIFont.systemFont(ofSize: 16, weight: .regular))
|
||||
}
|
||||
|
||||
func test_captionFont() {
|
||||
XCTAssertEqual(glideshow.captionFont, UIFont.systemFont(ofSize: 14, weight: .light))
|
||||
}
|
||||
|
||||
func test_titleColor() {
|
||||
XCTAssertEqual(glideshow.titleColor, .white)
|
||||
}
|
||||
|
||||
func test_descriptionColor() {
|
||||
XCTAssertEqual(glideshow.descriptionColor, .white)
|
||||
}
|
||||
|
||||
func test_captionColor() {
|
||||
XCTAssertEqual(glideshow.captionColor, .white)
|
||||
}
|
||||
|
||||
func test_gradientColor() {
|
||||
XCTAssertEqual(glideshow.gradientColor, UIColor.black.withAlphaComponent(0.6))
|
||||
XCTAssertEqual(glideshow.isGradientEnabled, false)
|
||||
|
||||
glideshow.gradientColor = .orange
|
||||
|
||||
XCTAssertEqual(glideshow.gradientColor, .orange)
|
||||
XCTAssertEqual(glideshow.isGradientEnabled, true)
|
||||
}
|
||||
|
||||
func test_gradientHeightFactor() {
|
||||
XCTAssertEqual(glideshow.gradientHeightFactor, 0.5)
|
||||
XCTAssertEqual(glideshow.isGradientEnabled, false)
|
||||
|
||||
glideshow.gradientHeightFactor = 0.8
|
||||
|
||||
XCTAssertEqual(glideshow.gradientHeightFactor, 0.8)
|
||||
XCTAssertEqual(glideshow.isGradientEnabled, true)
|
||||
|
||||
}
|
||||
|
||||
func test_pageIndicator() {
|
||||
XCTAssertEqual(glideshow.pageIndicator!.pageIndicatorTintColor, .lightGray)
|
||||
XCTAssertEqual(glideshow.pageIndicator!.currentPageIndicatorTintColor, .darkGray)
|
||||
XCTAssertEqual(glideshow.pageIndicator!.numberOfPages, 0)
|
||||
|
||||
glideshow.items = [
|
||||
GlideItem(caption: "", title: "", description: "", backgroundImage: UIImage.checkmark),
|
||||
GlideItem(caption: "", title: "", description: "", backgroundImage: UIImage.checkmark)
|
||||
]
|
||||
|
||||
XCTAssertEqual(glideshow.pageIndicator!.numberOfPages, 2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||

|
||||
|
||||
# Glideshow
|
||||
[](https://shields.io/) [](https://shields.io/) [](https://shields.io/) [](https://shields.io/)
|
||||
[](https://shields.io/) [](https://shields.io/) [](https://shields.io/) [](https://shields.io/)
|
||||
|
||||
A slideshow with *pizzazz!* Glideshow adds transitions to the slideshows labels to set it apart from conventional slideshows
|
||||
A slideshow with *pizzazz!* Glideshow adds transitions to the slideshows labels to set it apart from other conventional "boring" slideshows,
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
@@ -42,6 +41,8 @@ glideshow.items = [
|
||||
GlideItem(description: "General Kenobi!", backgroundImage: UIImage(named: "image2")),
|
||||
GlideItem(title : "Hello there", backgroundImage: UIImage(named: "image3")),
|
||||
GlideItem(title : "Hello there", description: "General Kenobi!")
|
||||
// Network images
|
||||
GlideItem(caption : "Hello there", description: "General Kenobi!", imageURL: "[ IMAGE URL ]")
|
||||
]
|
||||
|
||||
```
|
||||
@@ -67,14 +68,27 @@ The behaviour is configurable by the following properties
|
||||
| `titleColor` | Sets the `textColor` of the slide title |
|
||||
| `descriptionColor` | Sets the `textColor` of the slide description |
|
||||
| `captionColor` | Sets the `textColor` of the slide slide caption |
|
||||
| `titleGlideFactor` | Configures the speed of the transition of the title label ( Default 3 ) |
|
||||
| `titleGlideFactor` | Configures the speed of the transition of the title label ( Default 2 ) |
|
||||
| `descriptionGlideFactor` | Configures the speed of the transition of the description label ( Default 3 ) |
|
||||
| `captionGlideFactor` | Configures the speed of the transition of the caption label ( Default 3 ) |
|
||||
| `captionGlideFactor` | Configures the speed of the transition of the caption label ( Default 1 ) |
|
||||
| `pageIndicatorPosition` | Configures positon of the pge indicator |
|
||||
| `placeHolderImage` | Configures slide background placeholder if a URL is specified, else `nil` |
|
||||
|
||||
### Work in Progress
|
||||
### Contributions
|
||||
|
||||
* Support for Network images
|
||||
* Multiple animations
|
||||
A few issue to tackle
|
||||
- [ ] Pass slide data through delegates
|
||||
- [x] Support for Network images
|
||||
- [ ] Multiple animations
|
||||
- [ ] Customizable label positionings
|
||||
- [ ] Code optimizations
|
||||
|
||||
Steps to contribution:
|
||||
|
||||
1. Fork the repo
|
||||
2. Clone the project
|
||||
3. Make your changes
|
||||
4. Make a pull request
|
||||
|
||||
If you have any question please feel free to open an issue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user