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
24e9d6d6
Commit
24e9d6d6
authored
Oct 11, 2019
by
Jaime Baez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash when Dialog builder already deallocated when callback executed
parent
059ed9c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
Sources/iOS/Dialogs/Dialog.swift
+22
-15
No files found.
Sources/iOS/Dialogs/Dialog.swift
View file @
24e9d6d6
...
@@ -137,8 +137,9 @@ open class Dialog: NSObject {
...
@@ -137,8 +137,9 @@ open class Dialog: NSObject {
@discardableResult
@discardableResult
open
func
positive
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
Dialog
{
open
func
positive
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
Dialog
{
dialogView
.
positiveButton
.
title
=
title
dialogView
.
positiveButton
.
title
=
title
controller
.
didTapPositiveButtonHandler
=
{
[
unowned
self
]
in
controller
.
didTapPositiveButtonHandler
=
{
[
weak
self
]
in
self
.
delegate
?
.
dialog
?(
self
,
didTapPositive
:
self
.
controller
.
dialogView
.
positiveButton
)
guard
let
strongSelf
=
self
else
{
return
}
strongSelf
.
delegate
?
.
dialog
?(
strongSelf
,
didTapPositive
:
strongSelf
.
controller
.
dialogView
.
positiveButton
)
handler
?()
handler
?()
}
}
return
self
return
self
...
@@ -153,8 +154,9 @@ open class Dialog: NSObject {
...
@@ -153,8 +154,9 @@ open class Dialog: NSObject {
@discardableResult
@discardableResult
open
func
negative
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
Dialog
{
open
func
negative
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
Dialog
{
dialogView
.
negativeButton
.
title
=
title
dialogView
.
negativeButton
.
title
=
title
controller
.
didTapNegativeButtonHandler
=
{
[
unowned
self
]
in
controller
.
didTapNegativeButtonHandler
=
{
[
weak
self
]
in
self
.
delegate
?
.
dialog
?(
self
,
didTapNegative
:
self
.
controller
.
dialogView
.
negativeButton
)
guard
let
strongSelf
=
self
else
{
return
}
strongSelf
.
delegate
?
.
dialog
?(
strongSelf
,
didTapNegative
:
strongSelf
.
controller
.
dialogView
.
negativeButton
)
handler
?()
handler
?()
}
}
return
self
return
self
...
@@ -169,8 +171,9 @@ open class Dialog: NSObject {
...
@@ -169,8 +171,9 @@ open class Dialog: NSObject {
@discardableResult
@discardableResult
open
func
neutral
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
Dialog
{
open
func
neutral
(
_
title
:
String
?,
handler
:
(()
->
Void
)?)
->
Dialog
{
dialogView
.
neutralButton
.
title
=
title
dialogView
.
neutralButton
.
title
=
title
controller
.
didTapNeutralButtonHandler
=
{
[
unowned
self
]
in
controller
.
didTapNeutralButtonHandler
=
{
[
weak
self
]
in
self
.
delegate
?
.
dialog
?(
self
,
didTapNeutral
:
self
.
controller
.
dialogView
.
neutralButton
)
guard
let
strongSelf
=
self
else
{
return
}
strongSelf
.
delegate
?
.
dialog
?(
strongSelf
,
didTapNeutral
:
strongSelf
.
controller
.
dialogView
.
neutralButton
)
handler
?()
handler
?()
}
}
return
self
return
self
...
@@ -185,8 +188,9 @@ open class Dialog: NSObject {
...
@@ -185,8 +188,9 @@ open class Dialog: NSObject {
@discardableResult
@discardableResult
open
func
isCancelable
(
_
value
:
Bool
,
handler
:
(()
->
Void
)?
=
nil
)
->
Dialog
{
open
func
isCancelable
(
_
value
:
Bool
,
handler
:
(()
->
Void
)?
=
nil
)
->
Dialog
{
controller
.
isCancelable
=
value
controller
.
isCancelable
=
value
controller
.
didCancelHandler
=
{
[
unowned
self
]
in
controller
.
didCancelHandler
=
{
[
weak
self
]
in
self
.
delegate
?
.
dialogDidCancel
?(
self
)
guard
let
strongSelf
=
self
else
{
return
}
strongSelf
.
delegate
?
.
dialogDidCancel
?(
strongSelf
)
handler
?()
handler
?()
}
}
return
self
return
self
...
@@ -200,8 +204,9 @@ open class Dialog: NSObject {
...
@@ -200,8 +204,9 @@ open class Dialog: NSObject {
*/
*/
@discardableResult
@discardableResult
open
func
shouldDismiss
(
handler
:
((
DialogView
,
Button
?)
->
Bool
)?)
->
Dialog
{
open
func
shouldDismiss
(
handler
:
((
DialogView
,
Button
?)
->
Bool
)?)
->
Dialog
{
controller
.
shouldDismissHandler
=
{
[
unowned
self
]
dialogView
,
button
in
controller
.
shouldDismissHandler
=
{
[
weak
self
]
dialogView
,
button
in
let
d
=
self
.
delegate
?
.
dialog
?(
self
,
shouldDismiss
:
button
)
??
true
guard
let
strongSelf
=
self
else
{
return
true
}
let
d
=
strongSelf
.
delegate
?
.
dialog
?(
strongSelf
,
shouldDismiss
:
button
)
??
true
let
h
=
handler
?(
dialogView
,
button
)
??
true
let
h
=
handler
?(
dialogView
,
button
)
??
true
return
d
&&
h
return
d
&&
h
}
}
...
@@ -215,8 +220,9 @@ open class Dialog: NSObject {
...
@@ -215,8 +220,9 @@ open class Dialog: NSObject {
*/
*/
@discardableResult
@discardableResult
open
func
willAppear
(
handler
:
(()
->
Void
)?)
->
Dialog
{
open
func
willAppear
(
handler
:
(()
->
Void
)?)
->
Dialog
{
controller
.
willAppear
=
{
[
unowned
self
]
in
controller
.
willAppear
=
{
[
weak
self
]
in
self
.
delegate
?
.
dialogWillAppear
?(
self
)
guard
let
strongSelf
=
self
else
{
return
}
strongSelf
.
delegate
?
.
dialogWillAppear
?(
strongSelf
)
handler
?()
handler
?()
}
}
return
self
return
self
...
@@ -229,10 +235,11 @@ open class Dialog: NSObject {
...
@@ -229,10 +235,11 @@ open class Dialog: NSObject {
*/
*/
@discardableResult
@discardableResult
open
func
didDisappear
(
handler
:
(()
->
Void
)?)
->
Dialog
{
open
func
didDisappear
(
handler
:
(()
->
Void
)?)
->
Dialog
{
controller
.
didDisappear
=
{
[
unowned
self
]
in
controller
.
didDisappear
=
{
[
weak
self
]
in
self
.
delegate
?
.
dialogDidDisappear
?(
self
)
guard
let
strongSelf
=
self
else
{
return
}
strongSelf
.
delegate
?
.
dialogDidDisappear
?(
strongSelf
)
handler
?()
handler
?()
self
.
controller
.
dialog
=
nil
s
trongS
elf
.
controller
.
dialog
=
nil
}
}
return
self
return
self
}
}
...
...
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