Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
9b44d898
Commit
9b44d898
authored
Oct 12, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added DialogBuilder
parent
4005c303
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
163 additions
and
0 deletions
+163
-0
Material.xcodeproj/project.pbxproj
+20
-0
Sources/iOS/DialogBuilder.swift
+143
-0
No files found.
Material.xcodeproj/project.pbxproj
View file @
9b44d898
...
@@ -175,6 +175,9 @@
...
@@ -175,6 +175,9 @@
9D054A6620D175AC00D0528D
/* Material+UILabel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9D054A6420D175AC00D0528D
/* Material+UILabel.swift */
;
};
9D054A6620D175AC00D0528D
/* Material+UILabel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9D054A6420D175AC00D0528D
/* Material+UILabel.swift */
;
};
9D39A81B20FE8ED100BA8FA1
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9D39A81A20FE8ED100BA8FA1
/* ViewController.swift */
;
};
9D39A81B20FE8ED100BA8FA1
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9D39A81A20FE8ED100BA8FA1
/* ViewController.swift */
;
};
9D9089B92118914500605DC9
/* Editor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9D9089B82118914500605DC9
/* Editor.swift */
;
};
9D9089B92118914500605DC9
/* Editor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9D9089B82118914500605DC9
/* Editor.swift */
;
};
9DE25DE02170D7AF000C04DF
/* DialogBuilder.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9DE25DDF2170D7AF000C04DF
/* DialogBuilder.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 */
;
};
9DE84D721FF0252600586C8B
/* RadioButtonGroup.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9DE84D6F1FF0252500586C8B
/* RadioButtonGroup.swift */
;
};
9DE84D731FF0252600586C8B
/* BaseButtonGroup.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9DE84D701FF0252500586C8B
/* BaseButtonGroup.swift */
;
};
9DE84D731FF0252600586C8B
/* BaseButtonGroup.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9DE84D701FF0252500586C8B
/* BaseButtonGroup.swift */
;
};
9DE84D741FF0252600586C8B
/* CheckButtonGroup.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9DE84D711FF0252500586C8B
/* CheckButtonGroup.swift */
;
};
9DE84D741FF0252600586C8B
/* CheckButtonGroup.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9DE84D711FF0252500586C8B
/* CheckButtonGroup.swift */
;
};
...
@@ -298,6 +301,9 @@
...
@@ -298,6 +301,9 @@
9D054A6420D175AC00D0528D
/* Material+UILabel.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UILabel.swift"
;
sourceTree
=
"<group>"
;
};
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>"
;
};
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>"
;
};
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>"
;
};
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>"
;
};
9DE84D6F1FF0252500586C8B
/* RadioButtonGroup.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
RadioButtonGroup.swift
;
sourceTree
=
"<group>"
;
};
9DE84D701FF0252500586C8B
/* BaseButtonGroup.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BaseButtonGroup.swift
;
sourceTree
=
"<group>"
;
};
9DE84D701FF0252500586C8B
/* BaseButtonGroup.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BaseButtonGroup.swift
;
sourceTree
=
"<group>"
;
};
9DE84D711FF0252500586C8B
/* CheckButtonGroup.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CheckButtonGroup.swift
;
sourceTree
=
"<group>"
;
};
9DE84D711FF0252500586C8B
/* CheckButtonGroup.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CheckButtonGroup.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -550,6 +556,7 @@
...
@@ -550,6 +556,7 @@
96BCB8001CB40F0300C806FE
/* Color */
,
96BCB8001CB40F0300C806FE
/* Color */
,
96328B9A1E05C135009A4C90
/* Data */
,
96328B9A1E05C135009A4C90
/* Data */
,
96BCB80B1CB410CC00C806FE
/* Device */
,
96BCB80B1CB410CC00C806FE
/* Device */
,
9DE25DDE2170D779000C04DF
/* Dialogs */
,
96230AB61D6A51FD00AF47DC
/* Divider */
,
96230AB61D6A51FD00AF47DC
/* Divider */
,
96BCB80A1CB410A100C806FE
/* Extension */
,
96BCB80A1CB410A100C806FE
/* Extension */
,
963FBF021D6696D0008F8512
/* FABMenu */
,
963FBF021D6696D0008F8512
/* FABMenu */
,
...
@@ -771,6 +778,16 @@
...
@@ -771,6 +778,16 @@
name
=
Theme
;
name
=
Theme
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
9DE25DDE2170D779000C04DF
/* Dialogs */
=
{
isa
=
PBXGroup
;
children
=
(
9DE25DDF2170D7AF000C04DF
/* DialogBuilder.swift */
,
9DE25DE12170D7C0000C04DF
/* DialogController.swift */
,
9DE25DE32170D7FF000C04DF
/* DialogView.swift */
,
);
name
=
Dialogs
;
sourceTree
=
"<group>"
;
};
9DE84D6E1FF0250E00586C8B
/* ButtonGroup */
=
{
9DE84D6E1FF0250E00586C8B
/* ButtonGroup */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -1015,9 +1032,12 @@
...
@@ -1015,9 +1032,12 @@
9DE84D721FF0252600586C8B
/* RadioButtonGroup.swift in Sources */
,
9DE84D721FF0252600586C8B
/* RadioButtonGroup.swift in Sources */
,
9D00EBB4216675FB00DBCD69
/* Theme.swift in Sources */
,
9D00EBB4216675FB00DBCD69
/* Theme.swift in Sources */
,
965E80FE1DD4D59500D61E4B
/* ToolbarController.swift in Sources */
,
965E80FE1DD4D59500D61E4B
/* ToolbarController.swift in Sources */
,
9DE25DE22170D7C0000C04DF
/* DialogController.swift in Sources */
,
9DE25DE42170D7FF000C04DF
/* DialogView.swift in Sources */
,
96328B971E05C0BB009A4C90
/* TableView.swift in Sources */
,
96328B971E05C0BB009A4C90
/* TableView.swift in Sources */
,
965E80F81DD4D59500D61E4B
/* ImageCard.swift in Sources */
,
965E80F81DD4D59500D61E4B
/* ImageCard.swift in Sources */
,
96328B991E05C0CE009A4C90
/* TableViewController.swift in Sources */
,
96328B991E05C0CE009A4C90
/* TableViewController.swift in Sources */
,
9DE25DE02170D7AF000C04DF
/* DialogBuilder.swift in Sources */
,
965E80F91DD4D59500D61E4B
/* PresenterCard.swift in Sources */
,
965E80F91DD4D59500D61E4B
/* PresenterCard.swift in Sources */
,
96E09DC81F2287E50000B121
/* TabsController.swift in Sources */
,
96E09DC81F2287E50000B121
/* TabsController.swift in Sources */
,
961154CC1F32A7B100A78D74
/* ChipBar.swift in Sources */
,
961154CC1F32A7B100A78D74
/* ChipBar.swift in Sources */
,
...
...
Sources/iOS/DialogBuilder.swift
0 → 100644
View file @
9b44d898
/*
* Copyright (C) 2018, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Original Inspiration & Author
* Copyright (C) 2018 Orkhan Alikhanov <orkhan.alikhanov@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
/// A typealias referring to DialogBuilder<DialogView>.
public
typealias
Dialog
=
DialogBuilder
<
DialogView
>
/// A builder for DialogController.
open
class
DialogBuilder
<
T
:
DialogView
>
{
/// A reference to dialog controller.
public
let
controller
=
DialogController
<
T
>
()
/// An empty initializer.
public
init
()
{
}
/**
Sets title of the dialog.
- Parameter _ text: A string.
- Returns: DialogBuilder itself to allow chaining.
*/
open
func
title
(
_
text
:
String
?)
->
DialogBuilder
{
dialogView
.
titleLabel
.
text
=
text
return
self
}
/**
Sets details of the dialog.
- Parameter _ text: A string.
- Returns: DialogBuilder itself to allow chaining.
*/
open
func
details
(
_
text
:
String
?)
->
DialogBuilder
{
dialogView
.
detailsLabel
.
text
=
text
return
self
}
/**
Sets title and handler for positive button of dialog.
- Parameter _ title: A string.
- Parameter handler: A closure handling tap.
- Returns: DialogBuilder itself to allow chaining.
*/
open
func
positive
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
DialogBuilder
{
dialogView
.
positiveButton
.
title
=
title
controller
.
didTapPositiveButtonHandler
=
handler
return
self
}
/**
Sets title and handler for negative button of dialog.
- Parameter _ title: A string.
- Parameter handler: A closure handling tap.
- Returns: DialogBuilder itself to allow chaining.
*/
open
func
negative
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
DialogBuilder
{
dialogView
.
negativeButton
.
title
=
title
controller
.
didTapNegativeButtonHandler
=
handler
return
self
}
/**
Sets title and handler for neutral button of dialog.
- Parameter _ title: A string.
- Parameter handler: A closure handling tap.
- Returns: DialogBuilder itself to allow chaining.
*/
open
func
neutral
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
DialogBuilder
{
dialogView
.
neutralButton
.
title
=
title
controller
.
didTapNeutralButtonHandler
=
handler
return
self
}
/**
Sets cancelability of dialog and handler for when it's cancelled.
- Parameter _ value: A Bool.
- Parameter handler: A closure handling cancellation.
- Returns: DialogBuilder itself to allow chaining.
*/
open
func
isCancelable
(
_
value
:
Bool
,
handler
:
(()
->
Void
)?
=
nil
)
->
DialogBuilder
{
controller
.
isCancelable
=
value
controller
.
didCancelHandler
=
handler
return
self
}
/**
Sets should-dismiss handler of dialog which takes dialogView and tapped
button and returns a boolean indicating if dialog should be dismissed.
- Parameter handler: A closure handling if dialog can be dismissed.
- Returns: DialogBuilder itself to allow chaining.
*/
open
func
shouldDismiss
(
handler
:
((
T
,
Button
?)
->
Bool
)?)
->
DialogBuilder
{
controller
.
shouldDismissHandler
=
handler
return
self
}
/**
Presents dialog modally from given viewController.
- Parameter _ viewController: A UIViewController.
- Returns: DialogBuilder itself to allow chaining.
*/
@discardableResult
open
func
show
(
_
viewController
:
UIViewController
)
->
DialogBuilder
{
viewController
.
present
(
controller
,
animated
:
true
,
completion
:
nil
)
return
self
}
}
private
extension
DialogBuilder
{
/// Returns dialogView of controller.
var
dialogView
:
T
{
return
controller
.
dialogView
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment