Skip to content

Commit

Permalink
Workshop background view working with example
Browse files Browse the repository at this point in the history
  • Loading branch information
noahsark769 committed Dec 10, 2018
1 parent 48ae3d7 commit 09afe5d
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 12 deletions.
Binary file modified designs.sketch
Binary file not shown.
16 changes: 16 additions & 0 deletions iOS/CIFilter.io.xcodeproj/project.pbxproj
Expand Up @@ -11,6 +11,8 @@
A11C522521968BB000045F2E /* FilterListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A11C522421968BB000045F2E /* FilterListViewController.swift */; };
A1707F66219A1A0A0010E007 /* FilterInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1707F65219A1A0A0010E007 /* FilterInfo.swift */; };
A1A0D83521BC60BA0098168C /* FilterExampleProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1A0D83421BC60BA0098168C /* FilterExampleProvider.swift */; };
A1A0D83721BC659B0098168C /* FilterDetailExampleHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1A0D83621BC659B0098168C /* FilterDetailExampleHeaderView.swift */; };
A1A0D83A21BC67ED0098168C /* FilterWorkshopViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1A0D83921BC67ED0098168C /* FilterWorkshopViewController.swift */; };
A1C6621D2196818100826A2B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C6621C2196818100826A2B /* AppDelegate.swift */; };
A1C662242196818300826A2B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A1C662232196818300826A2B /* Assets.xcassets */; };
A1C662272196818300826A2B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A1C662252196818300826A2B /* LaunchScreen.storyboard */; };
Expand Down Expand Up @@ -42,6 +44,8 @@
A11C522421968BB000045F2E /* FilterListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterListViewController.swift; sourceTree = "<group>"; };
A1707F65219A1A0A0010E007 /* FilterInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterInfo.swift; sourceTree = "<group>"; };
A1A0D83421BC60BA0098168C /* FilterExampleProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterExampleProvider.swift; sourceTree = "<group>"; };
A1A0D83621BC659B0098168C /* FilterDetailExampleHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterDetailExampleHeaderView.swift; sourceTree = "<group>"; };
A1A0D83921BC67ED0098168C /* FilterWorkshopViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterWorkshopViewController.swift; sourceTree = "<group>"; };
A1C662192196818100826A2B /* CIFilter.io.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CIFilter.io.app; sourceTree = BUILT_PRODUCTS_DIR; };
A1C6621C2196818100826A2B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A1C662232196818300826A2B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,6 +105,14 @@
name = Frameworks;
sourceTree = "<group>";
};
A1A0D83821BC67C60098168C /* Filter Workshop */ = {
isa = PBXGroup;
children = (
A1A0D83921BC67ED0098168C /* FilterWorkshopViewController.swift */,
);
path = "Filter Workshop";
sourceTree = "<group>";
};
A1C662102196818100826A2B = {
isa = PBXGroup;
children = (
Expand All @@ -125,6 +137,7 @@
A1D5A8C921B48FB700257B5E /* Filter Detail */,
A1D5A8A921ADB30300257B5E /* Filter Info */,
A1D5A8B621AF033700257B5E /* Filter List */,
A1A0D83821BC67C60098168C /* Filter Workshop */,
A1D5A8B921AF03ED00257B5E /* Utils */,
A1C6621C2196818100826A2B /* AppDelegate.swift */,
A1C662232196818300826A2B /* Assets.xcassets */,
Expand Down Expand Up @@ -185,6 +198,7 @@
isa = PBXGroup;
children = (
A1D5A8D021B49E5400257B5E /* FilterAvailabilityView.swift */,
A1A0D83621BC659B0098168C /* FilterDetailExampleHeaderView.swift */,
A1D5A8CC21B4900400257B5E /* FilterDetailTitleView.swift */,
A1D5A8CA21B48FDD00257B5E /* FilterDetailView.swift */,
A1D5A8CE21B493A200257B5E /* FilterDetailViewController.swift */,
Expand Down Expand Up @@ -297,6 +311,7 @@
A1D5A8D121B49E5400257B5E /* FilterAvailabilityView.swift in Sources */,
A1D5A8B821AF034A00257B5E /* FilterCategoryHeaderView.swift in Sources */,
A1D5A8C821B0FECF00257B5E /* FilterCellModel.swift in Sources */,
A1A0D83721BC659B0098168C /* FilterDetailExampleHeaderView.swift in Sources */,
A1D5A8CD21B4900400257B5E /* FilterDetailTitleView.swift in Sources */,
A1D5A8CB21B48FDD00257B5E /* FilterDetailView.swift in Sources */,
A1D5A8CF21B493A200257B5E /* FilterDetailViewController.swift in Sources */,
Expand All @@ -310,6 +325,7 @@
A1D5A8AB21ADB31400257B5E /* FilterParameterInfo.swift in Sources */,
A1D5A8AD21ADB33300257B5E /* FilterParameterType.swift in Sources */,
A1D5A8D721B4A85A00257B5E /* FilterParameterView.swift in Sources */,
A1A0D83A21BC67ED0098168C /* FilterWorkshopViewController.swift in Sources */,
A1D5A8B521ADB3ED00257B5E /* ParameterData.swift in Sources */,
A1D5A8C321B054A100257B5E /* SeparatorView.swift in Sources */,
A1D5A8BF21AF0F8200257B5E /* UIColor+Utils.swift in Sources */,
Expand Down
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "workshop-background.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "workshop-background@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "workshop-background@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions iOS/CIFilter.io/Filter Detail/FilterDetailExampleHeaderView.swift
@@ -0,0 +1,65 @@
//
// FilterDetailExampleHeaderView.swift
// CIFilter.io
//
// Created by Noah Gilmore on 12/8/18.
// Copyright © 2018 Noah Gilmore. All rights reserved.
//

import UIKit

final class FilterDetailExampleHeaderView: UIView {
private var tryHandler: (() -> Void)? = nil
private let exampleLabel: UILabel = {
let view = UILabel()
view.font = UIFont.boldSystemFont(ofSize: 14)
view.textColor = UIColor(rgb: 0xF5BD5D)
view.text = "EXAMPLE"
return view
}()

private lazy var tryItButton: UIButton = {
let view = UIButton(type: .custom)
view.setAttributedTitle(
NSAttributedString(
string: "Try it!",
attributes: [
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 14),
NSAttributedString.Key.foregroundColor: UIColor(rgb: 0x80a5b1),
NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue
]
),
for: .normal
)
view.setTitleColor(UIColor(rgb: 0x80a5b1), for: .normal)
view.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
return view
}()

init() {
super.init(frame: .zero)

addSubview(exampleLabel)
addSubview(tryItButton)

[exampleLabel, tryItButton].disableTranslatesAutoresizingMaskIntoConstraints()

tryItButton.topAnchor <=> self.topAnchor
tryItButton.bottomAnchor <=> self.bottomAnchor
tryItButton.trailingAnchor <=> self.trailingAnchor
exampleLabel.leadingAnchor <=> self.leadingAnchor
tryItButton.centerYAnchor <=> exampleLabel.centerYAnchor
}

func set(tryHandler: @escaping () -> Void) {
self.tryHandler = tryHandler
}

@objc private func buttonTapped(_ sender: UIControl) {
self.tryHandler?()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
15 changes: 5 additions & 10 deletions iOS/CIFilter.io/Filter Detail/FilterDetailView.swift
Expand Up @@ -27,18 +27,12 @@ final class FilterDetailView: UIView {
return view
}()

private let parametersLabel: UILabel = {
let view = UILabel()
view.font = UIFont.boldSystemFont(ofSize: 14)
view.textColor = UIColor(rgb: 0xF5BD5D)
return view
}()
private let exampleView = FilterDetailExampleHeaderView()

private let exampleLabel: UILabel = {
private let parametersLabel: UILabel = {
let view = UILabel()
view.font = UIFont.boldSystemFont(ofSize: 14)
view.textColor = UIColor(rgb: 0xF5BD5D)
view.text = "EXAMPLE"
return view
}()

Expand Down Expand Up @@ -86,7 +80,7 @@ final class FilterDetailView: UIView {
stackView.edgesToSuperview()
}

func set(filter: FilterInfo) {
func set(filter: FilterInfo, tryHandler: @escaping () -> Void) {
titleView.set(filter: filter)
availabilityView.set(filter: filter)
descriptionLabel.text = filter.description
Expand All @@ -100,7 +94,8 @@ final class FilterDetailView: UIView {
}

exampleStackView.removeAllArrangedSubviews()
exampleStackView.addArrangedSubview(exampleLabel)
exampleStackView.addArrangedSubview(exampleView)
exampleView.set(tryHandler: tryHandler)
if self.exampleProvider.isExampleAvailable(forFilterName: filter.name) {

} else {
Expand Down
Expand Up @@ -31,7 +31,12 @@ final class FilterDetailViewController: UIViewController {
}

func set(filter: FilterInfo) {
filterView.set(filter: filter)
filterView.set(filter: filter, tryHandler: { [weak self] in
guard let `self` = self else { return }
let vc = FilterWorkshopViewController(filter: filter)
let navigationController = UINavigationController(rootViewController: vc)
self.splitViewController?.present(navigationController, animated: true, completion: nil)
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion iOS/CIFilter.io/Filter Detail/FilterExampleProvider.swift
Expand Up @@ -14,6 +14,6 @@ struct FilterExample {

final class FilterExampleProvider {
func isExampleAvailable(forFilterName filterName: String) -> Bool {
return false
return filterName == "CIBokehBlur"
}
}
25 changes: 25 additions & 0 deletions iOS/CIFilter.io/Filter Workshop/FilterWorkshopViewController.swift
@@ -0,0 +1,25 @@
//
// FilterWorkshopViewController.swift
// CIFilter.io
//
// Created by Noah Gilmore on 12/8/18.
// Copyright © 2018 Noah Gilmore. All rights reserved.
//

import UIKit

final class FilterWorkshopViewController: UIViewController {
init(filter: FilterInfo) {
super.init(nibName: nil, bundle: nil)
self.title = filter.name
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "workshop-background")!)
}
}
Binary file added iOS/CIFilter.io/Resources/workshop-background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added iOS/CIFilter.io/Resources/workshop-background@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added iOS/CIFilter.io/Resources/workshop-background@3x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 09afe5d

Please sign in to comment.