Commit fe4294dc by Orkhan Alikhanov

Renamed DialogBuilder to Dialog

parent 2ea0efcd
......@@ -175,7 +175,7 @@
9D054A6620D175AC00D0528D /* Material+UILabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D054A6420D175AC00D0528D /* Material+UILabel.swift */; };
9D39A81B20FE8ED100BA8FA1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D39A81A20FE8ED100BA8FA1 /* ViewController.swift */; };
9D9089B92118914500605DC9 /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D9089B82118914500605DC9 /* Editor.swift */; };
9DE25DE02170D7AF000C04DF /* DialogBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE25DDF2170D7AF000C04DF /* DialogBuilder.swift */; };
9DE25DE02170D7AF000C04DF /* Dialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE25DDF2170D7AF000C04DF /* Dialog.swift */; };
9DE25DE22170D7C0000C04DF /* DialogController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE25DE12170D7C0000C04DF /* DialogController.swift */; };
9DE25DE42170D7FF000C04DF /* DialogView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE25DE32170D7FF000C04DF /* DialogView.swift */; };
9DE84D721FF0252600586C8B /* RadioButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE84D6F1FF0252500586C8B /* RadioButtonGroup.swift */; };
......@@ -301,7 +301,7 @@
9D054A6420D175AC00D0528D /* Material+UILabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UILabel.swift"; sourceTree = "<group>"; };
9D39A81A20FE8ED100BA8FA1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
9D9089B82118914500605DC9 /* Editor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = "<group>"; };
9DE25DDF2170D7AF000C04DF /* DialogBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogBuilder.swift; sourceTree = "<group>"; };
9DE25DDF2170D7AF000C04DF /* Dialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dialog.swift; sourceTree = "<group>"; };
9DE25DE12170D7C0000C04DF /* DialogController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogController.swift; sourceTree = "<group>"; };
9DE25DE32170D7FF000C04DF /* DialogView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DialogView.swift; sourceTree = "<group>"; };
9DE84D6F1FF0252500586C8B /* RadioButtonGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonGroup.swift; sourceTree = "<group>"; };
......@@ -781,7 +781,7 @@
9DE25DDE2170D779000C04DF /* Dialogs */ = {
isa = PBXGroup;
children = (
9DE25DDF2170D7AF000C04DF /* DialogBuilder.swift */,
9DE25DDF2170D7AF000C04DF /* Dialog.swift */,
9DE25DE12170D7C0000C04DF /* DialogController.swift */,
9DE25DE32170D7FF000C04DF /* DialogView.swift */,
);
......@@ -1037,7 +1037,7 @@
96328B971E05C0BB009A4C90 /* TableView.swift in Sources */,
965E80F81DD4D59500D61E4B /* ImageCard.swift in Sources */,
96328B991E05C0CE009A4C90 /* TableViewController.swift in Sources */,
9DE25DE02170D7AF000C04DF /* DialogBuilder.swift in Sources */,
9DE25DE02170D7AF000C04DF /* Dialog.swift in Sources */,
965E80F91DD4D59500D61E4B /* PresenterCard.swift in Sources */,
96E09DC81F2287E50000B121 /* TabsController.swift in Sources */,
961154CC1F32A7B100A78D74 /* ChipBar.swift in Sources */,
......
......@@ -33,13 +33,10 @@
import UIKit
/// A typealias referring to DialogBuilder<DialogView>.
public typealias Dialog = DialogBuilder<DialogView>
/// A builder for DialogController.
open class DialogBuilder<T: DialogView> {
open class Dialog {
/// A reference to dialog controller.
public let controller = DialogController<T>()
public let controller = DialogController<DialogView>()
/// An empty initializer.
public init() { }
......@@ -49,7 +46,7 @@ open class DialogBuilder<T: DialogView> {
- Parameter _ text: A string.
- Returns: DialogBuilder itself to allow chaining.
*/
open func title(_ text: String?) -> DialogBuilder {
open func title(_ text: String?) -> Dialog {
dialogView.titleLabel.text = text
return self
}
......@@ -59,7 +56,7 @@ open class DialogBuilder<T: DialogView> {
- Parameter _ text: A string.
- Returns: DialogBuilder itself to allow chaining.
*/
open func details(_ text: String?) -> DialogBuilder {
open func details(_ text: String?) -> Dialog {
dialogView.detailsLabel.text = text
return self
}
......@@ -70,7 +67,7 @@ open class DialogBuilder<T: DialogView> {
- Parameter handler: A closure handling tap.
- Returns: DialogBuilder itself to allow chaining.
*/
open func positive(_ title: String?, handler: (() -> Void)?) -> DialogBuilder {
open func positive(_ title: String?, handler: (() -> Void)?) -> Dialog {
dialogView.positiveButton.title = title
controller.didTapPositiveButtonHandler = handler
return self
......@@ -82,7 +79,7 @@ open class DialogBuilder<T: DialogView> {
- Parameter handler: A closure handling tap.
- Returns: DialogBuilder itself to allow chaining.
*/
open func negative(_ title: String?, handler: (() -> Void)?) -> DialogBuilder {
open func negative(_ title: String?, handler: (() -> Void)?) -> Dialog {
dialogView.negativeButton.title = title
controller.didTapNegativeButtonHandler = handler
return self
......@@ -94,7 +91,7 @@ open class DialogBuilder<T: DialogView> {
- Parameter handler: A closure handling tap.
- Returns: DialogBuilder itself to allow chaining.
*/
open func neutral(_ title: String?, handler: (() -> Void)?) -> DialogBuilder {
open func neutral(_ title: String?, handler: (() -> Void)?) -> Dialog {
dialogView.neutralButton.title = title
controller.didTapNeutralButtonHandler = handler
return self
......@@ -106,7 +103,7 @@ open class DialogBuilder<T: DialogView> {
- Parameter handler: A closure handling cancellation.
- Returns: DialogBuilder itself to allow chaining.
*/
open func isCancelable(_ value: Bool, handler: (() -> Void)? = nil) -> DialogBuilder {
open func isCancelable(_ value: Bool, handler: (() -> Void)? = nil) -> Dialog {
controller.isCancelable = value
controller.didCancelHandler = handler
return self
......@@ -118,7 +115,7 @@ open class DialogBuilder<T: DialogView> {
- Parameter handler: A closure handling if dialog can be dismissed.
- Returns: DialogBuilder itself to allow chaining.
*/
open func shouldDismiss(handler: ((T, Button?) -> Bool)?) -> DialogBuilder {
open func shouldDismiss(handler: ((DialogView, Button?) -> Bool)?) -> Dialog {
controller.shouldDismissHandler = handler
return self
}
......@@ -129,15 +126,15 @@ open class DialogBuilder<T: DialogView> {
- Returns: DialogBuilder itself to allow chaining.
*/
@discardableResult
open func show(_ viewController: UIViewController) -> DialogBuilder {
open func show(_ viewController: UIViewController) -> Dialog {
viewController.present(controller, animated: true, completion: nil)
return self
}
}
private extension DialogBuilder {
private extension Dialog {
/// Returns dialogView of controller.
var dialogView: T {
var dialogView: DialogView {
return controller.dialogView
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment