Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kt-ios
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
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Виктор
kt-ios
Commits
77bcef1e
Commit
77bcef1e
authored
Nov 01, 2017
by
Olzhas Aldabergenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chat bot open knowledge and service links as respective view controllers
parent
a3dbd190
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
126 additions
and
59 deletions
+126
-59
UserInterfaceState.xcuserstate
...cuserdata/neox.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
Breakpoints_v2.xcbkptlist
...ata/neox.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+27
-43
Facade+Bot.swift
kt/Facade/Facade+Bot.swift
+2
-0
BotManager.swift
kt/Managers/BotManager.swift
+6
-2
BotNode.swift
kt/Models/BotNode.swift
+10
-0
Main.storyboard
kt/Resources/Base.lproj/Main.storyboard
+0
-0
Localization.strings
kt/Resources/en.lproj/Localization.strings
+1
-0
Localization.strings
kt/Resources/kk.lproj/Localization.strings
+1
-0
Localization.strings
kt/Resources/ru.lproj/Localization.strings
+1
-1
BotLeftMessageCell.swift
kt/ViewControllers/BotLeftMessageCell.swift
+35
-2
BotViewController.swift
kt/ViewControllers/BotViewController.swift
+43
-11
No files found.
kt.xcworkspace/xcuserdata/neox.xcuserdatad/UserInterfaceState.xcuserstate
View file @
77bcef1e
No preview for this file type
kt.xcworkspace/xcuserdata/neox.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
77bcef1e
...
...
@@ -41,38 +41,6 @@
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"kt/ViewControllers/BotLeftMessageCell.swift"
timestampString =
"522067560.634483"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"65"
endingLineNumber =
"65"
landmarkName =
"bind(_:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"kt/ViewControllers/Cabinet/MainKnowedgeViewController.swift"
timestampString =
"527420051.899478"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"47"
endingLineNumber =
"47"
landmarkName =
"tableView(tableView:cellForRowAtIndexPath:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"kt/ViewControllers/Service/CallbackViewController.swift"
timestampString =
"528032989.334432"
startingColumnNumber =
"9223372036854775807"
...
...
@@ -182,16 +150,16 @@
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
shouldBeEnabled =
"
Yes
"
shouldBeEnabled =
"
No
"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"kt/ViewControllers/
Service/ServiceItemScroll
ViewController.swift"
timestampString =
"530
767730.950769
"
filePath =
"kt/ViewControllers/
FastPay/UIFastPay
ViewController.swift"
timestampString =
"530
168698.751804
"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"
287
"
endingLineNumber =
"
287
"
landmarkName =
"
prepareForSegue(segue:sender:
)"
startingLineNumber =
"
89
"
endingLineNumber =
"
89
"
landmarkName =
"
createCellsData(
)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
...
...
@@ -201,13 +169,29 @@
shouldBeEnabled =
"No"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"kt/ViewControllers/
FastPay/UIFastPayViewController
.swift"
timestampString =
"53
0168698.751804
"
filePath =
"kt/ViewControllers/
BotLeftMessageCell
.swift"
timestampString =
"53
1209142.403686
"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"89"
endingLineNumber =
"89"
landmarkName =
"createCellsData()"
startingLineNumber =
"67"
endingLineNumber =
"67"
landmarkName =
"bind(nodes:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"kt/ViewControllers/BotViewController.swift"
timestampString =
"531222126.771091"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"190"
endingLineNumber =
"190"
landmarkName =
"processService(_:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
...
...
kt/Facade/Facade+Bot.swift
View file @
77bcef1e
...
...
@@ -30,6 +30,8 @@ extension Facade {
botNode
.
text
=
n
[
"text"
]
.
string
botNode
.
expanded
=
n
[
"expanded"
]
.
int
botNode
.
isLink
=
n
[
"isLink"
]
.
int
botNode
.
entityId
=
n
[
"entity_id"
]
.
string
botNode
.
type
=
n
[
"type"
]
.
string
botNodes
.
append
(
botNode
)
}
let
res
=
BotResult
()
...
...
kt/Managers/BotManager.swift
View file @
77bcef1e
...
...
@@ -55,7 +55,7 @@ class BotManager {
return
nil
}
func
save
StoreFastPay
(
botResults
:
[
BotResult
])
{
func
save
BotResults
(
botResults
:
[
BotResult
])
{
let
archivedItems
=
archiveAll
(
botResults
)
NSUserDefaults
.
standardUserDefaults
()
.
setObject
(
archivedItems
,
forKey
:
UserDefaultsBotResultsKey
+
UserManager
.
sharedInstance
()
.
login
!
)
NSUserDefaults
.
standardUserDefaults
()
.
synchronize
()
...
...
@@ -67,7 +67,11 @@ class BotManager {
items
=
[]
}
items
!.
append
(
botResult
)
saveStoreFastPay
(
items
!
)
saveBotResults
(
items
!
)
}
func
addAll
(
items
:
[
BotResult
])
{
saveBotResults
(
items
)
}
}
kt/Models/BotNode.swift
View file @
77bcef1e
...
...
@@ -17,6 +17,8 @@ class BotNode: NSObject, NSCoding {
var
text
:
String
?
var
expanded
:
Int
?
var
isLink
:
Int
?
var
entityId
:
String
?
var
type
:
String
?
override
init
()
{
super
.
init
()
...
...
@@ -30,6 +32,12 @@ class BotNode: NSObject, NSCoding {
text
=
aDecoder
.
decodeObjectForKey
(
"text"
)
as!
String
?
expanded
=
aDecoder
.
decodeObjectForKey
(
"expanded"
)
as!
Int
?
isLink
=
aDecoder
.
decodeObjectForKey
(
"isLink"
)
as!
Int
?
if
(
aDecoder
.
containsValueForKey
(
"entityId"
)
)
{
entityId
=
aDecoder
.
decodeObjectForKey
(
"entityId"
)
as!
String
?
}
if
(
aDecoder
.
containsValueForKey
(
"type"
)
)
{
type
=
aDecoder
.
decodeObjectForKey
(
"type"
)
as!
String
?
}
}
func
encodeWithCoder
(
aCoder
:
NSCoder
)
{
...
...
@@ -40,6 +48,8 @@ class BotNode: NSObject, NSCoding {
aCoder
.
encodeObject
(
text
,
forKey
:
"text"
)
aCoder
.
encodeObject
(
expanded
,
forKey
:
"expanded"
)
aCoder
.
encodeObject
(
isLink
,
forKey
:
"isLink"
)
aCoder
.
encodeObject
(
entityId
,
forKey
:
"entityId"
)
aCoder
.
encodeObject
(
type
,
forKey
:
"type"
)
}
}
kt/Resources/Base.lproj/Main.storyboard
View file @
77bcef1e
This diff is collapsed.
Click to expand it.
kt/Resources/en.lproj/Localization.strings
View file @
77bcef1e
...
...
@@ -621,4 +621,5 @@
"registration_placeholder_login" = "Придумайте Ваш логин";
"registration_placeholder_password" = "Придумайте Ваш пароль";
"help" = "Помощь";
kt/Resources/kk.lproj/Localization.strings
View file @
77bcef1e
...
...
@@ -620,4 +620,5 @@
"registration_placeholder_login" = "Придумайте Ваш логин";
"registration_placeholder_password" = "Придумайте Ваш пароль";
"help" = "Помощь";
kt/Resources/ru.lproj/Localization.strings
View file @
77bcef1e
...
...
@@ -623,4 +623,4 @@
"registration_placeholder_login" = "Придумайте Ваш логин";
"registration_placeholder_password" = "Придумайте Ваш пароль";
"help" = "Помощь";
kt/ViewControllers/BotLeftMessageCell.swift
View file @
77bcef1e
...
...
@@ -8,7 +8,7 @@
import
UIKit
class
BotLeftMessageCell
:
UITableViewCell
,
UIPickerViewDataSource
,
UIPickerViewDelegate
,
UITextFieldDelegate
{
class
BotLeftMessageCell
:
UITableViewCell
,
UIPickerViewDataSource
,
UIPickerViewDelegate
,
UITextFieldDelegate
,
UITextViewDelegate
{
@IBOutlet
weak
var
container
:
UIView
!
@IBOutlet
weak
var
stackView
:
UIStackView
!
...
...
@@ -43,7 +43,7 @@ class BotLeftMessageCell: UITableViewCell, UIPickerViewDataSource, UIPickerViewD
self
.
showAbonentForm
(
UITapGestureRecognizer
())
}
}
else
{
let
label
=
UITextView
(
frame
:
CGRectMake
(
0
,
0
,
0
,
0
))
let
label
=
BotNode
UITextView
(
frame
:
CGRectMake
(
0
,
0
,
0
,
0
))
label
.
textAlignment
=
NSTextAlignment
.
Left
let
attrStr
=
try!
NSAttributedString
(
data
:
text
.
dataUsingEncoding
(
NSUnicodeStringEncoding
,
allowLossyConversion
:
true
)
!
,
options
:
[
NSDocumentTypeDocumentAttribute
:
NSHTMLTextDocumentType
],
documentAttributes
:
nil
)
label
.
attributedText
=
attrStr
...
...
@@ -59,7 +59,13 @@ class BotLeftMessageCell: UITableViewCell, UIPickerViewDataSource, UIPickerViewD
label
.
textColor
=
Color
.
ButtonBlueDefaultColor
}
label
.
tag
=
Int
(
id
)
!
label
.
botNode
=
node
label
.
delegate
=
self
self
.
stackView
.
addArrangedSubview
(
label
)
if
id
==
"27"
{
print
(
text
)
}
}
}
}
...
...
@@ -169,6 +175,27 @@ class BotLeftMessageCell: UITableViewCell, UIPickerViewDataSource, UIPickerViewD
}
}
func
textView
(
textView
:
UITextView
,
shouldInteractWithURL
URL
:
NSURL
,
inRange
characterRange
:
NSRange
)
->
Bool
{
if
let
textLabel
=
textView
as?
BotNodeUITextView
{
if
textLabel
.
botNode
!=
nil
{
if
(
textLabel
.
botNode
?
.
type
==
"1"
)
{
if
let
pc
=
parentViewController
as?
BotViewController
{
pc
.
processKnowledge
(
textLabel
.
botNode
!
)
}
return
false
}
else
if
(
textLabel
.
botNode
?
.
type
==
"2"
)
{
if
let
pc
=
parentViewController
as?
BotViewController
{
pc
.
processService
(
textLabel
.
botNode
!
)
}
return
false
}
}
}
return
true
;
}
func
getBalanceButtonTap
(
sender
:
UITapGestureRecognizer
)
{
if
typeForm
==
0
{
if
let
phoneText
=
phoneTextField
.
text
{
...
...
@@ -220,4 +247,10 @@ class BotLeftMessageCell: UITableViewCell, UIPickerViewDataSource, UIPickerViewD
textField
.
resignFirstResponder
()
return
true
}
}
class
BotNodeUITextView
:
UITextView
,
UITextViewDelegate
{
var
botNode
:
BotNode
?
}
kt/ViewControllers/BotViewController.swift
View file @
77bcef1e
...
...
@@ -126,20 +126,21 @@ class BotViewController: UIViewController, UITableViewDataSource, UITableViewDel
}
func
addMessage
(
botResult
:
BotResult
)
{
self
.
tableView
.
beginUpdates
()
self
.
messagesList
.
append
(
botResult
)
let
indexPath
=
NSIndexPath
(
forRow
:
(
self
.
messagesList
.
count
-
1
),
inSection
:
0
)
self
.
tableView
.
insertRowsAtIndexPaths
([
indexPath
],
withRowAnimation
:
UITableViewRowAnimation
.
Top
)
self
.
tableView
.
endUpdates
()
// self.tableView.beginUpdates()
// self.messagesList.append(botResult)
// let indexPath = NSIndexPath(forRow: (self.messagesList.count - 1), inSection: 0)
// self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top)
// self.tableView.endUpdates()
self
.
messagesList
.
append
(
botResult
)
self
.
tableView
.
reloadData
()
self
.
tableView
.
scrollToBottom
(
true
)
self
.
persist
(
botResult
)
self
.
persist
()
}
func
persist
(
botResult
:
BotResult
)
{
BotManager
.
sharedInstance
()
.
add
(
botResul
t
)
func
persist
()
{
BotManager
.
sharedInstance
()
.
add
All
(
self
.
messagesLis
t
)
}
func
reloadTable
()
{
...
...
@@ -166,6 +167,37 @@ class BotViewController: UIViewController, UITableViewDataSource, UITableViewDel
}
}
func
processKnowledge
(
botNode
:
BotNode
)
{
print
(
botNode
.
text
)
let
vc
=
self
.
storyboard
!.
instantiateViewControllerWithIdentifier
(
"KnowedgeQuestionsViewController"
)
as!
KnowedgeQuestionsViewController
vc
.
id
=
Int
(
botNode
.
entityId
!
)
!
vc
.
screenName
=
LS
(
"help"
)
self
.
navigationController
!.
pushViewController
(
vc
,
animated
:
true
)
}
func
processService
(
botNode
:
BotNode
)
{
let
params
:
[
String
:
AnyObject
]
=
[
"service_id"
:
Int
(
botNode
.
entityId
!
)
!
,
"type"
:
"landing"
]
Facade
.
sharedInstance
()
.
getLanding
(
params
,
onSuccess
:
{
(
serviceItem
)
in
serviceItem
.
type
=
"landing"
let
destination
=
self
.
storyboard
!.
instantiateViewControllerWithIdentifier
(
"ServiceItemScrollViewController"
)
as!
ServiceItemScrollViewController
destination
.
serviceItemForLoading
=
serviceItem
self
.
navigationController
!.
pushViewController
(
destination
,
animated
:
true
)
},
onError
:
{
(
error
)
in
print
(
error
)
},
onFinish
:
{
})
// let serviceItem = ServiceItem();
// serviceItem.id = Int(botNode.entityId!)!
// let destination = self.storyboard!.instantiateViewControllerWithIdentifier("ServiceItemScrollViewController") as! ServiceItemScrollViewController
// destination.serviceItemForLoading = serviceItem
// self.navigationController!.pushViewController(destination, animated: true)
}
func
getChildNodes
(
id
:
Int
)
{
Facade
.
sharedInstance
()
.
childBot
(
String
(
id
),
onSuccess
:
{
(
botResult
)
in
if
botResult
.
count
!=
0
{
...
...
@@ -200,7 +232,7 @@ class BotViewController: UIViewController, UITableViewDataSource, UITableViewDel
}
func
tableView
(
tableView
:
UITableView
,
estimatedHeightForRowAtIndexPath
indexPath
:
NSIndexPath
)
->
CGFloat
{
let
height
=
self
.
heightAtIndexPath
.
objectForKey
(
indexPath
)
let
height
=
self
.
heightAtIndexPath
.
objectForKey
(
indexPath
.
row
)
if
((
height
)
!=
nil
)
{
return
CGFloat
(
height
!.
floatValue
)
}
else
{
...
...
@@ -210,7 +242,7 @@ class BotViewController: UIViewController, UITableViewDataSource, UITableViewDel
func
tableView
(
tableView
:
UITableView
,
willDisplayCell
cell
:
UITableViewCell
,
forRowAtIndexPath
indexPath
:
NSIndexPath
)
{
let
height
=
cell
.
frame
.
size
.
height
self
.
heightAtIndexPath
.
setObject
(
height
,
forKey
:
indexPath
)
self
.
heightAtIndexPath
.
setObject
(
height
,
forKey
:
indexPath
.
row
)
}
}
...
...
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