mirror of https://github.com/oxen-io/session-ios
				
				
				
			plus button for more emoji
							parent
							
								
									ecb657545e
								
							
						
					
					
						commit
						6314240189
					
				@ -0,0 +1,89 @@
 | 
			
		||||
 | 
			
		||||
extension ContextMenuVC {
 | 
			
		||||
    
 | 
			
		||||
    final class EmojiReactsView: UIView {
 | 
			
		||||
        private let emoji: String
 | 
			
		||||
        private let dismiss: () -> Void
 | 
			
		||||
 | 
			
		||||
        // MARK: Settings
 | 
			
		||||
        private static let size: CGFloat = 40
 | 
			
		||||
        
 | 
			
		||||
        // MARK: Lifecycle
 | 
			
		||||
        init(for emoji: String, dismiss: @escaping () -> Void) {
 | 
			
		||||
            self.emoji = emoji
 | 
			
		||||
            self.dismiss = dismiss
 | 
			
		||||
            super.init(frame: CGRect.zero)
 | 
			
		||||
            setUpViewHierarchy()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        override init(frame: CGRect) {
 | 
			
		||||
            preconditionFailure("Use init(for:) instead.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        required init?(coder: NSCoder) {
 | 
			
		||||
            preconditionFailure("Use init(for:) instead.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private func setUpViewHierarchy() {
 | 
			
		||||
            let emojiLabel = UILabel()
 | 
			
		||||
            emojiLabel.text = self.emoji
 | 
			
		||||
            emojiLabel.font = .systemFont(ofSize: Values.veryLargeFontSize)
 | 
			
		||||
            emojiLabel.set(.height, to: ContextMenuVC.EmojiReactsView.size)
 | 
			
		||||
            addSubview(emojiLabel)
 | 
			
		||||
            emojiLabel.pin(to: self)
 | 
			
		||||
            // Tap gesture recognizer
 | 
			
		||||
            let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap))
 | 
			
		||||
            addGestureRecognizer(tapGestureRecognizer)
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // MARK: Interaction
 | 
			
		||||
        @objc private func handleTap() {
 | 
			
		||||
            dismiss()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    final class EmojiPlusButton: UIView {
 | 
			
		||||
        private let dismiss: () -> Void
 | 
			
		||||
 | 
			
		||||
        // MARK: Settings
 | 
			
		||||
        public static let size: CGFloat = 28
 | 
			
		||||
        private let iconSize: CGFloat = 14
 | 
			
		||||
        
 | 
			
		||||
        // MARK: Lifecycle
 | 
			
		||||
        init(dismiss: @escaping () -> Void) {
 | 
			
		||||
            self.dismiss = dismiss
 | 
			
		||||
            super.init(frame: CGRect.zero)
 | 
			
		||||
            setUpViewHierarchy()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        override init(frame: CGRect) {
 | 
			
		||||
            preconditionFailure("Use init(for:) instead.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        required init?(coder: NSCoder) {
 | 
			
		||||
            preconditionFailure("Use init(for:) instead.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private func setUpViewHierarchy() {
 | 
			
		||||
            // Icon image
 | 
			
		||||
            let iconImageView = UIImageView(image: #imageLiteral(resourceName: "ic_plus_24").withTint(Colors.text))
 | 
			
		||||
            iconImageView.set(.width, to: iconSize)
 | 
			
		||||
            iconImageView.set(.height, to: iconSize)
 | 
			
		||||
            iconImageView.contentMode = .scaleAspectFit
 | 
			
		||||
            addSubview(iconImageView)
 | 
			
		||||
            iconImageView.center(in: self)
 | 
			
		||||
            // Background
 | 
			
		||||
            isUserInteractionEnabled = true
 | 
			
		||||
            backgroundColor = Colors.sessionEmojiPlusButtonBackground
 | 
			
		||||
            // Tap gesture recognizer
 | 
			
		||||
            let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap))
 | 
			
		||||
            addGestureRecognizer(tapGestureRecognizer)
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // MARK: Interaction
 | 
			
		||||
        @objc private func handleTap() {
 | 
			
		||||
            dismiss()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,38 @@
 | 
			
		||||
{
 | 
			
		||||
  "colors" : [
 | 
			
		||||
    {
 | 
			
		||||
      "color" : {
 | 
			
		||||
        "color-space" : "srgb",
 | 
			
		||||
        "components" : {
 | 
			
		||||
          "alpha" : "1.000",
 | 
			
		||||
          "blue" : "0xFF",
 | 
			
		||||
          "green" : "0xFF",
 | 
			
		||||
          "red" : "0xFF"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "idiom" : "universal"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "appearances" : [
 | 
			
		||||
        {
 | 
			
		||||
          "appearance" : "luminosity",
 | 
			
		||||
          "value" : "dark"
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "color" : {
 | 
			
		||||
        "color-space" : "srgb",
 | 
			
		||||
        "components" : {
 | 
			
		||||
          "alpha" : "1.000",
 | 
			
		||||
          "blue" : "0x23",
 | 
			
		||||
          "green" : "0x23",
 | 
			
		||||
          "red" : "0x23"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "idiom" : "universal"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "info" : {
 | 
			
		||||
    "author" : "xcode",
 | 
			
		||||
    "version" : 1
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue