QmeraCreateStreamingViewController.swift 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. //
  2. // QmeraCreateStreamingViewController.swift
  3. // Qmera
  4. //
  5. // Created by Yayan Dwi on 01/11/21.
  6. //
  7. import UIKit
  8. import NotificationBannerSwift
  9. import AVFoundation
  10. public class QmeraCreateStreamingViewController: UITableViewController {
  11. var isJoin = false
  12. var data: [String: Any] = [:]
  13. private enum Section {
  14. case chooser
  15. case title
  16. case description
  17. case tagline
  18. case users
  19. case groups
  20. }
  21. private var sections: [Section] = [
  22. .chooser,
  23. .title,
  24. .description,
  25. .tagline
  26. ]
  27. private var chooser: [Chooser] = [
  28. Chooser(title: "Target Audience".localized(), value: AudienceViewController().data.first),
  29. Chooser(title: "Promotion Type".localized(), value: TypeViewController().data.first)
  30. ]
  31. private var users: [User] = [] {
  32. didSet {
  33. DispatchQueue.main.async { [weak self] in
  34. self?.tableView.reloadData()
  35. }
  36. }
  37. }
  38. private var groups: [Group] = [] {
  39. didSet {
  40. DispatchQueue.main.async { [weak self] in
  41. self?.tableView.reloadData()
  42. }
  43. }
  44. }
  45. private let cellIdentifier = "reuseIdentifier"
  46. lazy var table: UITableView = {
  47. let tableView = UITableView(frame: CGRect.zero, style: .grouped)
  48. tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
  49. return tableView
  50. }()
  51. lazy var titleView: UITextField = {
  52. let textField = UITextField()
  53. textField.borderStyle = .none
  54. textField.placeholder = "Title".localized()
  55. return textField
  56. }()
  57. lazy var descriptionView: UITextView = {
  58. let textView = UITextView()
  59. textView.text = "Description".localized()
  60. textView.textColor = UIColor.lightGray
  61. return textView
  62. }()
  63. lazy var taglineView: UITextField = {
  64. let textField = UITextField()
  65. textField.borderStyle = .none
  66. textField.placeholder = "Tagline".localized()
  67. return textField
  68. }()
  69. deinit {
  70. //print(#function, ">>>> TADAA1")
  71. NotificationCenter.default.removeObserver(self)
  72. NotificationCenter.default.post(name: NSNotification.Name(rawValue: "refreshView"), object: nil, userInfo: nil)
  73. }
  74. public override func viewDidLoad() {
  75. super.viewDidLoad()
  76. title = "Live Streaming".localized()
  77. navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(didTapCancel(sender:)))
  78. navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start".localized(), style: .plain, target: self, action: #selector(didTapRight(sender:)))
  79. descriptionView.delegate = self
  80. let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
  81. tapGesture.cancelsTouchesInView = false
  82. table.addGestureRecognizer(tapGesture)
  83. if isJoin {
  84. navigationItem.rightBarButtonItem?.title = "Join".localized()
  85. titleView.isEnabled = false
  86. descriptionView.isEditable = false
  87. taglineView.isEnabled = false
  88. if let a = data["type"] as? String {
  89. chooser[0].value = AudienceViewController().data[getTypeIndex(value: a)]
  90. }
  91. if let b = data["broadcast_type"] as? String {
  92. chooser[1].value = TypeViewController().data[getBroadcastIndex(value: b)]
  93. }
  94. if let c = data["title"] as? String {
  95. titleView.text = c
  96. }
  97. if let d = data["description"] as? String {
  98. descriptionView.text = d
  99. }
  100. if let e = data["tagline"] as? String {
  101. taglineView.text = e
  102. }
  103. } else if !isJoin && !data.isEmpty {
  104. navigationItem.rightBarButtonItem?.title = "Start".localized()
  105. titleView.isEnabled = false
  106. descriptionView.isEditable = false
  107. taglineView.isEnabled = false
  108. if let a = data["type"] as? String {
  109. chooser[0].value = AudienceViewController().data[getTypeIndex(value: a)]
  110. }
  111. if let b = data["broadcast_type"] as? String {
  112. chooser[1].value = TypeViewController().data[getBroadcastIndex(value: b)]
  113. }
  114. if let c = data["title"] as? String {
  115. titleView.text = c
  116. }
  117. if let d = data["description"] as? String {
  118. descriptionView.text = d
  119. }
  120. if let e = data["tagline"] as? String {
  121. taglineView.text = e
  122. }
  123. }
  124. tableView = table
  125. }
  126. @objc func dismissKeyboard() {
  127. titleView.resignFirstResponder()
  128. descriptionView.resignFirstResponder()
  129. taglineView.resignFirstResponder()
  130. }
  131. @objc func didTapCancel(sender: AnyObject) {
  132. navigationController?.dismiss(animated: true, completion: nil)
  133. }
  134. @objc func didTapRight(sender: Any?) {
  135. let controller = QmeraStreamingViewController()
  136. controller.isLive = !isJoin
  137. if isJoin {
  138. guard let by = data["by"] as? String else {
  139. return
  140. }
  141. let dataBlog = data["blog"] as? String
  142. if dataBlog != nil {
  143. if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getIsInitiatorJoin(p_broadcaster: by, p_category: "3", blog_id: dataBlog!)) {
  144. if response.getBody(key: CoreMessage_TMessageKey.ERRCOD) != "00" {
  145. let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
  146. imageView.tintColor = .white
  147. let banner = FloatingNotificationBanner(title: "Live Streaming session hasn\'t started yet".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
  148. banner.show()
  149. return
  150. }
  151. } else {
  152. let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
  153. imageView.tintColor = .white
  154. let banner = FloatingNotificationBanner(title: "No Network. Please try again.".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
  155. banner.show()
  156. return
  157. }
  158. }
  159. controller.data = by
  160. controller.streamingData = data
  161. } else {
  162. let goAudioCall = Nexilis.checkMicPermission()
  163. if !goAudioCall {
  164. let alert = UIAlertController(title: "Attention!".localized(), message: "Please allow microphone permission in your settings".localized(), preferredStyle: .alert)
  165. alert.addAction(UIAlertAction(title: "OK".localized(), style: UIAlertAction.Style.default, handler: { _ in
  166. if let url = URL(string: UIApplication.openSettingsURLString), UIApplication.shared.canOpenURL(url) {
  167. UIApplication.shared.open(url, options: [:], completionHandler: nil)
  168. }
  169. }))
  170. if UIApplication.shared.visibleViewController?.navigationController != nil {
  171. UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
  172. } else {
  173. UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
  174. }
  175. return
  176. }
  177. var permissionCheck = -1
  178. if AVCaptureDevice.authorizationStatus(for: .video) == .authorized {
  179. permissionCheck = 1
  180. } else if AVCaptureDevice.authorizationStatus(for: .video) == .denied {
  181. permissionCheck = 0
  182. } else {
  183. AVCaptureDevice.requestAccess(for: .video, completionHandler: { (granted: Bool) -> Void in
  184. if granted == true {
  185. permissionCheck = 1
  186. } else {
  187. permissionCheck = 0
  188. }
  189. })
  190. }
  191. while permissionCheck == -1 {
  192. sleep(1)
  193. }
  194. if permissionCheck == 0 {
  195. let alert = UIAlertController(title: "Attention!".localized(), message: "Please allow camera permission in your settings".localized(), preferredStyle: .alert)
  196. alert.addAction(UIAlertAction(title: "OK".localized(), style: UIAlertAction.Style.default, handler: { _ in
  197. if let url = URL(string: UIApplication.openSettingsURLString), UIApplication.shared.canOpenURL(url) {
  198. UIApplication.shared.open(url, options: [:], completionHandler: nil)
  199. }
  200. }))
  201. if UIApplication.shared.visibleViewController?.navigationController != nil {
  202. UIApplication.shared.visibleViewController?.navigationController?.present(alert, animated: true, completion: nil)
  203. } else {
  204. UIApplication.shared.visibleViewController?.present(alert, animated: true, completion: nil)
  205. }
  206. return
  207. }
  208. var data: [String: Any] = [:]
  209. if !isJoin && !self.data.isEmpty {
  210. data = self.data
  211. } else if self.data.isEmpty {
  212. guard let streamingTitle = titleView.text else {
  213. return
  214. }
  215. guard let streamingDesc = descriptionView.text else {
  216. return
  217. }
  218. let id = "LST\(Date().currentTimeMillis().toHex())"
  219. data["title"] = streamingTitle
  220. data["description"] = streamingDesc
  221. data["by"] = UserDefaults.standard.string(forKey: "me") ?? ""
  222. data["tagline"] = taglineView.text ?? ""
  223. data["time"] = Date().currentTimeMillis()
  224. data["blog"] = id
  225. if streamingTitle.trimmingCharacters(in: .whitespaces).isEmpty {
  226. let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
  227. imageView.tintColor = .white
  228. let banner = FloatingNotificationBanner(title: "Live Streaming title can't be empty".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
  229. banner.show()
  230. return
  231. } else if streamingDesc.trimmingCharacters(in: .whitespaces).isEmpty {
  232. let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
  233. imageView.tintColor = .white
  234. let banner = FloatingNotificationBanner(title: "Live Streaming description can't be empty".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
  235. banner.show()
  236. return
  237. }
  238. var type: String = "0" // Friend
  239. let groups: [String] = groups.map{ $0.id }
  240. let members: [String] = users.map{ $0.pin }
  241. switch chooser[0].id {
  242. case 0:
  243. type = "7"
  244. case 1:
  245. type = "8"
  246. case 2:
  247. type = "3"
  248. case 3:
  249. type = "6"
  250. case 4:
  251. type = "5"
  252. default:
  253. type = "0"
  254. }
  255. data["groups"] = groups
  256. data["members"] = members
  257. data["type"] = type
  258. var notif: String = "0"
  259. switch chooser[1].id {
  260. case 0:
  261. notif = "1"
  262. default:
  263. notif = "2"
  264. }
  265. data["broadcast_type"] = notif
  266. guard let json = String(data: try! JSONSerialization.data(withJSONObject: data, options: []), encoding: String.Encoding.utf8) else {
  267. return
  268. }
  269. if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.createLS(title: "1~\(data["title"] ?? "")", type: data["type"] as! String, category: "3", tagline: data["tagline"] as! String, notifType: data["broadcast_type"] as! String, blogId: data["blog"] as! String, data: json)) {
  270. if response.getBody(key: CoreMessage_TMessageKey.ERRCOD) != "00" {
  271. let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
  272. imageView.tintColor = .white
  273. let banner = FloatingNotificationBanner(title: "Server Busy. Please try again.".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
  274. banner.show()
  275. return
  276. }
  277. } else {
  278. let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
  279. imageView.tintColor = .white
  280. let banner = FloatingNotificationBanner(title: "No Network. Please try again.".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
  281. banner.show()
  282. return
  283. }
  284. // Nexilis.saveMessageBot(textMessage: json, blog_id: data["blog"] as? String ?? "", attachment_type: "27")
  285. NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
  286. }
  287. controller.data = UserDefaults.standard.string(forKey: "me")!
  288. controller.streamingData = data
  289. }
  290. navigationController?.show(controller, sender: nil)
  291. }
  292. private func getTypeIndex(value: String) -> Int {
  293. var type = 0
  294. switch value {
  295. case "7":
  296. type = 0
  297. case "8":
  298. type = 1
  299. case "3":
  300. type = 2
  301. case "6":
  302. type = 3
  303. case "5":
  304. type = 4
  305. default:
  306. type = 0
  307. }
  308. return type
  309. }
  310. private func getBroadcastIndex(value: String) -> Int {
  311. var notif = 0
  312. switch value {
  313. case "1":
  314. notif = 0
  315. default:
  316. notif = 1
  317. }
  318. return notif
  319. }
  320. // MARK: - Table view data source
  321. public override func numberOfSections(in tableView: UITableView) -> Int {
  322. return sections.count
  323. }
  324. public override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  325. switch sections[section] {
  326. case .chooser:
  327. return 2
  328. case .users:
  329. return users.count + 1
  330. case .groups:
  331. return groups.count + 1
  332. default:
  333. return 1
  334. }
  335. }
  336. public override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  337. switch sections[indexPath.section] {
  338. case .description:
  339. return 100
  340. default:
  341. return 44
  342. }
  343. }
  344. public override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
  345. if isJoin, sections[indexPath.section] == .chooser {
  346. return nil
  347. }
  348. return indexPath
  349. }
  350. public override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  351. tableView.deselectRow(at: indexPath, animated: true)
  352. switch sections[indexPath.section] {
  353. case .chooser:
  354. if indexPath.row == 0 {
  355. if isJoin || (!isJoin && !data.isEmpty){
  356. return
  357. }
  358. let chooser = chooser[indexPath.row]
  359. let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "audienceView") as AudienceViewController
  360. controller.selected = chooser.value
  361. controller.isDismiss = { [weak self] index in
  362. chooser.id = index
  363. chooser.value = AudienceViewController().data[index]
  364. guard let sec = self?.sections else {
  365. return
  366. }
  367. if sec.count > 4 {
  368. self?.sections.removeLast()
  369. }
  370. if chooser.value == "Group".localized() {
  371. self?.sections.append(.groups)
  372. if self?.users.count != 0 {
  373. self?.users.removeAll()
  374. }
  375. } else if chooser.value == "User".localized() {
  376. self?.sections.append(.users)
  377. if self?.groups.count != 0{
  378. self?.groups.removeAll()
  379. }
  380. } else {
  381. if self?.users.count != 0 {
  382. self?.users.removeAll()
  383. } else if self?.groups.count != 0{
  384. self?.groups.removeAll()
  385. }
  386. }
  387. DispatchQueue.main.async {
  388. tableView.reloadData()
  389. }
  390. }
  391. navigationController?.show(controller, sender: nil)
  392. } else if indexPath.row == 1 {
  393. if isJoin || (!isJoin && !data.isEmpty){
  394. return
  395. }
  396. let chooser = chooser[indexPath.row]
  397. let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "typeView") as TypeViewController
  398. controller.selected = chooser.value
  399. controller.isDismiss = { index in
  400. chooser.id = index
  401. chooser.value = TypeViewController().data[index]
  402. DispatchQueue.main.async {
  403. tableView.reloadRows(at: [indexPath], with: .automatic)
  404. }
  405. }
  406. navigationController?.show(controller, sender: nil)
  407. }
  408. case .users:
  409. if indexPath.row == 0 {
  410. let controller = QmeraUserChooserViewController()
  411. controller.ignored.append(contentsOf: users)
  412. controller.isDismiss = { users in
  413. self.users.append(contentsOf: users)
  414. }
  415. navigationController?.show(controller, sender: nil)
  416. }
  417. case .groups:
  418. if indexPath.row == 0 {
  419. let controller = QmeraGroupStreamingViewController()
  420. controller.ignored.append(contentsOf: groups)
  421. controller.isDismiss = { groups in
  422. self.groups.append(contentsOf: groups)
  423. }
  424. navigationController?.show(controller, sender: nil)
  425. }
  426. default:
  427. return
  428. }
  429. }
  430. public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  431. let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath)
  432. cell.contentView.subviews.forEach{ NSLayoutConstraint.deactivate($0.constraints); $0.removeFromSuperview() }
  433. cell.contentConfiguration = nil
  434. cell.accessoryType = .none
  435. cell.selectionStyle = .none
  436. switch sections[indexPath.section] {
  437. case .chooser:
  438. var content = cell.defaultContentConfiguration()
  439. let data = chooser[indexPath.row]
  440. content.text = data.title
  441. content.secondaryText = data.value
  442. content.textProperties.font = UIFont.systemFont(ofSize: 14)
  443. content.secondaryTextProperties.color = .systemGray
  444. content.secondaryTextProperties.font = UIFont.systemFont(ofSize: 14)
  445. content.prefersSideBySideTextAndSecondaryText = true
  446. cell.contentConfiguration = content
  447. cell.accessoryType = .disclosureIndicator
  448. cell.selectionStyle = .default
  449. case .title:
  450. cell.contentView.addSubview(titleView)
  451. titleView.anchor(top: cell.topAnchor, left: cell.leftAnchor, bottom: cell.bottomAnchor, right: cell.rightAnchor, paddingLeft: 20, paddingRight: 20)
  452. case .description:
  453. let stack = UIStackView()
  454. stack.axis = .vertical
  455. stack.distribution = .fill
  456. cell.contentView.addSubview(stack)
  457. stack.anchor(top: cell.topAnchor, left: cell.leftAnchor, bottom: cell.bottomAnchor, right: cell.rightAnchor, paddingTop: 8, paddingLeft: 20, paddingBottom: 8, paddingRight: 20)
  458. stack.addArrangedSubview(descriptionView)
  459. case .tagline:
  460. cell.contentView.addSubview(taglineView)
  461. taglineView.anchor(top: cell.topAnchor, left: cell.leftAnchor, bottom: cell.bottomAnchor, right: cell.rightAnchor, paddingLeft: 20, paddingRight: 20)
  462. case .users:
  463. var content = cell.defaultContentConfiguration()
  464. if indexPath.row == 0 {
  465. content.image = UIImage(systemName: "plus.circle.fill")
  466. content.imageProperties.tintColor = .mainColor
  467. content.text = "Add user".localized()
  468. content.textProperties.font = UIFont.systemFont(ofSize: 14)
  469. cell.accessoryType = .disclosureIndicator
  470. cell.selectionStyle = .default
  471. } else {
  472. let data = users[indexPath.row - 1]
  473. getImage(name: data.thumb, placeholderImage: UIImage(named: "Profile---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), isCircle: true, tableView: tableView, indexPath: indexPath) { result, isDownloaded, image in
  474. content.image = image
  475. }
  476. content.text = data.fullName
  477. content.textProperties.font = UIFont.systemFont(ofSize: 14)
  478. }
  479. cell.contentConfiguration = content
  480. case .groups:
  481. var content = cell.defaultContentConfiguration()
  482. if indexPath.row == 0 {
  483. content.image = UIImage(systemName: "plus.circle.fill")
  484. content.imageProperties.tintColor = .mainColor
  485. content.text = "Add group".localized()
  486. content.textProperties.font = UIFont.systemFont(ofSize: 14)
  487. cell.accessoryType = .disclosureIndicator
  488. cell.selectionStyle = .default
  489. } else {
  490. let data = groups[indexPath.row - 1]
  491. getImage(name: data.profile, placeholderImage: UIImage(named: "Conversation---Purple", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), isCircle: true, tableView: tableView, indexPath: indexPath) { result, isDownloaded, image in
  492. content.image = image
  493. }
  494. content.text = data.name
  495. content.textProperties.font = UIFont.systemFont(ofSize: 14)
  496. }
  497. cell.contentConfiguration = content
  498. }
  499. return cell
  500. }
  501. public override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
  502. switch sections[indexPath.section] {
  503. case .users:
  504. if (editingStyle == .delete) {
  505. users.remove(at: indexPath.row - 1)
  506. tableView.deleteRows(at: [indexPath], with: .automatic)
  507. }
  508. case .groups:
  509. if (editingStyle == .delete) {
  510. groups.remove(at: indexPath.row - 1)
  511. tableView.deleteRows(at: [indexPath], with: .automatic)
  512. }
  513. default:
  514. return
  515. }
  516. }
  517. public override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
  518. if indexPath.section < 4 {
  519. return .none
  520. } else if indexPath.section == 4 && indexPath.row == 0 {
  521. return .none
  522. }
  523. return .delete
  524. }
  525. @IBAction func result(unwind segue: UIStoryboardSegue) {
  526. }
  527. }
  528. private class Chooser {
  529. let title: String
  530. var id: Int = 0
  531. var value: String?
  532. init(title: String, id: Int = 0, value: String?) {
  533. self.title = title
  534. self.id = id
  535. self.value = value
  536. }
  537. }
  538. extension QmeraCreateStreamingViewController: UITextViewDelegate {
  539. public func textViewDidBeginEditing(_ textView: UITextView) {
  540. if textView.textColor == UIColor.lightGray {
  541. textView.text = nil
  542. textView.textColor = UIColor.black
  543. }
  544. }
  545. public func textViewDidEndEditing(_ textView: UITextView) {
  546. if textView.text.isEmpty {
  547. textView.text = "Description".localized()
  548. textView.textColor = UIColor.lightGray
  549. }
  550. }
  551. }