|
@@ -2,8 +2,7 @@ import Foundation
|
|
|
import UIKit
|
|
|
import DcCore
|
|
|
|
|
|
-class QrViewController: UITableViewController {
|
|
|
- private let rowQRCode = 0
|
|
|
+class QrViewController: UIViewController {
|
|
|
|
|
|
var dcContext: DcContext
|
|
|
var contact: DcContact? {
|
|
@@ -26,90 +25,69 @@ class QrViewController: UITableViewController {
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
title = String.localized("qr_code")
|
|
|
- tableView.separatorStyle = .none
|
|
|
- }
|
|
|
-
|
|
|
- override func tableView(_: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
- let row = indexPath.row
|
|
|
- switch row {
|
|
|
- case rowQRCode:
|
|
|
- return createQRCodeCell()
|
|
|
- default:
|
|
|
- return UITableViewCell(style: .default, reuseIdentifier: nil)
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- override func numberOfSections(in _: UITableView) -> Int {
|
|
|
- return 1
|
|
|
- }
|
|
|
+ func displayNewChat(contactId: Int) {
|
|
|
+ let chatId = dcContext.createChatByContactId(contactId: contactId)
|
|
|
+ let chatVC = ChatViewController(dcContext: dcContext, chatId: Int(chatId))
|
|
|
|
|
|
- override func tableView(_: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
- return 2
|
|
|
+ chatVC.hidesBottomBarWhenPushed = true
|
|
|
+ navigationController?.pushViewController(chatVC, animated: true)
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- override func tableView(_: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
- switch indexPath.row {
|
|
|
- case rowQRCode:
|
|
|
- return 325
|
|
|
- default:
|
|
|
- return 10
|
|
|
- }
|
|
|
- }
|
|
|
+class QrViewContentView: UIView {
|
|
|
|
|
|
- private func createQRCodeCell() -> UITableViewCell {
|
|
|
- let cell = UITableViewCell(style: .default, reuseIdentifier: "qrCodeCell")
|
|
|
- let qrCode = createQRCodeView()
|
|
|
- let infolabel = createInfoLabel()
|
|
|
+}
|
|
|
|
|
|
- cell.contentView.addSubview(qrCode)
|
|
|
- cell.contentView.addSubview(infolabel)
|
|
|
- cell.selectionStyle = .none
|
|
|
+/*
|
|
|
+ private func createQRCodeCell() -> UITableViewCell {
|
|
|
+ let cell = UITableViewCell(style: .default, reuseIdentifier: "qrCodeCell")
|
|
|
+ let qrCode = createQRCodeView()
|
|
|
+ let infolabel = createInfoLabel()
|
|
|
|
|
|
- let qrCodeConstraints = [qrCode.constraintAlignTopTo(cell.contentView, paddingTop: 25),
|
|
|
- qrCode.constraintCenterXTo(cell.contentView)]
|
|
|
- let infoLabelConstraints = [infolabel.constraintToBottomOf(qrCode, paddingTop: 25),
|
|
|
- infolabel.constraintAlignLeadingTo(cell.contentView, paddingLeading: 8),
|
|
|
- infolabel.constraintAlignTrailingTo(cell.contentView, paddingTrailing: 8)]
|
|
|
- cell.contentView.addConstraints(qrCodeConstraints)
|
|
|
- cell.contentView.addConstraints(infoLabelConstraints)
|
|
|
- return cell
|
|
|
- }
|
|
|
+ cell.contentView.addSubview(qrCode)
|
|
|
+ cell.contentView.addSubview(infolabel)
|
|
|
+ cell.selectionStyle = .none
|
|
|
|
|
|
- private func createInfoLabel() -> UIView {
|
|
|
- let label = UILabel.init()
|
|
|
- label.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- if let contact = contact {
|
|
|
- label.text = String.localizedStringWithFormat(String.localized("qrshow_join_contact_hint"), contact.email)
|
|
|
- }
|
|
|
- label.lineBreakMode = .byWordWrapping
|
|
|
- label.numberOfLines = 0
|
|
|
- label.textAlignment = .center
|
|
|
- label.font = UIFont.systemFont(ofSize: 14)
|
|
|
- return label
|
|
|
- }
|
|
|
+ let qrCodeConstraints = [qrCode.constraintAlignTopTo(cell.contentView, paddingTop: 25),
|
|
|
+ qrCode.constraintCenterXTo(cell.contentView)]
|
|
|
+ let infoLabelConstraints = [infolabel.constraintToBottomOf(qrCode, paddingTop: 25),
|
|
|
+ infolabel.constraintAlignLeadingTo(cell.contentView, paddingLeading: 8),
|
|
|
+ infolabel.constraintAlignTrailingTo(cell.contentView, paddingTrailing: 8)]
|
|
|
+ cell.contentView.addConstraints(qrCodeConstraints)
|
|
|
+ cell.contentView.addConstraints(infoLabelConstraints)
|
|
|
+ return cell
|
|
|
+ }
|
|
|
|
|
|
- private func createQRCodeView() -> UIView {
|
|
|
- let width: CGFloat = 230
|
|
|
- let frame = CGRect(origin: .zero, size: .init(width: width, height: width))
|
|
|
- let imageView = QRCodeView(frame: frame)
|
|
|
- if let qrCode = dcContext.getSecurejoinQr(chatId: 0) {
|
|
|
- imageView.generateCode(
|
|
|
- qrCode,
|
|
|
- foregroundColor: .darkText,
|
|
|
- backgroundColor: .white
|
|
|
- )
|
|
|
- }
|
|
|
- imageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- imageView.widthAnchor.constraint(equalToConstant: width).isActive = true
|
|
|
- imageView.heightAnchor.constraint(equalToConstant: width).isActive = true
|
|
|
- return imageView
|
|
|
- }
|
|
|
+ private func createInfoLabel() -> UIView {
|
|
|
+ let label = UILabel.init()
|
|
|
+ label.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ if let contact = contact {
|
|
|
+ label.text = String.localizedStringWithFormat(String.localized("qrshow_join_contact_hint"), contact.email)
|
|
|
+ }
|
|
|
+ label.lineBreakMode = .byWordWrapping
|
|
|
+ label.numberOfLines = 0
|
|
|
+ label.textAlignment = .center
|
|
|
+ label.font = UIFont.systemFont(ofSize: 14)
|
|
|
+ return label
|
|
|
+ }
|
|
|
|
|
|
- func displayNewChat(contactId: Int) {
|
|
|
- let chatId = dcContext.createChatByContactId(contactId: contactId)
|
|
|
- let chatVC = ChatViewController(dcContext: dcContext, chatId: Int(chatId))
|
|
|
+ private func createQRCodeView() -> UIView {
|
|
|
+ let width: CGFloat = 230
|
|
|
+ let frame = CGRect(origin: .zero, size: .init(width: width, height: width))
|
|
|
+ let imageView = QRCodeView(frame: frame)
|
|
|
+ if let qrCode = dcContext.getSecurejoinQr(chatId: 0) {
|
|
|
+ imageView.generateCode(
|
|
|
+ qrCode,
|
|
|
+ foregroundColor: .darkText,
|
|
|
+ backgroundColor: .white
|
|
|
+ )
|
|
|
+ }
|
|
|
+ imageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ imageView.widthAnchor.constraint(equalToConstant: width).isActive = true
|
|
|
+ imageView.heightAnchor.constraint(equalToConstant: width).isActive = true
|
|
|
+ return imageView
|
|
|
+ }
|
|
|
|
|
|
- chatVC.hidesBottomBarWhenPushed = true
|
|
|
- navigationController?.pushViewController(chatVC, animated: true)
|
|
|
- }
|
|
|
-}
|
|
|
+ */
|