|
@@ -73,8 +73,9 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
|
|
|
return searchController.searchBar.text!.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
|
|
}
|
|
|
|
|
|
- var isFilltering: Bool {
|
|
|
- return !isSearchBarEmpty
|
|
|
+ var isFiltering: Bool {
|
|
|
+ return !textViewSearch.text!.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
|
|
+// return !isSearchBarEmpty
|
|
|
}
|
|
|
@IBOutlet var tableView: UITableView!
|
|
|
|
|
@@ -275,8 +276,11 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
|
|
|
|
|
|
if error != nil || isFinal {
|
|
|
if error == nil {
|
|
|
- self.searchController.searchBar.searchTextField.text = result!.bestTranscription.formattedString
|
|
|
- self.updateSearchResults(for: self.searchController)
|
|
|
+ let textRes = result!.bestTranscription.formattedString
|
|
|
+ self.textViewSearch.text = textRes
|
|
|
+ self.filterContentForSearchText(textRes)
|
|
|
+// self.searchController.searchBar.searchTextField.text = result!.bestTranscription.formattedString
|
|
|
+// self.updateSearchResults(for: self.searchController)
|
|
|
} else {
|
|
|
self.audioEngine.stop()
|
|
|
self.recognitionRequest?.endAudio()
|
|
@@ -400,13 +404,13 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
|
|
|
let imageViewSearch = UIImageView(image: UIImage(named: self.traitCollection.userInterfaceStyle == .dark ? "nx_search_bar_dark" : "nx_search_bar", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!)
|
|
|
imageViewSearch.contentMode = .scaleToFill
|
|
|
customView.addSubview(imageViewSearch)
|
|
|
- imageViewSearch.anchor(top: customView.topAnchor, left: customView.leftAnchor, bottom: customView.bottomAnchor, right: customView.rightAnchor, height: 30)
|
|
|
+ imageViewSearch.anchor(top: customView.topAnchor, left: customView.leftAnchor, bottom: customView.bottomAnchor, right: customView.rightAnchor, height: 35)
|
|
|
imageViewSearch.isUserInteractionEnabled = true
|
|
|
|
|
|
let imageSetting = UIImageView(image: UIImage(named: "nx_setting_sb", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!)
|
|
|
imageSetting.contentMode = .scaleToFill
|
|
|
imageViewSearch.addSubview(imageSetting)
|
|
|
- imageSetting.anchor(top: imageViewSearch.topAnchor, right: customView.rightAnchor, paddingTop: 5, paddingRight: 18, width: 20, height: 20)
|
|
|
+ imageSetting.anchor(right: customView.rightAnchor, paddingRight: 18, centerY: customView.centerYAnchor, width: 20, height: 20)
|
|
|
imageSetting.isUserInteractionEnabled = true
|
|
|
imageSetting.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(settingTapped)))
|
|
|
|
|
@@ -490,6 +494,13 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
|
|
|
// tableView.reloadData()
|
|
|
// }
|
|
|
|
|
|
+ func textFieldDidChangeSelection(_ textField: UITextField) {
|
|
|
+ if textField == textViewSearch {
|
|
|
+ let textSerch = textField.text ?? ""
|
|
|
+ filterContentForSearchText(textSerch)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
|
tabBarController?.navigationItem.leftBarButtonItem = nil
|
|
|
tabBarController?.navigationItem.searchController = nil
|
|
@@ -594,7 +605,8 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
|
|
|
// searchController.searchBar.placeholder = "Search chats & messages".localized()
|
|
|
// searchController.searchBar.searchTextField.attributedPlaceholder = NSAttributedString(string: "Search chats & messages".localized(), attributes: [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)])
|
|
|
}
|
|
|
- filterContentForSearchText(searchController.searchBar.text!)
|
|
|
+// filterContentForSearchText(searchController.searchBar.text!)
|
|
|
+ filterContentForSearchText(self.textViewSearch.text ?? "")
|
|
|
}
|
|
|
|
|
|
// MARK: - Data source
|
|
@@ -783,7 +795,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
switch segment.selectedSegmentIndex {
|
|
|
case 0:
|
|
|
let data: Chat
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
data = fillteredData[indexPath.row] as! Chat
|
|
|
} else {
|
|
|
data = chats[indexPath.row]
|
|
@@ -816,7 +828,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
func expandCollapseGroup(tableView: UITableView, indexPath: IndexPath) {
|
|
|
let group: Group
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
if indexPath.row == 0 {
|
|
|
group = fillteredData[indexPath.section] as! Group
|
|
|
} else {
|
|
@@ -845,7 +857,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
var loooop = true
|
|
|
repeat {
|
|
|
let c = sect + 1
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
if let o = self.fillteredData[c] as? Group {
|
|
|
if o.parent == id {
|
|
|
sects = sects + 1
|
|
@@ -874,7 +886,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
} while(loooop)
|
|
|
}
|
|
|
for i in stride(from: sects, to: 0, by: -1){
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
self.fillteredData.remove(at: indexPath.section + i)
|
|
|
}
|
|
|
else {
|
|
@@ -937,7 +949,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
//print("index path section: \(indexPath.section)")
|
|
|
//print("index path row: \(indexPath.row)")
|
|
|
//print("index path item: \(indexPath.item)")
|
|
|
- if self.isFilltering {
|
|
|
+ if self.isFiltering {
|
|
|
// self.fillteredData.remove(at: indexPath.section)
|
|
|
if self.fillteredData[indexPath.section] is Group {
|
|
|
self.groupMap[(self.fillteredData[indexPath.section] as! Group).id] = 1
|
|
@@ -1013,7 +1025,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
}
|
|
|
|
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
if segment.selectedSegmentIndex == 1 {
|
|
|
return fillteredData.count
|
|
|
}
|
|
@@ -1028,7 +1040,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
var value = 0
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
if segment.selectedSegmentIndex == 1, let groups = fillteredData as? [Group] {
|
|
|
let group = groups[section]
|
|
|
if group.isSelected {
|
|
@@ -1044,6 +1056,12 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
} else {
|
|
|
value = fillteredData.count
|
|
|
}
|
|
|
+ if value == 0 {
|
|
|
+ value = 1
|
|
|
+ tableView.separatorStyle = .none
|
|
|
+ } else {
|
|
|
+ tableView.separatorStyle = .singleLine
|
|
|
+ }
|
|
|
return value
|
|
|
}
|
|
|
switch segment.selectedSegmentIndex {
|
|
@@ -1084,9 +1102,9 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
if content.subviews.count > 0 {
|
|
|
content.subviews.forEach { $0.removeFromSuperview() }
|
|
|
}
|
|
|
- if noData {
|
|
|
+ if noData || (isFiltering && fillteredData.count == 0) {
|
|
|
let labelNochat = UILabel()
|
|
|
- labelNochat.text = "There are no conversations".localized()
|
|
|
+ labelNochat.text = isFiltering ? "No Result".localized() : "There are no conversations".localized()
|
|
|
labelNochat.font = .systemFont(ofSize: 13)
|
|
|
labelNochat.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
|
|
|
content.addSubview(labelNochat)
|
|
@@ -1096,7 +1114,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
return cell
|
|
|
}
|
|
|
let data: Chat
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
data = fillteredData[indexPath.row] as! Chat
|
|
|
} else {
|
|
|
if chats.count == 0 {
|
|
@@ -1289,7 +1307,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
var content = cell.defaultContentConfiguration()
|
|
|
content.textProperties.font = UIFont.systemFont(ofSize: 14)
|
|
|
let group: Group
|
|
|
- if isFilltering {
|
|
|
+ if isFiltering {
|
|
|
if indexPath.row == 0 {
|
|
|
group = fillteredData[indexPath.section] as! Group
|
|
|
} else {
|