-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️ Add new demo project and restructure repository
The repository was initially only supposed to house the "Demo-ShazamKit" project, but it would have been a hassle to have a repository for each demo project I make. I restructured it to make it more flexible and accommodate new projects in the future, including the new "Animate UICollectionViewCell highlight" playground in the "Swift Tips" directory. Having the prefix "Demo-" in front of every project name was unuseful. I renamed "Demo-ShazamKit" to its future associated article "ShazamKit - A first look". I also put it in the "Swift" directory. The repository's README.md needs to include a link to every project, organised by type, to make it easily accessible to users. I added these links and associated them with a date. That date would either be the date of publication or, when available, the date of publication of their corresponding article. Every project needs its README.md file to disclose corresponding articles, availability and frameworks used. I added the file to the two projects with the link to the article commented out before it is published. Projects in the "Swift Tips" category also have a preview video in that file.
- Loading branch information
Showing
42 changed files
with
170 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.DS_Store | ||
xcuserdata/ | ||
xcuserdata/ | ||
timeline.xctimeline | ||
playground.xcworkspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# Demo-ShazamKit | ||
# Demo Projects | ||
|
||
*Updated for Xcode 13 beta 2.* | ||
|
||
<!-- | ||
This demo project is associated with my article [ShazamKit: A first look](https://yaacoub.github.io/articles/swift/shazamkit-a-first-look/). | ||
A collection of all the demo projects I made. | ||
<br> | ||
--> | ||
It is built using SwiftUI and ShazamKit. | ||
Most of them are associated with an article I published on my website. | ||
|
||
## Swift | ||
|
||
- 2021/07/28 - [ShazamKit: A first look](<Swift/ShazamKit - A first look>) | ||
|
||
## Swift Tips | ||
|
||
- 2021/07/28 - [Animate UICollectionViewCell highlight](<Swift Tips/Animate UICollectionViewCell highlight>) |
81 changes: 81 additions & 0 deletions
81
...ectionViewCell highlight/Animate UICollectionViewCell highlight.playground/Contents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import UIKit | ||
import PlaygroundSupport | ||
|
||
|
||
|
||
//MARK:- View Controller | ||
|
||
class CollectionViewController: UICollectionViewController { | ||
|
||
|
||
|
||
//MARK:- Override Methods | ||
|
||
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) | ||
cell.backgroundColor = .systemPink | ||
cell.layer.cornerRadius = 25 | ||
return cell | ||
} | ||
|
||
override func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) { | ||
let cell = collectionView.cellForItem(at: indexPath) | ||
UIView.animate(withDuration: 0.5, delay: 0, options: .beginFromCurrentState, animations: { | ||
cell?.transform = CGAffineTransform(scaleX: 0.90, y: 0.90) | ||
}) | ||
} | ||
|
||
override func collectionView(_ collectionView: UICollectionView, didUnhighlightItemAt indexPath: IndexPath) { | ||
let cell = collectionView.cellForItem(at: indexPath) | ||
UIView.animate(withDuration: 0.5, delay: 0, options: .beginFromCurrentState, animations: { | ||
cell?.transform = .identity | ||
}) | ||
} | ||
|
||
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
return 12 | ||
} | ||
|
||
override func numberOfSections(in collectionView: UICollectionView) -> Int { | ||
return 1 | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setup() | ||
} | ||
|
||
|
||
|
||
//MARK:- Private Methods | ||
|
||
private func setup() { | ||
collectionView.backgroundColor = .white | ||
collectionView.delaysContentTouches = false | ||
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell") | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
//MARK:- Extensions | ||
|
||
extension CollectionViewController: UICollectionViewDelegateFlowLayout { | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { | ||
return UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
let size = (Int(collectionView.frame.width) - 10) / 3 - 2 * 10 | ||
return CGSize(width: size, height: size) | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
//MARK:- Live View | ||
|
||
PlaygroundPage.current.liveView = CollectionViewController(collectionViewLayout: UICollectionViewFlowLayout()) |
4 changes: 4 additions & 0 deletions
4
...iewCell highlight/Animate UICollectionViewCell highlight.playground/contents.xcplayground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' executeOnSourceChanges='true' importAppTypes='true'> | ||
<timeline fileName='timeline.xctimeline'/> | ||
</playground> |
17 changes: 17 additions & 0 deletions
17
Swift Tips/Animate UICollectionViewCell highlight/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Animate UICollectionViewCell highlight | ||
|
||
<!-- This demo project is associated with my article [Animate UICollectionViewCell highlight](https://yaacoub.github.io/articles/swift-tips/animate-uicollectionviewcell-highlight/). --> | ||
|
||
### Availability | ||
|
||
Xcode 13.0+ (Beta) | ||
|
||
### Frameworks | ||
|
||
PlaygroundSupport | ||
<br> | ||
UIKit | ||
|
||
<br> | ||
|
||
https://user-images.githubusercontent.com/34966652/125084746-8b509480-e0d2-11eb-8828-edd50fbe6415.mov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# ShazamKit: A first look | ||
|
||
<!-- This demo project is associated with my article [ShazamKit: A first look](https://yaacoub.github.io/articles/swift/shazamkit-a-first-look/). --> | ||
|
||
### Availability | ||
|
||
iOS 15.0+ (Beta) | ||
<br> | ||
Xcode 13.0+ (Beta) | ||
|
||
### Frameworks | ||
|
||
Foundation | ||
<br> | ||
ShazamKit | ||
<br> | ||
SwiftUI |
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...irst look/ShazamKit - A first look.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.