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/CocoapodsDemo/SDKConfiguration.swift b/Examples/CocoapodsDemo/SDKConfiguration.swift index 31a51fcd..2600fa37 100644 --- a/Examples/CocoapodsDemo/SDKConfiguration.swift +++ b/Examples/CocoapodsDemo/SDKConfiguration.swift @@ -21,7 +21,7 @@ class SDKConfiguration: NSObject { static let clientSecret = "" // Copy this value from Bot Builder SDK Settings ex. Wibn3ULagYyq0J10LCndswYycHGLuIWbwHvTRSfLwhs= 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 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. @@ -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) } diff --git a/Examples/Shared/Common/KABotClient.swift b/Examples/Shared/Common/KABotClient.swift index ebe5c558..9f6e1983 100644 --- a/Examples/Shared/Common/KABotClient.swift +++ b/Examples/Shared/Common/KABotClient.swift @@ -365,9 +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] - - dataStoreManager.deleteThreadIfRequired(with: botId, completionBlock: { (success) in + 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() @@ -383,7 +381,6 @@ 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 a9c94903..251ba95e 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(){ @@ -143,7 +154,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 @@ -162,7 +173,10 @@ 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 let l: Legend = self.lcView.legend l.horizontalAlignment = .right @@ -173,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() @@ -195,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) @@ -226,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 { @@ -234,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)) @@ -251,8 +266,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()) @@ -267,20 +283,26 @@ 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]] { @@ -375,10 +396,10 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } var colors = colorsPalet() - + var dataSets: Array = Array() for i in 0.. = Array() for i in 0.. = dictionary["values"] != nil ? dictionary["values"] as! Array : [] valuesArray.append(values) } @@ -476,23 +497,23 @@ 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(entries: subDataValues, label:"") + let dataSet = BarChartDataSet(values: subDataValues, label:"") dataSet.stackLabels = titles let n = titles.count let colorsArr:[NSUIColor] = Array(colors.prefix(n)) 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)) @@ -510,7 +531,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)) } @@ -518,11 +539,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) } } @@ -559,7 +580,7 @@ class ChartBubbleView: BubbleView, IAxisValueFormatter, IValueFormatter { } override var intrinsicContentSize : CGSize { - return CGSize(width: 0.0, height: 280) + return CGSize(width: 0.0, height: cellHeight) } override func prepareForReuse() { diff --git a/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift b/Examples/Shared/Library/BubbleViews/Table/MiniTableBubbleView.swift index f0f2cf8d..08b288be 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,8 +74,19 @@ 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 + 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! { @@ -97,11 +109,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 = 2.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 +137,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 +185,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 +243,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 +273,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..