Skip to content

Commit

Permalink
⭐️ Add new demo project and restructure repository
Browse files Browse the repository at this point in the history
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
Yaacoub committed Jul 9, 2021
1 parent 5cde96f commit 78153e2
Show file tree
Hide file tree
Showing 42 changed files with 170 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
xcuserdata/
xcuserdata/
timeline.xctimeline
playground.xcworkspace
18 changes: 11 additions & 7 deletions README.md
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>)
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())
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 Swift Tips/Animate UICollectionViewCell highlight/README.md
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
17 changes: 17 additions & 0 deletions Swift/ShazamKit - A first look/README.md
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.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
D0C0644E269707A600948EFE /* Demo_ShazamKitApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Demo_ShazamKitApp.swift; sourceTree = "<group>"; };
D0C0644F269707A600948EFE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
D0C06450269707A800948EFE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
D0C06455269707A800948EFE /* Demo-ShazamKit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Demo-ShazamKit.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D0C0645B269707A800948EFE /* Demo-ShazamKit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Demo-ShazamKit.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D0C06455269707A800948EFE /* ShazamKit - A first look.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ShazamKit - A first look.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D0C0645B269707A800948EFE /* ShazamKit - A first look.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ShazamKit - A first look.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D0C064752697094E00948EFE /* SongMatch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SongMatch.swift; sourceTree = "<group>"; };
D0C064772697094E00948EFE /* ContentViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentViewModel.swift; sourceTree = "<group>"; };
D0C064A02697100600948EFE /* Audio.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = Audio.mp3; sourceTree = "<group>"; };
Expand Down Expand Up @@ -78,8 +78,8 @@
D0C06456269707A800948EFE /* Products */ = {
isa = PBXGroup;
children = (
D0C06455269707A800948EFE /* Demo-ShazamKit.app */,
D0C0645B269707A800948EFE /* Demo-ShazamKit.app */,
D0C06455269707A800948EFE /* ShazamKit - A first look.app */,
D0C0645B269707A800948EFE /* ShazamKit - A first look.app */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -111,9 +111,9 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
D0C06454269707A800948EFE /* Demo-ShazamKit (iOS) */ = {
D0C06454269707A800948EFE /* ShazamKit - A first look (iOS) */ = {
isa = PBXNativeTarget;
buildConfigurationList = D0C06464269707A800948EFE /* Build configuration list for PBXNativeTarget "Demo-ShazamKit (iOS)" */;
buildConfigurationList = D0C06464269707A800948EFE /* Build configuration list for PBXNativeTarget "ShazamKit - A first look (iOS)" */;
buildPhases = (
D0C06451269707A800948EFE /* Sources */,
D0C06452269707A800948EFE /* Frameworks */,
Expand All @@ -123,14 +123,14 @@
);
dependencies = (
);
name = "Demo-ShazamKit (iOS)";
name = "ShazamKit - A first look (iOS)";
productName = "Demo-ShazamKit (iOS)";
productReference = D0C06455269707A800948EFE /* Demo-ShazamKit.app */;
productReference = D0C06455269707A800948EFE /* ShazamKit - A first look.app */;
productType = "com.apple.product-type.application";
};
D0C0645A269707A800948EFE /* Demo-ShazamKit (macOS) */ = {
D0C0645A269707A800948EFE /* ShazamKit - A first look (macOS) */ = {
isa = PBXNativeTarget;
buildConfigurationList = D0C06467269707A800948EFE /* Build configuration list for PBXNativeTarget "Demo-ShazamKit (macOS)" */;
buildConfigurationList = D0C06467269707A800948EFE /* Build configuration list for PBXNativeTarget "ShazamKit - A first look (macOS)" */;
buildPhases = (
D0C06457269707A800948EFE /* Sources */,
D0C06458269707A800948EFE /* Frameworks */,
Expand All @@ -140,9 +140,9 @@
);
dependencies = (
);
name = "Demo-ShazamKit (macOS)";
name = "ShazamKit - A first look (macOS)";
productName = "Demo-ShazamKit (macOS)";
productReference = D0C0645B269707A800948EFE /* Demo-ShazamKit.app */;
productReference = D0C0645B269707A800948EFE /* ShazamKit - A first look.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand All @@ -163,7 +163,7 @@
};
};
};
buildConfigurationList = D0C0644C269707A600948EFE /* Build configuration list for PBXProject "Demo-ShazamKit" */;
buildConfigurationList = D0C0644C269707A600948EFE /* Build configuration list for PBXProject "ShazamKit - A first look" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
Expand All @@ -176,8 +176,8 @@
projectDirPath = "";
projectRoot = "";
targets = (
D0C06454269707A800948EFE /* Demo-ShazamKit (iOS) */,
D0C0645A269707A800948EFE /* Demo-ShazamKit (macOS) */,
D0C06454269707A800948EFE /* ShazamKit - A first look (iOS) */,
D0C0645A269707A800948EFE /* ShazamKit - A first look (macOS) */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -356,7 +356,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
INFOPLIST_KEY_CFBundleDisplayName = ShazamKit;
INFOPLIST_KEY_CFBundleExecutable = "Demo-ShazamKit";
INFOPLIST_KEY_CFBundleExecutable = "ShazamKit---A-first-look";
INFOPLIST_KEY_CFBundleName = "Demo-ShazamKit";
INFOPLIST_KEY_CFBundleVersion = 1;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand All @@ -371,7 +371,7 @@
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.example.Demo-ShazamKit";
PRODUCT_NAME = "Demo-ShazamKit";
PRODUCT_NAME = "ShazamKit - A first look";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -394,7 +394,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
INFOPLIST_KEY_CFBundleDisplayName = ShazamKit;
INFOPLIST_KEY_CFBundleExecutable = "Demo-ShazamKit";
INFOPLIST_KEY_CFBundleExecutable = "ShazamKit---A-first-look";
INFOPLIST_KEY_CFBundleName = "Demo-ShazamKit";
INFOPLIST_KEY_CFBundleVersion = 1;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand All @@ -409,7 +409,7 @@
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.example.Demo-ShazamKit";
PRODUCT_NAME = "Demo-ShazamKit";
PRODUCT_NAME = "ShazamKit - A first look";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -433,6 +433,9 @@
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleExecutable = "ShazamKit - A first look";
INFOPLIST_KEY_CFBundleName = "ShazamKit - A first look";
INFOPLIST_KEY_CFBundleVersion = 1;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -441,7 +444,7 @@
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.example.Demo-ShazamKit";
PRODUCT_NAME = "Demo-ShazamKit";
PRODUCT_NAME = "ShazamKit - A first look";
SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -462,6 +465,9 @@
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleExecutable = "ShazamKit - A first look";
INFOPLIST_KEY_CFBundleName = "ShazamKit - A first look";
INFOPLIST_KEY_CFBundleVersion = 1;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -470,7 +476,7 @@
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.example.Demo-ShazamKit";
PRODUCT_NAME = "Demo-ShazamKit";
PRODUCT_NAME = "ShazamKit - A first look";
SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -480,7 +486,7 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
D0C0644C269707A600948EFE /* Build configuration list for PBXProject "Demo-ShazamKit" */ = {
D0C0644C269707A600948EFE /* Build configuration list for PBXProject "ShazamKit - A first look" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D0C06462269707A800948EFE /* Debug */,
Expand All @@ -489,7 +495,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D0C06464269707A800948EFE /* Build configuration list for PBXNativeTarget "Demo-ShazamKit (iOS)" */ = {
D0C06464269707A800948EFE /* Build configuration list for PBXNativeTarget "ShazamKit - A first look (iOS)" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D0C06465269707A800948EFE /* Debug */,
Expand All @@ -498,7 +504,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D0C06467269707A800948EFE /* Build configuration list for PBXNativeTarget "Demo-ShazamKit (macOS)" */ = {
D0C06467269707A800948EFE /* Build configuration list for PBXNativeTarget "ShazamKit - A first look (macOS)" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D0C06468269707A800948EFE /* Debug */,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 78153e2

Please sign in to comment.