Update README and doc comments
This commit is contained in:
parent
b5deabff24
commit
34632313ae
355
README.md
355
README.md
|
@ -1,16 +1,23 @@
|
||||||

|

|
||||||
|
_Easily extend any project to include an intelligent design component browser._
|
||||||
|
|
||||||
A standalone component browser package that intelligently displays design components.
|
Licensing
|
||||||
|
----------
|
||||||
|
Y—Component Browser is licensed under the [Apache 2.0 license](LICENSE).
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
----------
|
||||||
|
Documentation is automatically generated from source code comments and rendered as a static website hosted via GitHub Pages at: https://yml-org.github.io/YComponentBrowser/
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Icon Category](#icon-category)
|
|
||||||
* [Font Category](#font-category)
|
|
||||||
* [Color Category](#color-category)
|
* [Color Category](#color-category)
|
||||||
|
* [Font Category](#font-category)
|
||||||
|
* [Icon Category](#icon-category)
|
||||||
* [Catalog Category](#catalog-category)
|
* [Catalog Category](#catalog-category)
|
||||||
* [Custom Component Category](#custom-component-category)
|
* [Small Component Category](#small-component-category)
|
||||||
* [Custom View Controller Category](#custom-view-controller-category)
|
* [Medium Component Category](#medium-component-category)
|
||||||
|
* [Large Component Category](#large-component-category)
|
||||||
* [Contributing to Y—Component-Browser](#contributing-to-ycomponent-browser)
|
* [Contributing to Y—Component-Browser](#contributing-to-ycomponent-browser)
|
||||||
* [Versioning Stratergy](#versioning-strategy)
|
* [Versioning Stratergy](#versioning-strategy)
|
||||||
* [Branching Stratergy](#branching-strategy)
|
* [Branching Stratergy](#branching-strategy)
|
||||||
|
@ -18,220 +25,215 @@ A standalone component browser package that intelligently displays design compon
|
||||||
* [Pull Requests](#pull-requests)
|
* [Pull Requests](#pull-requests)
|
||||||
* [Releasing New Versions](#releasing-new-versions)
|
* [Releasing New Versions](#releasing-new-versions)
|
||||||
* [Requirements](#requirements)
|
* [Requirements](#requirements)
|
||||||
* [Jazzy(documentation)](#jazzy-documentation)
|
* [SwiftLint (linter)](#swiftlint-linter)
|
||||||
|
* [Jazzy (documentation)](#jazzy-documentation)
|
||||||
* [Setup](#setup)
|
* [Setup](#setup)
|
||||||
* [Generating Documentation (via Jazzy)](#generating-documentation-via-jazzy)
|
* [Generating Documentation (via Jazzy)](#generating-documentation-via-jazzy)
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
----------
|
----------
|
||||||
The category is a collection of components utilized in a project that share common traits. A category with a number of subcategories can be created. By default, components are laid out in nested table views, with each component being represented by a single row. A CatalogDisplayView is used to display a component in a single row. It displays small components together with a title and optional subtitle text. This is used for icons, fonts, and colors, but also works well for smaller components such as buttons. It uses generics to display any view (together with an associated model). The framework includes some pre-defined categories for displaying common tasks: icons, colors, and fonts.
|
A category is a collection of components that share common traits. A category may contain subcategories. By default, components are laid out in nested table views, with each component being represented by a single row. A `CatalogDisplayView` is used to display a component in a single row. It displays small components together with a title and optional detail description. This is used for icons, fonts, and colors, but also works well for smaller components such as buttons. By using generics, `CaralogDisplayView` can display any view (populated with an associated model). The framework includes pre-defined categories for displaying common components: colors, fonts, and icons.
|
||||||
|
|
||||||
The catalog display view model has four parameters:
|
The catalog display view model has four parameters:
|
||||||
* The title of the component
|
|
||||||
* The model of the component
|
|
||||||
* The description, an optional argument, is nil by default but allows the user to provide more information about the component if necessary.
|
|
||||||
* A user may choose whether they want the title, description, and components to be shown vertically or horizontally using the axis attribute, which is an optional parameter and is horizontal by default.
|
|
||||||
|
|
||||||
Using the custom category defined in the package, a bigger component, such as a card view, can be shown. These custom component may take up a full row by itself. For a components like a view controller, we may skip the table view controller and show the component on the full screen by defining a custom category and destination that comply with the Classification protocol and Destination protocol, respectively.
|
* `title`: title
|
||||||
|
* `detail`: detail description (optional), defaults to `nil`
|
||||||
|
* `axis`: primary axis for the content view, defaults to `.horizontal`
|
||||||
|
* `model`: model to populate the content view
|
||||||
|
|
||||||
|
By using `CustomCategory`, a larger component, such as a card view, can be shown. Each custom component might occupy a full row by itself.
|
||||||
|
|
||||||
|
For even larger components such as a view controller, we may skip the table view controller and display the component on a full screen by itself. This is accomplished by defining a custom category and destination that conform to the `Classification` and `Destination` protocols, respectively.
|
||||||
|
|
||||||
|
### Color category
|
||||||
|
We can display colors by declaring a `ColorCategory` object:
|
||||||
|
```
|
||||||
|
let category = ColorCategory(
|
||||||
|
name: "Easter",
|
||||||
|
models: [
|
||||||
|
.init(
|
||||||
|
title: "Purple",
|
||||||
|
detail: "HEX: #D9D7F1",
|
||||||
|
model: UIColor(red: 217/255, green: 215/255, blue: 241/255, alpha: 1)
|
||||||
|
),
|
||||||
|
.init(
|
||||||
|
title: "Light Yellow",
|
||||||
|
detail: "HEX: #FFFDDE",
|
||||||
|
model: UIColor(red: 1, green: 253/255, blue: 222/255, alpha: 1)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
```
|
||||||
|
where you need to specify:
|
||||||
|
|
||||||
|
* `name`: color category name
|
||||||
|
* `models`: information about the colors to be displayed
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Font Category
|
||||||
|
We can display fonts by declaring a `FontCategory` object:
|
||||||
|
```
|
||||||
|
let category = FontCategory(
|
||||||
|
name: "TiemposHeadline Bold",
|
||||||
|
models: [
|
||||||
|
.init(
|
||||||
|
title: "Title 1",
|
||||||
|
model: FontView.Model(
|
||||||
|
font: UIFont(name: "TiemposHeadline-Bold", size: 36)!
|
||||||
|
)
|
||||||
|
),
|
||||||
|
.init(
|
||||||
|
title: "Title 2",
|
||||||
|
model: FontView.Model(
|
||||||
|
font: UIFont(name: "TiemposHeadline-Bold", size: 26)!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
```
|
||||||
|
where you need to specify:
|
||||||
|
|
||||||
|
* `name`: font category name
|
||||||
|
* `models`: information about the fonts to be displayed
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Icon Category
|
### Icon Category
|
||||||
For example, a user can create an icon category as follows:
|
We can display icons by declaring an `IconCategory` object:
|
||||||
|
```
|
||||||
```
|
let category = IconCategory(
|
||||||
enum IconSample {
|
name: "Media",
|
||||||
static var media: IconCategory {
|
models: [
|
||||||
IconCategory(
|
.init(
|
||||||
name: "Media",
|
title: "Play",
|
||||||
models: [
|
model: UIImage(systemName: "play.fill")!
|
||||||
.init(
|
),
|
||||||
title: "Play",
|
.init(
|
||||||
model: UIImage(systemName: "play.fill") ?? UIImage()
|
title: "Pause",
|
||||||
)
|
model: UIImage(systemName: "pause.fill")!
|
||||||
]
|
|
||||||
)
|
)
|
||||||
}
|
]
|
||||||
}
|
)
|
||||||
|
```
|
||||||
|
where you need to specify:
|
||||||
|
|
||||||
```
|
* `name`: icon category name
|
||||||
where the user needs to provide the following parameters:
|
* `models`: information about the icons to be displayed
|
||||||
* The name of the category.
|
|
||||||
* Model for the image to be displayed
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
### Font Category
|
|
||||||
a user can create a font category as follows:
|
|
||||||
```
|
|
||||||
enum FontSample {
|
|
||||||
static var tiemposHeadlineBold: FontCategory {
|
|
||||||
FontCategory(
|
|
||||||
name: "TiemposHeadline Bold",
|
|
||||||
models: [
|
|
||||||
.init(
|
|
||||||
title: "Title 1",
|
|
||||||
model: FontView.Model(
|
|
||||||
font: UIFont(name: "TiemposHeadline-Bold", size: 36) ?? UIFont()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
where the user needs to provide the following parameters:
|
|
||||||
* The name of the category.
|
|
||||||
* Model for the font to be displayed
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
### Color category
|
|
||||||
a user can create a color category as follows:
|
|
||||||
```
|
|
||||||
enum ColorSample {
|
|
||||||
static var category: ColorCategory {
|
|
||||||
ColorCategory(
|
|
||||||
name: "Easter",
|
|
||||||
models: [
|
|
||||||
.init(
|
|
||||||
title: "Purple",
|
|
||||||
detail: "HEX: #D9D7F1",
|
|
||||||
model: UIColor(red: 217/255, green: 215/255, blue: 241/255, alpha: 1)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
where the user needs to provide the following parameters:
|
|
||||||
* The name of the category.
|
|
||||||
* Model for the view to be displayed
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Catalog Category
|
### Catalog Category
|
||||||
We can create a category which contains other categories.
|
We can display nested subcategories by declaring a `CatalogCategory` object:
|
||||||
```
|
```
|
||||||
let foundationalCategory = CatalogCategory(
|
let category = CatalogCategory(
|
||||||
name: "Foundational",
|
name: "Foundational",
|
||||||
subcategories: [
|
subcategories: [
|
||||||
ColorSample.category,
|
ColorSample.category,
|
||||||
IconSample.category,
|
IconSample.category,
|
||||||
FontSample.category
|
FontSample.category
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
where the user needs to provide the following parameters:
|
where you need to specify:
|
||||||
* The name of the category.
|
|
||||||
* Array of subcategories.
|
|
||||||
|
|
||||||
|
* `name`: category name
|
||||||
|
* `subcategories`: array of subcategories
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### Small Component Category
|
||||||
|
We can display small custom components (such as buttons) by declaring a `CustomCategory` object that leverages `CatalogDisplayView`:
|
||||||
|
```
|
||||||
|
let category = CustomCategory<CatalogDisplayView<DemoButton>>(
|
||||||
|
name: "Demo Button",
|
||||||
|
models: [
|
||||||
|
.init(
|
||||||
|
title: "Login",
|
||||||
|
model: .init(
|
||||||
|
backgroundColor: .systemBlue,
|
||||||
|
title: "Login",
|
||||||
|
titleColor: .white
|
||||||
|
)
|
||||||
|
),
|
||||||
|
.init(
|
||||||
|
title: "Logout",
|
||||||
|
model: .init(
|
||||||
|
backgroundColor: .systemRed,
|
||||||
|
cornerRadius: 25,
|
||||||
|
title: "Logout",
|
||||||
|
titleColor: .white
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
```
|
||||||
|
where you need to specify:
|
||||||
|
|
||||||
### Custom Component Category
|
* `name`: category name
|
||||||
Suppose a user wants to display a button named DemoButton from their project.
|
* `models`: information about the components to be displayed (in this case buttons)
|
||||||
```
|
|
||||||
enum DemoButtonSample {
|
|
||||||
static var demoButtonCategory: CustomCategory<CatalogDisplayView<DemoButton>> {
|
|
||||||
CustomCategory<CatalogDisplayView<DemoButton>>(
|
|
||||||
name: "Demo Button",
|
|
||||||
models: [
|
|
||||||
CatalogDisplayView<DemoButton>.Model(
|
|
||||||
title: "Login",
|
|
||||||
model: DemoButtonModel(
|
|
||||||
backgroundColor: .systemBlue,
|
|
||||||
title: "Login",
|
|
||||||
titleColor: .white
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
where the user needs to provide the following parameters:
|
|
||||||
* name for the category.
|
|
||||||
* model needed to initialise the button.
|
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Custom View Category
|
### Medium Component Category
|
||||||
We can display a custom view within the catalog.
|
We can display medium-sized custom components (such as a card or a note) by declaring a `CustomCategory` object that directly uses the view to be displayed:
|
||||||
Suppose a user wants to display a custom view named DemoView from their project.
|
```
|
||||||
```
|
let category = CustomCategory<NoteView>(
|
||||||
enum DemoViewSample {
|
name: "Demo View",
|
||||||
static var demoViewCategory: CustomCategory<DemoView> {
|
models: [
|
||||||
CustomCategory<DemoView>(
|
NoteView.Model(
|
||||||
name: "Demo View",
|
title: "Grocery List",
|
||||||
models: [
|
body: "1) apples\n 2) sugar\n 3) coffee\n 4)snacks",
|
||||||
DemoViewModel(
|
backgroundColor: .systemYellow
|
||||||
title: "Grocery List",
|
),
|
||||||
description: "1) apples\n 2) sugar\n 3) coffee\n 4)snacks",
|
NoteView.Model(
|
||||||
backgroundColor: .systemYellow
|
title: "Todo List",
|
||||||
)
|
body: ""1)Buy Grocery\n 2)Prepare meal\n 3) Call a friend\n "",
|
||||||
]
|
backgroundColor: .systemYellow
|
||||||
)
|
)
|
||||||
}
|
]
|
||||||
}
|
)
|
||||||
```
|
```
|
||||||
where the user needs to provide the following parameters:
|
where you need to specify:
|
||||||
* name for the category.
|
|
||||||
* model needed to initialise the custom view.
|
* `name`: category name
|
||||||
|
* `models`: information about the components to be displayed (in this case notes)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### Large Component Category
|
||||||
|
In order to display large custom components (including full-screen views and even view controllers), we need to:
|
||||||
|
|
||||||
### Custom View Controller category
|
1. Create a custom destination that returns a view controller to be presented. If your component is not a view controller, this would be a view controller that contains your component.
|
||||||
We can display view controllers in the catalog
|
```
|
||||||
1. First create a custom destination that returns the view controller
|
struct CarouselDestination: Destination {
|
||||||
```
|
let navigationTitle: String?
|
||||||
struct CarouselDestination: Destination {
|
|
||||||
var navigationTitle: String?
|
|
||||||
|
|
||||||
var presentationStyle: Presentation = .detail
|
let presentationStyle: Presentation = .detail
|
||||||
|
|
||||||
func getDestinationController() -> UIViewController {
|
func getDestinationController() -> UIViewController {
|
||||||
return CarouselDemoViewController(navigationTitle: navigationTitle ?? "")
|
CarouselDemoViewController(navigationTitle: navigationTitle)
|
||||||
}
|
|
||||||
|
|
||||||
init(presentationStyle: Presentation = .detail, navigationTitle: String) {
|
|
||||||
self.presentationStyle = presentationStyle
|
|
||||||
self.navigationTitle = navigationTitle
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Create a custom category for that particular view controller
|
2. Create a custom category for that particular view controller
|
||||||
```
|
```
|
||||||
struct CarouselCategory: Classification {
|
struct CarouselCategory: Classification {
|
||||||
let name: String
|
let name: String
|
||||||
|
|
||||||
var destination: Destination {
|
var destination: Destination {
|
||||||
CarouselDestination(navigationTitle: name)
|
CarouselDestination(navigationTitle: name)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(name: String) {
|
|
||||||
self.name = name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
3. Create instance of the category
|
|
||||||
```
|
|
||||||
enum CarouselSample {
|
|
||||||
static var category: CarouselCategory {
|
|
||||||
CarouselCategory(name: "Carousel Demo View Controller")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||

|
|
||||||
|
|
||||||
|
3. Declare an instance of the category
|
||||||
|
```
|
||||||
|
let category = CarouselCategory(name: "Carousel Demo View Controller")
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Contributing to Y—Component-Browser
|
Contributing to Y—Component-Browser
|
||||||
----------
|
----------
|
||||||
|
@ -302,6 +304,11 @@ When merging a pull request:
|
||||||
Requirements
|
Requirements
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
#### SwiftLint (linter)
|
||||||
|
```
|
||||||
|
brew install swiftlint
|
||||||
|
```
|
||||||
|
|
||||||
### Jazzy (documentation)
|
### Jazzy (documentation)
|
||||||
```
|
```
|
||||||
sudo gem install jazzy
|
sudo gem install jazzy
|
||||||
|
|
|
@ -8,12 +8,12 @@ import UIKit
|
||||||
|
|
||||||
/// Catalog factory to encapsulate the creation logic of catalog and controllers
|
/// Catalog factory to encapsulate the creation logic of catalog and controllers
|
||||||
public enum CatalogFactory {
|
public enum CatalogFactory {
|
||||||
/// Types of generic display ViewController
|
/// Display type
|
||||||
public enum DisplayType {
|
public enum DisplayType {
|
||||||
/// TableViewController
|
/// Table view
|
||||||
case table
|
case table
|
||||||
|
|
||||||
/// CollectionViewController
|
/// Collection view
|
||||||
case collection(UICollectionViewLayout)
|
case collection(UICollectionViewLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ public final class ClassificationDataSource: NSObject, CatalogDataSource {
|
||||||
|
|
||||||
/// Initializes a classification data source
|
/// Initializes a classification data source
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - navigationTitle:the text to be displayed in the navigation bar
|
/// - navigationTitle:the text to be displayed in the navigation bar
|
||||||
/// - classification: array of categories
|
/// - classification: array of categories
|
||||||
public init(navigationTitle: String?, classification: [Classification]) {
|
public init(navigationTitle: String?, classification: [Classification]) {
|
||||||
self.navigationTitle = navigationTitle
|
self.navigationTitle = navigationTitle
|
||||||
categories = classification
|
categories = classification
|
||||||
|
|
|
@ -10,9 +10,8 @@ public final class ClassificationViewController<DataSource: CatalogDataSource>:
|
||||||
/// Data source for that catalogView
|
/// Data source for that catalogView
|
||||||
public let datasource: DataSource
|
public let datasource: DataSource
|
||||||
|
|
||||||
/// Initializes a classification view controller
|
/// Initializes a classification view controller
|
||||||
/// - Parameters:
|
/// - Parameter datasource: data source for the catalog view
|
||||||
/// - datasource: data source for the catalog view
|
|
||||||
public init(datasource: DataSource) {
|
public init(datasource: DataSource) {
|
||||||
self.datasource = datasource
|
self.datasource = datasource
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Catalog category
|
/// Catalog category: a category that contains other subcategories
|
||||||
public struct CatalogCategory: Classification {
|
public struct CatalogCategory: Classification {
|
||||||
/// Name of the catalog category
|
/// Name of the catalog category
|
||||||
public let name: String
|
public let name: String
|
||||||
|
@ -24,8 +24,8 @@ public struct CatalogCategory: Classification {
|
||||||
|
|
||||||
/// Initializes a catalog category
|
/// Initializes a catalog category
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - name: Name of the category
|
/// - name: category name
|
||||||
/// - subcategories: Array of sub categories
|
/// - subcategories: array of subcategories
|
||||||
public init(name: String, subcategories: [Classification]) {
|
public init(name: String, subcategories: [Classification]) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.subcategories = subcategories
|
self.subcategories = subcategories
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Foundation
|
||||||
|
|
||||||
/// Category for colours
|
/// Category for colours
|
||||||
public struct ColorCategory: Classification {
|
public struct ColorCategory: Classification {
|
||||||
/// The type of View category supports
|
/// The type of View category supports
|
||||||
public typealias View = CatalogDisplayView<ColorView>
|
public typealias View = CatalogDisplayView<ColorView>
|
||||||
|
|
||||||
/// Name of the category
|
/// Name of the category
|
||||||
|
@ -22,10 +22,10 @@ public struct ColorCategory: Classification {
|
||||||
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a category
|
/// Initializes a color category
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - name: name of the category
|
/// - name: color category name
|
||||||
/// - models: model for the components to be displayed
|
/// - models: information about the colors to be displayed
|
||||||
public init(name: String, models: [View.Model]) {
|
public init(name: String, models: [View.Model]) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.models = models
|
self.models = models
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Category for any view that satisfies ContentView
|
/// Category for small views that will be displayed in a table or collection view cell.
|
||||||
|
///
|
||||||
|
/// Suitable for buttons, switches, badges, and other small components.
|
||||||
public struct ComponentCategory<View: ContentView>: Classification {
|
public struct ComponentCategory<View: ContentView>: Classification {
|
||||||
/// The type of View category supports
|
/// The type of View category supports
|
||||||
public typealias DisplayView = CatalogDisplayView<View>
|
public typealias DisplayView = CatalogDisplayView<View>
|
||||||
|
|
||||||
/// Name of the category
|
/// Name of the category
|
||||||
|
@ -22,10 +24,10 @@ public struct ComponentCategory<View: ContentView>: Classification {
|
||||||
CatalogDetailDestination<DisplayView>(navigationTitle: name, models: models)
|
CatalogDetailDestination<DisplayView>(navigationTitle: name, models: models)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a category
|
/// Initializes a component category
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - name: name of the category
|
/// - name: component category name
|
||||||
/// - models: model for the components to be displayed
|
/// - models: information about the components to be displayed
|
||||||
public init(name: String, models: [DisplayView.Model]) {
|
public init(name: String, models: [DisplayView.Model]) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.models = models
|
self.models = models
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Custom category for View that satisfies protocols
|
/// Custom category for components that will not utilize `CatalogDisplayView`.
|
||||||
|
///
|
||||||
|
/// Suitable for larger components, such as cards, that might occupy an entire table view (or collection view) cell
|
||||||
|
/// by themselves.
|
||||||
|
/// Also suitable when you wish to define your own custom `ContentView` to display the component.
|
||||||
public struct CustomCategory<View: ContentView>: Classification {
|
public struct CustomCategory<View: ContentView>: Classification {
|
||||||
/// Name of the category
|
/// Name of the category
|
||||||
public let name: String
|
public let name: String
|
||||||
|
@ -19,10 +23,10 @@ public struct CustomCategory<View: ContentView>: Classification {
|
||||||
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a category
|
/// Initializes a custom category
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - name: name of the category
|
/// - name: category name
|
||||||
/// - models: model for the components to be displayed
|
/// - models: information about the components to be displayed
|
||||||
public init(name: String, models: [View.Model]) {
|
public init(name: String, models: [View.Model]) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.models = models
|
self.models = models
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Foundation
|
||||||
|
|
||||||
/// Category for fonts and text
|
/// Category for fonts and text
|
||||||
public struct FontCategory: Classification {
|
public struct FontCategory: Classification {
|
||||||
/// The type of View category supports
|
/// The type of View category supports
|
||||||
public typealias View = CatalogDisplayView<FontView>
|
public typealias View = CatalogDisplayView<FontView>
|
||||||
|
|
||||||
/// Name of the category
|
/// Name of the category
|
||||||
|
@ -22,10 +22,10 @@ public struct FontCategory: Classification {
|
||||||
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a category
|
/// Initializes a font category
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - name: name of the category
|
/// - name: font category name
|
||||||
/// - models: model for the components to be displayed
|
/// - models: information about the fonts to be displayed
|
||||||
public init(name: String, models: [View.Model]) {
|
public init(name: String, models: [View.Model]) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.models = models
|
self.models = models
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Foundation
|
||||||
|
|
||||||
/// Category for icons (intended for small images having a fixed size and ratio)
|
/// Category for icons (intended for small images having a fixed size and ratio)
|
||||||
public struct IconCategory: Classification {
|
public struct IconCategory: Classification {
|
||||||
/// The type of View category supports
|
/// The type of View category supports
|
||||||
public typealias View = CatalogDisplayView<IconView>
|
public typealias View = CatalogDisplayView<IconView>
|
||||||
|
|
||||||
/// Name of the category
|
/// Name of the category
|
||||||
|
@ -22,10 +22,10 @@ public struct IconCategory: Classification {
|
||||||
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
CatalogDetailDestination<View>(navigationTitle: name, models: models)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a category
|
/// Initializes an icon category
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - name: name of the category
|
/// - name: icon category name
|
||||||
/// - models: model for the components to be displayed
|
/// - models: information about the icons to be displayed
|
||||||
public init(name: String, models: [View.Model]) {
|
public init(name: String, models: [View.Model]) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.models = models
|
self.models = models
|
||||||
|
|
|
@ -11,7 +11,7 @@ public struct CatalogDetailDestination<View: ContentView>: Destination {
|
||||||
/// Presentation style of catalog destination view controller
|
/// Presentation style of catalog destination view controller
|
||||||
public var presentationStyle: Presentation = .detail
|
public var presentationStyle: Presentation = .detail
|
||||||
|
|
||||||
/// Navigation title of the destination screen
|
/// Navigation title of the destination screen
|
||||||
public let navigationTitle: String?
|
public let navigationTitle: String?
|
||||||
|
|
||||||
/// Model of catalog destination view controller
|
/// Model of catalog destination view controller
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Foundation
|
||||||
|
|
||||||
/// Represents anything that can be highlighted
|
/// Represents anything that can be highlighted
|
||||||
public protocol Highlightable {
|
public protocol Highlightable {
|
||||||
/// Method to set highlighted for the given UI component
|
/// Highlights the UI component
|
||||||
/// - Parameter isHighlighted: bool indicating if UI component is highlighted
|
/// - Parameter isHighlighted: whether the UI component is highlighted
|
||||||
func setHighlighted(_ isHighlighted: Bool)
|
func setHighlighted(_ isHighlighted: Bool)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Foundation
|
||||||
|
|
||||||
/// Represents anything that can be selected
|
/// Represents anything that can be selected
|
||||||
public protocol Selectable {
|
public protocol Selectable {
|
||||||
/// Used to set isSelected for the given UI component
|
/// Selects the given UI component
|
||||||
/// - Parameter isSelected: Bool indicating if UI component is selected
|
/// - Parameter isSelected: whether the UI component is selected
|
||||||
func setSelected(_ isSelected: Bool)
|
func setSelected(_ isSelected: Bool)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public final class GenericCollectionViewCell<View: ContentView>: UICollectionVie
|
||||||
initialDisplayView()
|
initialDisplayView()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public required init?(coder: NSCoder) { return nil }
|
public required init?(coder: NSCoder) { return nil }
|
||||||
|
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
|
|
|
@ -26,10 +26,10 @@ final public class CatalogDisplayView<View: ContentView>: UIView {
|
||||||
|
|
||||||
/// Initializes a catalog display view
|
/// Initializes a catalog display view
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - title: title
|
/// - title: title
|
||||||
/// - detail: detail description
|
/// - detail: detail description (optional), defaults to `nil`
|
||||||
/// - displayViewAxis: primary axis for content view
|
/// - axis: primary axis for the content view, defaults to .horizontal
|
||||||
/// - displayViewModel: model to populate the content view
|
/// - model: model to populate the content view
|
||||||
public init(
|
public init(
|
||||||
title: String?,
|
title: String?,
|
||||||
detail: String? = nil,
|
detail: String? = nil,
|
||||||
|
|
|
@ -8,9 +8,9 @@ import UIKit
|
||||||
|
|
||||||
/// A view to display a given font and text
|
/// A view to display a given font and text
|
||||||
final public class FontView: UILabel {
|
final public class FontView: UILabel {
|
||||||
/// Model to initialize the the `FontView`
|
/// Font view model
|
||||||
public struct Model {
|
public struct Model {
|
||||||
/// Default display text for FontView Model
|
/// Default display text
|
||||||
public static let defaultText = "The quick brown fox jumped over the lazy dog."
|
public static let defaultText = "The quick brown fox jumped over the lazy dog."
|
||||||
|
|
||||||
/// Font for the label
|
/// Font for the label
|
||||||
|
@ -21,8 +21,8 @@ final public class FontView: UILabel {
|
||||||
|
|
||||||
/// Initializes a FontView Model
|
/// Initializes a FontView Model
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - font: font to use
|
/// - font: font to use
|
||||||
/// - text: text to display
|
/// - text: text to display
|
||||||
public init(font: UIFont, text: String = defaultText) {
|
public init(font: UIFont, text: String = defaultText) {
|
||||||
self.font = font
|
self.font = font
|
||||||
self.text = text
|
self.text = text
|
||||||
|
|
Loading…
Reference in New Issue