From 940b9d02df3ad793ecf76b60d09e4e1e9c4d9887 Mon Sep 17 00:00:00 2001 From: Kartheek Date: Tue, 14 Apr 2020 19:21:51 +0530 Subject: [PATCH 01/11] For MS-42 --- .../BubbleViews/Chart/ChartBubbleView.swift | 8 +- .../Table/MiniTableBubbleView.swift | 145 ++++++++++++------ 2 files changed, 104 insertions(+), 49 deletions(-) diff --git a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift index a9c94903..008a9464 100644 --- a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift @@ -280,7 +280,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { rightOffset = CGFloat.maximum(rightOffset, (title as NSString).size(withAttributes: [NSAttributedString.Key.font : UIFont(name: "HelveticaNeue-Medium", size: 12.0)!]).width) } - let pieChartDataSet = PieChartDataSet(entries: values, label: "") + let pieChartDataSet = PieChartDataSet(values: values, label: "") pieChartDataSet.colors = colorsPalet() pieChartDataSet.sliceSpace = 2.0 @@ -378,7 +378,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { var dataSets: Array = Array() for i in 0.. = Array() for i in 0.. = Array() for _ in 0..<1 { - let dataSet = BarChartDataSet(entries: subDataValues, label:"") + let dataSet = BarChartDataSet(values: subDataValues, label:"") dataSet.stackLabels = titles let n = titles.count let colorsArr:[NSUIColor] = Array(colors.prefix(n)) diff --git a/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift b/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift index f0f2cf8d..591df3a6 100644 --- a/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift @@ -66,6 +66,7 @@ class MiniTableData { class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSource { var tableView: UITableView! + var titleLbl: UILabel! var cardView: UIView! let customCellIdentifier = "CustomCellIdentifier" var data: MiniTableData = MiniTableData() @@ -73,6 +74,11 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc var align0:NSTextAlignment = .left var align1:NSTextAlignment = .left + let kMaxTextWidth: CGFloat = BubbleViewMaxWidth - 20.0 + let kMinTextWidth: CGFloat = 20.0 + + var tileBgv: UIView! + override func applyBubbleMask() { //nothing to put here } @@ -97,11 +103,24 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc let cardViews: [String: UIView] = ["cardView": cardView] self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-15-[cardView]-15-|", options: [], metrics: nil, views: cardViews)) self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-15-[cardView]-15-|", options: [], metrics: nil, views: cardViews)) + } override func initialize() { super.initialize() intializeCardLayout() + + + self.tileBgv = UIView(frame:.zero) + self.tileBgv.translatesAutoresizingMaskIntoConstraints = false + self.cardView.addSubview(self.tileBgv) + self.tileBgv.layer.rasterizationScale = UIScreen.main.scale + self.tileBgv.layer.shouldRasterize = true + self.tileBgv.layer.cornerRadius = 6.0 + self.tileBgv.clipsToBounds = true + self.tileBgv.backgroundColor = Common.UIColorRGB(0xEDEFF2) + + self.tableView = UITableView(frame: CGRect.zero,style:.grouped) self.tableView.translatesAutoresizingMaskIntoConstraints = false self.tableView.dataSource = self @@ -112,14 +131,34 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc self.tableView.bounces = false self.tableView.separatorStyle = .none self.cardView.addSubview(self.tableView) + self.tableView.isScrollEnabled = false tableView.register(MiniTableViewCell.self, forCellReuseIdentifier: customCellIdentifier) - let views: [String: UIView] = ["tableView": tableView] - - self.cardView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-15-[tableView]-15-|", options: [], metrics: nil, views: views)) + let views: [String: UIView] = ["tileBgv": tileBgv, "tableView": tableView] + self.cardView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-15-[tileBgv]-[tableView]-20-|", options: [], metrics: nil, views: views)) + self.cardView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-25-[tileBgv]-25-|", options: [], metrics: nil, views: views)) self.cardView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-15-[tableView]-15-|", options: [], metrics: nil, views: views)) + + self.titleLbl = UILabel(frame: CGRect.zero) + self.titleLbl.textColor = Common.UIColorRGB(0x484848) + self.titleLbl.font = UIFont(name: "HelveticaNeue-Medium", size: 16.0) + self.titleLbl.numberOfLines = 0 + self.titleLbl.lineBreakMode = NSLineBreakMode.byWordWrapping + self.titleLbl.isUserInteractionEnabled = true + self.titleLbl.contentMode = UIView.ContentMode.topLeft + self.titleLbl.translatesAutoresizingMaskIntoConstraints = false + self.tileBgv.addSubview(self.titleLbl) + self.titleLbl.adjustsFontSizeToFitWidth = true + self.titleLbl.backgroundColor = .clear + self.titleLbl.layer.cornerRadius = 6.0 + self.titleLbl.clipsToBounds = true + self.titleLbl.sizeToFit() + + let subView: [String: UIView] = ["titleLbl": titleLbl] + self.tileBgv.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-5-[titleLbl(>=31)]-5-|", options: [], metrics: nil, views: subView)) + self.tileBgv.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-10-[titleLbl]-10-|", options: [], metrics: nil, views: subView)) } - + override func populateComponents() { if (components.count > 0) { let component: KREComponent = components.firstObject as! KREComponent @@ -140,52 +179,56 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc if self.data.rows[self.data.rows.count-1][0] != "---" { self.data.rows.append(["---"]) } + self.titleLbl.text = "\(data["text"] ?? "")" self.tableView.reloadData() - } + } } } - func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - - return UITableView.automaticDimension - } + + func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - - return data.rows[section].count/2 - } + return UITableView.automaticDimension + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - func numberOfSections(in tableView: UITableView) -> Int { - - return data.elements.count - } + return UITableView.automaticDimension + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return data.rows[section].count/2 + } + + func numberOfSections(in tableView: UITableView) -> Int { + return data.elements.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell : MiniTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: customCellIdentifier) as! MiniTableViewCell - let rows = data.rows[indexPath.section] - if (rows.count > (indexPath.row * 2)){ - cell.headerLabel.text = rows[indexPath.row*2] - cell.headerLabel.font = UIFont(name: "Lato-Regular", size: 15.0) - cell.headerLabel.font = cell.headerLabel.font.withSize(15.0) - cell.headerLabel.textColor = UIColor(red: 138/255, green: 149/255, blue: 159/255, alpha: 1) - } - if (rows.count > (indexPath.row * 2+1)){ - cell.secondLbl.text = rows[indexPath.row*2+1] - cell.secondLbl.font = UIFont(name: "Lato-Regular", size: 15.0) - cell.secondLbl.font = cell.headerLabel.font.withSize(15.0) - - cell.secondLbl.textColor = UIColor(red: 138/255, green: 149/255, blue: 159/255, alpha: 1) - } - cell.backgroundColor = UIColor.white - + let cell : MiniTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: customCellIdentifier) as! MiniTableViewCell + let rows = data.rows[indexPath.section] + if (rows.count > (indexPath.row * 2)){ + cell.headerLabel.text = rows[indexPath.row*2] + cell.headerLabel.font = UIFont(name: "Lato-Regular", size: 15.0) + cell.headerLabel.font = cell.headerLabel.font.withSize(15.0) + cell.headerLabel.textColor = UIColor(red: 138/255, green: 149/255, blue: 159/255, alpha: 1) + } + if (rows.count > (indexPath.row * 2+1)){ + cell.secondLbl.text = rows[indexPath.row*2+1] + cell.secondLbl.font = UIFont(name: "Lato-Regular", size: 15.0) + cell.secondLbl.font = cell.headerLabel.font.withSize(15.0) - return cell - + cell.secondLbl.textColor = UIColor(red: 138/255, green: 149/255, blue: 159/255, alpha: 1) } - + cell.backgroundColor = UIColor.white + return cell + + } + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = UIView() @@ -194,7 +237,7 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc headerLabel.textAlignment = .left headerLabel.font = UIFont(name: "Lato-Bold", size: 15.0) headerLabel.font = headerLabel.font.withSize(15.0) - + headerLabel.textColor = UIColor(red: 38/255, green: 52/255, blue: 74/255, alpha: 1) headerLabel.text = data.headers[section*2].title view.addSubview(headerLabel) @@ -224,22 +267,34 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc view.layer.shadowOpacity = 1.0 return view } - - override var intrinsicContentSize : CGSize { + + override var intrinsicContentSize : CGSize { + + let limitingSize: CGSize = CGSize(width: kMaxTextWidth, height: CGFloat.greatestFiniteMagnitude) + var textSize: CGSize = self.titleLbl.sizeThatFits(limitingSize) + if textSize.height < self.titleLbl.font.pointSize { + textSize.height = self.titleLbl.font.pointSize + } + + var cellHeight : CGFloat = 0.0 let rows = self.data.rows - var height: CGFloat = 38.0 + var finalHeight: CGFloat = 0.0 for i in 0.. Date: Mon, 20 Apr 2020 19:17:11 +0530 Subject: [PATCH 02/11] For MS-40, MS-1 and MS-23 --- Examples/Shared/Common/KABotClient.swift | 4 ++-- .../Controllers/AppLaunch/AppLaunchViewController.swift | 5 +++++ .../Shared/Library/BubbleViews/Chart/ChartBubbleView.swift | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Examples/Shared/Common/KABotClient.swift b/Examples/Shared/Common/KABotClient.swift index ebe5c558..fb130a6f 100644 --- a/Examples/Shared/Common/KABotClient.swift +++ b/Examples/Shared/Common/KABotClient.swift @@ -367,7 +367,7 @@ open class KABotClient: NSObject { context.perform { let resources: Dictionary = ["threadId": botId as AnyObject, "subject": chatBotName as AnyObject, "messages":[] as AnyObject] - dataStoreManager.deleteThreadIfRequired(with: botId, completionBlock: { (success) in + //dataStoreManager.deleteThreadIfRequired(with: botId, completionBlock: { (success) in dataStoreManager.insertOrUpdateThread(dictionary: resources, with: {(thread1) in self?.thread = thread1 try? context.save() @@ -383,7 +383,7 @@ open class KABotClient: NSObject { failure?(error!) }) }) - }) + //}) } }, failure: { (error) in print(error) diff --git a/Examples/Shared/Controllers/AppLaunch/AppLaunchViewController.swift b/Examples/Shared/Controllers/AppLaunch/AppLaunchViewController.swift index 20e71fa7..89a9345b 100644 --- a/Examples/Shared/Controllers/AppLaunch/AppLaunchViewController.swift +++ b/Examples/Shared/Controllers/AppLaunch/AppLaunchViewController.swift @@ -72,6 +72,11 @@ class AppLaunchViewController: UIViewController { identity = SDKConfiguration.botConfig.identity } + let dataStoreManager: DataStoreManager = DataStoreManager.sharedManager + dataStoreManager.deleteThreadIfRequired(with: botId, completionBlock: { (success) in + print("Delete Sucess") + }) + if !clientId.hasPrefix("<") && !clientSecret.hasPrefix("<") && !chatBotName.hasPrefix("<") && !botId.hasPrefix("<") && !identity.hasPrefix("<") { let activityIndicatorView: UIActivityIndicatorView = UIActivityIndicatorView(style: .white) activityIndicatorView.center = chatButton.center diff --git a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift index 008a9464..5daec205 100644 --- a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift @@ -143,7 +143,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.cardView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-15-[lcView]-15-|", options: [], metrics: nil, views: views)) self.lcView.chartDescription?.enabled = false - self.lcView.isUserInteractionEnabled = false + self.lcView.isUserInteractionEnabled = true self.lcView.leftAxis.enabled = true self.lcView.leftAxis.drawAxisLineEnabled = true @@ -164,6 +164,9 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.lcView.dragEnabled = true self.lcView.pinchZoomEnabled = true + let marker = BalloonMarker(color: UIColor.white.withAlphaComponent(0.9), font: UIFont(name: "HelveticaNeue-Bold", size: 12.0)!, textColor: .black, insets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 20.0, right: 8.0)) + self.lcView.marker = marker + let l: Legend = self.lcView.legend l.horizontalAlignment = .right l.verticalAlignment = .top @@ -394,7 +397,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.xAxisValues = headers self.lcView.data = lineChartData self.lcView.xAxis.labelCount = headers.count - lcView.animate(xAxisDuration: 1.0, easingOption: ChartEasingOption.easeInElastic) + lcView.animate(xAxisDuration: 2.5, easingOption: ChartEasingOption.easeInOutBack) } func setDataForBarChart(_ jsonObject: NSDictionary){ let stacked = jsonObject["stacked"] != nil ? jsonObject["stacked"] as! Bool : false From 1f420b2d6f7fe2c0c04ede79e1a8db65042dd4b9 Mon Sep 17 00:00:00 2001 From: Kartheek Date: Mon, 20 Apr 2020 19:48:47 +0530 Subject: [PATCH 03/11] For Remove MS-23 --- Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift index 5daec205..297828cf 100644 --- a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift @@ -397,7 +397,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.xAxisValues = headers self.lcView.data = lineChartData self.lcView.xAxis.labelCount = headers.count - lcView.animate(xAxisDuration: 2.5, easingOption: ChartEasingOption.easeInOutBack) + lcView.animate(xAxisDuration: 1.0, easingOption: ChartEasingOption.easeInOutElastic) } func setDataForBarChart(_ jsonObject: NSDictionary){ let stacked = jsonObject["stacked"] != nil ? jsonObject["stacked"] as! Bool : false From 542abe2d600b7b7afafcd733f97a99411fa41c3b Mon Sep 17 00:00:00 2001 From: Kartheek Date: Mon, 20 Apr 2020 20:03:17 +0530 Subject: [PATCH 04/11] For MS-23 The animation of line chart template is not smooth --- Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift index 297828cf..5daec205 100644 --- a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift @@ -397,7 +397,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.xAxisValues = headers self.lcView.data = lineChartData self.lcView.xAxis.labelCount = headers.count - lcView.animate(xAxisDuration: 1.0, easingOption: ChartEasingOption.easeInOutElastic) + lcView.animate(xAxisDuration: 2.5, easingOption: ChartEasingOption.easeInOutBack) } func setDataForBarChart(_ jsonObject: NSDictionary){ let stacked = jsonObject["stacked"] != nil ? jsonObject["stacked"] as! Bool : false From 818a6de998bc623d09f47954f1809b6f2e3ec2d4 Mon Sep 17 00:00:00 2001 From: Kartheek Date: Mon, 20 Apr 2020 20:42:09 +0530 Subject: [PATCH 05/11] For MS-42 --- Examples/CocoapodsDemo/SDKConfiguration.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Examples/CocoapodsDemo/SDKConfiguration.swift b/Examples/CocoapodsDemo/SDKConfiguration.swift index 31a51fcd..08ced35b 100644 --- a/Examples/CocoapodsDemo/SDKConfiguration.swift +++ b/Examples/CocoapodsDemo/SDKConfiguration.swift @@ -16,21 +16,20 @@ class SDKConfiguration: NSObject { } struct botConfig { - static let clientId = "" // Copy this value from Bot Builder SDK Settings ex. cs-5250bdc9-6bfe-5ece-92c9-ab54aa2d4285 + static let clientId = "cs-3dd6a21c-70ef-5d52-b742-7b9dcf6a6a89" - static let clientSecret = "" // Copy this value from Bot Builder SDK Settings ex. Wibn3ULagYyq0J10LCndswYycHGLuIWbwHvTRSfLwhs= + static let clientSecret = "Zf/sPAMUgD4Hl/y6nUELodw6DJu9cuzaytcAyqL5gO8=" + static let botId = "st-05303785-9992-526c-a83c-be3252fd478e" - static let botId = "" // Copy this value from Bot Builder -> Channels -> Web/Mobile Client ex. st-acecd91f-b009-5f3f-9c15-7249186d827d - - static let chatBotName = "" // Copy this value from Bot Builder -> Channels -> Web/Mobile Client ex. "Demo Bot" + static let chatBotName = "CanCan" - static let identity = " or "// This should represent the subject for JWT token. This can be an email or phone number, in case of known user, and in case of anonymous user, this can be a randomly generated unique id. + static let identity = "sainath.bhima@kore.com" - static let isAnonymous = false // This should be either true (in case of known-user) or false (in-case of anonymous user). + static let isAnonymous = true } struct serverConfig { - static let JWT_SERVER = String(format: "http:///") // Replace it with the actual JWT server URL, if required. Refer to developer documentation for instructions on hosting JWT Server. + static let JWT_SERVER = String(format: "https://demo.kore.net/") // Replace it with the actual JWT server URL, if required. Refer to developer documentation for instructions on hosting JWT Server. static func koreJwtUrl() -> String { return String(format: "%@users/sts", JWT_SERVER) From ad33093a041f6fa2f4d8a9911d076094cbf87c68 Mon Sep 17 00:00:00 2001 From: Kartheek Date: Mon, 27 Apr 2020 18:04:34 +0530 Subject: [PATCH 06/11] For MS-42 Mini Table text being displayed --- .../KoreBotSDKDemo.xcodeproj/project.pbxproj | 4 ---- .../Library/BubbleViews/Table/MiniTableBubbleView.swift | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Examples/CocoapodsDemo/KoreBotSDKDemo.xcodeproj/project.pbxproj b/Examples/CocoapodsDemo/KoreBotSDKDemo.xcodeproj/project.pbxproj index f99a18a8..a63e498e 100644 --- a/Examples/CocoapodsDemo/KoreBotSDKDemo.xcodeproj/project.pbxproj +++ b/Examples/CocoapodsDemo/KoreBotSDKDemo.xcodeproj/project.pbxproj @@ -685,8 +685,6 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-KoreBotSDKDemo/Pods-KoreBotSDKDemo-frameworks.sh", "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", @@ -696,8 +694,6 @@ "${BUILT_PRODUCTS_DIR}/SocketRocket/SocketRocket.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Charts.framework", diff --git a/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift b/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift index 591df3a6..08b288be 100644 --- a/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift @@ -81,6 +81,12 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc override func applyBubbleMask() { //nothing to put here + if(self.maskLayer == nil){ + self.maskLayer = CAShapeLayer() + self.tileBgv.layer.mask = self.maskLayer + } + self.maskLayer.path = self.createBezierPath().cgPath + self.maskLayer.position = CGPoint(x:0, y:0) } override var tailPosition: BubbleMaskTailPosition! { @@ -116,7 +122,7 @@ class MiniTableBubbleView: BubbleView, UITableViewDelegate, UITableViewDataSourc self.cardView.addSubview(self.tileBgv) self.tileBgv.layer.rasterizationScale = UIScreen.main.scale self.tileBgv.layer.shouldRasterize = true - self.tileBgv.layer.cornerRadius = 6.0 + self.tileBgv.layer.cornerRadius = 2.0 self.tileBgv.clipsToBounds = true self.tileBgv.backgroundColor = Common.UIColorRGB(0xEDEFF2) From 390b7014b2045d53b7f4a497c3dfe4c1816dcc1f Mon Sep 17 00:00:00 2001 From: Kartheek Date: Mon, 27 Apr 2020 18:07:59 +0530 Subject: [PATCH 07/11] Configuration data Removed --- Examples/CocoapodsDemo/SDKConfiguration.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Examples/CocoapodsDemo/SDKConfiguration.swift b/Examples/CocoapodsDemo/SDKConfiguration.swift index 08ced35b..420c0887 100644 --- a/Examples/CocoapodsDemo/SDKConfiguration.swift +++ b/Examples/CocoapodsDemo/SDKConfiguration.swift @@ -16,20 +16,21 @@ class SDKConfiguration: NSObject { } struct botConfig { - static let clientId = "cs-3dd6a21c-70ef-5d52-b742-7b9dcf6a6a89" + static let clientId = "" // Copy this value from Bot Builder SDK Settings ex. cs-5250bdc9-6bfe-5ece-92c9-ab54aa2d4285 - static let clientSecret = "Zf/sPAMUgD4Hl/y6nUELodw6DJu9cuzaytcAyqL5gO8=" - static let botId = "st-05303785-9992-526c-a83c-be3252fd478e" + static let clientSecret = "" // Copy this value from Bot Builder SDK Settings ex. Wibn3ULagYyq0J10LCndswYycHGLuIWbwHvTRSfLwhs= - static let chatBotName = "CanCan" + static let botId = "" // Copy this value from Bot Builder -> Channels -> Web/Mobile Client ex. st-acecd91f-b009-5f3f-9c15-7249186d827d - static let identity = "sainath.bhima@kore.com" + static let chatBotName = "" // Copy this value from Bot Builder -> Channels -> Web/Mobile Client ex. "Demo Bot" - static let isAnonymous = true + static let identity = " or "// This should represent the subject for JWT token. This can be an email or phone number, in case of known user, and in case of anonymous user, this can be a randomly generated unique id. + + static let isAnonymous = false // This should be either true (in case of known-user) or false (in-case of anonymous user). } struct serverConfig { - static let JWT_SERVER = String(format: "https://demo.kore.net/") // Replace it with the actual JWT server URL, if required. Refer to developer documentation for instructions on hosting JWT Server. + static let JWT_SERVER = String(format: "http:///") // Replace it with the actual JWT server URL, if required. Refer to developer documentation for instructions on hosting JWT Server. static func koreJwtUrl() -> String { return String(format: "%@users/sts", JWT_SERVER) From 930fa5edabeb32c1bacb490ce353fbae7ba9c491 Mon Sep 17 00:00:00 2001 From: Kartheek Date: Tue, 5 May 2020 06:25:07 +0530 Subject: [PATCH 08/11] For Ms-1, MS-14, MS-15, MS-16, MS-21, MS-23 ,MS-27, MS-29 and MS-40 --- Examples/Shared/Common/KABotClient.swift | 3 - .../BubbleViews/Chart/ChartBubbleView.swift | 118 +++++++++++------- 2 files changed, 71 insertions(+), 50 deletions(-) diff --git a/Examples/Shared/Common/KABotClient.swift b/Examples/Shared/Common/KABotClient.swift index fb130a6f..2adabc1c 100644 --- a/Examples/Shared/Common/KABotClient.swift +++ b/Examples/Shared/Common/KABotClient.swift @@ -366,8 +366,6 @@ open class KABotClient: NSObject { let context = dataStoreManager.coreDataManager.workerContext context.perform { let resources: Dictionary = ["threadId": botId as AnyObject, "subject": chatBotName as AnyObject, "messages":[] as AnyObject] - - //dataStoreManager.deleteThreadIfRequired(with: botId, completionBlock: { (success) in dataStoreManager.insertOrUpdateThread(dictionary: resources, with: {(thread1) in self?.thread = thread1 try? context.save() @@ -383,7 +381,6 @@ open class KABotClient: NSObject { failure?(error!) }) }) - //}) } }, failure: { (error) in print(error) diff --git a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift index 5daec205..f0a7f71a 100644 --- a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift @@ -18,7 +18,8 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { public var optionsAction: ((_ text: String?) -> Void)! public var linkAction: ((_ text: String?) -> Void)! - + var cellHeight: Double = 280.0 + var lengendsLimit = 5 override func applyBubbleMask() { //nothing to put here } @@ -69,7 +70,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } // MARK: initialize chart views - func intializePieChartView(_ pieType: String){ + func intializePieChartView(_ jsonObject: NSDictionary,_ pieType: String){ intializeCardLayout() self.pcView = PieChartView() @@ -80,11 +81,22 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.cardView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-15-[pcView]-15-|", options: [], metrics: nil, views: views)) self.cardView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-15-[pcView]-15-|", options: [], metrics: nil, views: views)) + let elements: Array> = jsonObject["elements"] != nil ? jsonObject["elements"] as! Array> : [] + let elementsCount: Int = elements.count + let l: Legend = self.pcView.legend - if(pieType == "regular"){ + if elementsCount > lengendsLimit{ + l.horizontalAlignment = .right + l.verticalAlignment = .bottom + l.orientation = .horizontal + cellHeight = 380 + }else{ l.horizontalAlignment = .right l.verticalAlignment = .top l.orientation = .vertical + cellHeight = 280 + } + if(pieType == "regular"){ l.drawInside = false l.formSize = 12.0 l.textColor = UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1) @@ -96,11 +108,9 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.pcView.drawEntryLabelsEnabled = false self.pcView.extraRightOffset = 0.0 self.pcView.rotationEnabled = false + } if(pieType == "donut"){ - l.horizontalAlignment = .right - l.verticalAlignment = .top - l.orientation = .vertical l.drawInside = false l.formSize = 12.0 l.textColor = UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1) @@ -111,12 +121,10 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.pcView.drawEntryLabelsEnabled = false self.pcView.extraRightOffset = 0.0 self.pcView.rotationEnabled = false -// self.pcView.legend.enabled = false + // self.pcView.legend.enabled = false + } if(pieType == "donut_legend"){ - l.horizontalAlignment = .right - l.verticalAlignment = .center - l.orientation = .vertical l.drawInside = false l.formSize = 12.0 l.textColor = UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1) @@ -129,7 +137,10 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.pcView.extraRightOffset = 5.0 self.pcView.rotationEnabled = false + let marker = BalloonMarker(color: UIColor.white.withAlphaComponent(0.9), font: UIFont(name: "HelveticaNeue-Bold", size: 12.0)!, textColor: .black, insets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 20.0, right: 8.0)) + self.pcView.marker = marker } + } func intializeLineChartView(){ @@ -162,7 +173,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.lcView.drawGridBackgroundEnabled = false self.lcView.drawBordersEnabled = false self.lcView.dragEnabled = true - self.lcView.pinchZoomEnabled = true + self.lcView.pinchZoomEnabled = false let marker = BalloonMarker(color: UIColor.white.withAlphaComponent(0.9), font: UIFont(name: "HelveticaNeue-Bold", size: 12.0)!, textColor: .black, insets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 20.0, right: 8.0)) self.lcView.marker = marker @@ -176,11 +187,12 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { l.textColor = UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1) l.font = UIFont(name: "HelveticaNeue-Medium", size: 12.0)! l.form = .circle + cellHeight = 280.0 } func intializeBarChartView(_ direction:String){ - intializeCardLayout() + intializeCardLayout() if(direction == "horizontal"){ self.bcView = HorizontalBarChartView() @@ -198,13 +210,18 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.bcView.chartDescription?.enabled = false if(direction == "horizontal"){ self.bcView.leftAxis.enabled = false + self.bcView.rightAxis.enabled = true }else{ - self.bcView.leftAxis.enabled = true + self.bcView.leftAxis.enabled = true + self.bcView.rightAxis.enabled = false } self.bcView.leftAxis.drawAxisLineEnabled = true self.bcView.leftAxis.drawGridLinesEnabled = false self.bcView.leftAxis.labelTextColor = UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1) - self.bcView.rightAxis.enabled = false + + self.bcView.rightAxis.drawAxisLineEnabled = true + self.bcView.rightAxis.drawGridLinesEnabled = false + self.bcView.rightAxis.labelTextColor = UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1) self.bcView.xAxis.labelPosition = .bottom self.bcView.xAxis.labelTextColor = UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1) @@ -229,6 +246,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { let marker = BalloonMarker(color: UIColor.white.withAlphaComponent(0.9), font: UIFont(name: "HelveticaNeue-Bold", size: 12.0)!, textColor: .black, insets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 20.0, right: 8.0)) self.bcView.marker = marker + cellHeight = 280.0 } override func borderColor() -> UIColor { @@ -237,12 +255,12 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { func colorsPalet() -> [NSUIColor]{ var colors: Array = Array() -// colors.append(Common.UIColorRGB(0x5F6BF7)) -// colors.append(Common.UIColorRGB(0xF78083)) -// colors.append(Common.UIColorRGB(0x41C5D3)) -// colors.append(Common.UIColorRGB(0xC4AFF0)) -// colors.append(Common.UIColorRGB(0x2ecc71)) -// colors.append(Common.UIColorRGB(0x1abc9c)) + // colors.append(Common.UIColorRGB(0x5F6BF7)) + // colors.append(Common.UIColorRGB(0xF78083)) + // colors.append(Common.UIColorRGB(0x41C5D3)) + // colors.append(Common.UIColorRGB(0xC4AFF0)) + // colors.append(Common.UIColorRGB(0x2ecc71)) + // colors.append(Common.UIColorRGB(0x1abc9c)) colors.append( UIColor(red: 95/255, green: 107/255, blue: 247/255, alpha: 1)) colors.append( UIColor(red: 153/255, green: 237/255, blue: 158/255, alpha: 1)) colors.append( UIColor(red: 247/255, green: 128/255, blue: 131/255, alpha: 1)) @@ -254,8 +272,9 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { colors.append( UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1)) colors.append( UIColor(red: 156/255, green: 235/255, blue: 249/255, alpha: 1)) colors.append( UIColor(red: 247/255, green: 199/255, blue: 244/255, alpha: 1)) - - + + + colors.append(contentsOf: ChartColorTemplates.colorful()) colors.append(contentsOf: ChartColorTemplates.joyful()) colors.append(contentsOf: ChartColorTemplates.liberty()) @@ -270,18 +289,24 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { let elements: Array> = jsonObject["elements"] != nil ? jsonObject["elements"] as! Array> : [] let elementsCount: Int = elements.count var values: Array = Array() - var rightOffset: CGFloat = 0.0 + var rightOffset: CGFloat = 2.0 for i in 0..(input: [[T]]) -> [[T]] { @@ -378,7 +402,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } var colors = colorsPalet() - + var dataSets: Array = Array() for i in 0.. = dictionary["values"] != nil ? dictionary["values"] as! Array : [] valuesArray.append(values) } @@ -479,13 +503,13 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } subDataValues.append(BarChartDataEntry(x: Double(j), yValues: values)) } - - - + + + let colors = colorsPalet() -// var colorsArray: Array = Array() -// colorsArray.append(colors[0]) - + // var colorsArray: Array = Array() + // colorsArray.append(colors[0]) + var dataSets: Array = Array() for _ in 0..<1 { let dataSet = BarChartDataSet(values: subDataValues, label:"") @@ -495,7 +519,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { dataSet.colors = colorsArr dataSets.append(dataSet) } - + let barChartData = BarChartData(dataSets: dataSets) barChartData.setValueTextColor(UIColor(red: 179/255, green: 186/255, blue: 200/255, alpha: 1)) barChartData.setValueFont(UIFont(name: "HelveticaNeue-Medium", size: 8.0) ?? UIFont.systemFont(ofSize: 8.0, weight: .medium)) @@ -513,7 +537,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { self.xAxisValues = headers bcView.fitBars = true self.bcView.data = barChartData - + self.bcView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0) self.bcView.setVisibleXRangeMaximum(Double(headers.count)) } @@ -521,11 +545,11 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { func initializeViewForType(_ type: String, jsonObject: NSDictionary){ if type == "piechart" { let pieType = jsonObject["pie_type"] != nil ? jsonObject["pie_type"] as! String : "regular" - intializePieChartView(pieType) + intializePieChartView(jsonObject,pieType) }else if type == "linechart" { intializeLineChartView() }else if type == "barchart" { - let direction = jsonObject["direction"] != nil ? jsonObject["direction"] as! String : "horizontal" + let direction = jsonObject["direction"] != nil ? jsonObject["direction"] as! String : "horizontal" intializeBarChartView(direction) } } @@ -562,7 +586,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } override var intrinsicContentSize : CGSize { - return CGSize(width: 0.0, height: 280) + return CGSize(width: 0.0, height: cellHeight) //280 } override func prepareForReuse() { From 85d86d3576e12794b5c47e29f5c0cb75d8fbd44b Mon Sep 17 00:00:00 2001 From: Kartheek Date: Tue, 5 May 2020 06:37:54 +0530 Subject: [PATCH 09/11] For Ms-1, MS-14, MS-15, MS-16, MS-21, MS-23 ,MS-27, MS-29 and MS-40 --- Examples/Shared/Common/KABotClient.swift | 2 +- .../Library/BubbleViews/Chart/ChartBubbleView.swift | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Examples/Shared/Common/KABotClient.swift b/Examples/Shared/Common/KABotClient.swift index 2adabc1c..9f6e1983 100644 --- a/Examples/Shared/Common/KABotClient.swift +++ b/Examples/Shared/Common/KABotClient.swift @@ -365,7 +365,7 @@ open class KABotClient: NSObject { let dataStoreManager: DataStoreManager = DataStoreManager.sharedManager let context = dataStoreManager.coreDataManager.workerContext context.perform { - let resources: Dictionary = ["threadId": botId as AnyObject, "subject": chatBotName as AnyObject, "messages":[] as AnyObject] + let resources: Dictionary = ["threadId": botId as AnyObject, "subject": chatBotName as AnyObject, "messages":[] as AnyObject] dataStoreManager.insertOrUpdateThread(dictionary: resources, with: {(thread1) in self?.thread = thread1 try? context.save() diff --git a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift index f0a7f71a..251ba95e 100644 --- a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift @@ -255,12 +255,6 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { func colorsPalet() -> [NSUIColor]{ var colors: Array = Array() - // colors.append(Common.UIColorRGB(0x5F6BF7)) - // colors.append(Common.UIColorRGB(0xF78083)) - // colors.append(Common.UIColorRGB(0x41C5D3)) - // colors.append(Common.UIColorRGB(0xC4AFF0)) - // colors.append(Common.UIColorRGB(0x2ecc71)) - // colors.append(Common.UIColorRGB(0x1abc9c)) colors.append( UIColor(red: 95/255, green: 107/255, blue: 247/255, alpha: 1)) colors.append( UIColor(red: 153/255, green: 237/255, blue: 158/255, alpha: 1)) colors.append( UIColor(red: 247/255, green: 128/255, blue: 131/255, alpha: 1)) @@ -586,7 +580,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } override var intrinsicContentSize : CGSize { - return CGSize(width: 0.0, height: cellHeight) //280 + return CGSize(width: 0.0, height: cellHeight) } override func prepareForReuse() { From 7cef35465cb64b38256cae196b634dd7850790e3 Mon Sep 17 00:00:00 2001 From: Kartheek Date: Tue, 5 May 2020 06:37:54 +0530 Subject: [PATCH 10/11] Bug Fixes --- Examples/Shared/Common/KABotClient.swift | 2 +- .../Library/BubbleViews/Chart/ChartBubbleView.swift | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Examples/Shared/Common/KABotClient.swift b/Examples/Shared/Common/KABotClient.swift index 2adabc1c..9f6e1983 100644 --- a/Examples/Shared/Common/KABotClient.swift +++ b/Examples/Shared/Common/KABotClient.swift @@ -365,7 +365,7 @@ open class KABotClient: NSObject { let dataStoreManager: DataStoreManager = DataStoreManager.sharedManager let context = dataStoreManager.coreDataManager.workerContext context.perform { - let resources: Dictionary = ["threadId": botId as AnyObject, "subject": chatBotName as AnyObject, "messages":[] as AnyObject] + let resources: Dictionary = ["threadId": botId as AnyObject, "subject": chatBotName as AnyObject, "messages":[] as AnyObject] dataStoreManager.insertOrUpdateThread(dictionary: resources, with: {(thread1) in self?.thread = thread1 try? context.save() diff --git a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift index f0a7f71a..251ba95e 100644 --- a/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift +++ b/Examples/Shared/Library/BubbleViews/Chart/ChartBubbleView.swift @@ -255,12 +255,6 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { func colorsPalet() -> [NSUIColor]{ var colors: Array = Array() - // colors.append(Common.UIColorRGB(0x5F6BF7)) - // colors.append(Common.UIColorRGB(0xF78083)) - // colors.append(Common.UIColorRGB(0x41C5D3)) - // colors.append(Common.UIColorRGB(0xC4AFF0)) - // colors.append(Common.UIColorRGB(0x2ecc71)) - // colors.append(Common.UIColorRGB(0x1abc9c)) colors.append( UIColor(red: 95/255, green: 107/255, blue: 247/255, alpha: 1)) colors.append( UIColor(red: 153/255, green: 237/255, blue: 158/255, alpha: 1)) colors.append( UIColor(red: 247/255, green: 128/255, blue: 131/255, alpha: 1)) @@ -586,7 +580,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } override var intrinsicContentSize : CGSize { - return CGSize(width: 0.0, height: cellHeight) //280 + return CGSize(width: 0.0, height: cellHeight) } override func prepareForReuse() { From e8d989ec1cd30b708393d861d3050d2d633c9c2a Mon Sep 17 00:00:00 2001 From: Kartheek Date: Thu, 21 May 2020 18:34:24 +0530 Subject: [PATCH 11/11] Bug fixes and Fixed app crash when Background Process Running While in ChatBot. --- Examples/CocoapodsDemo/SDKConfiguration.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/CocoapodsDemo/SDKConfiguration.swift b/Examples/CocoapodsDemo/SDKConfiguration.swift index 420c0887..2600fa37 100644 --- a/Examples/CocoapodsDemo/SDKConfiguration.swift +++ b/Examples/CocoapodsDemo/SDKConfiguration.swift @@ -32,6 +32,7 @@ class SDKConfiguration: NSObject { struct serverConfig { static let JWT_SERVER = String(format: "http:///") // Replace it with the actual JWT server URL, if required. Refer to developer documentation for instructions on hosting JWT Server. + static func koreJwtUrl() -> String { return String(format: "%@users/sts", JWT_SERVER) }