Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test flight reply bar redesign #406

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"images" : [
{
"filename" : "Clear.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Clear 1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Clear@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Clear@2x 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Clear@3x.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Clear@3x 1.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ChatBottomView: NSView, LoadableNib {

@IBOutlet var contentView: NSView!

@IBOutlet weak var messageReplyView: NewMessageReplyView!
@IBOutlet weak var messageReplyView: NewReplyView!
@IBOutlet weak var giphySearchView: GiphySearchView!
@IBOutlet weak var messageFieldView: ChatMessageFieldView!
@IBOutlet weak var chatSearchView: ChatSearchResultsBar!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pXa-h9-I4V">
<rect key="frame" x="0.0" y="0.0" width="835" height="60"/>
<subviews>
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7Ir-cU-gQ9" customClass="NewMessageReplyView" customModule="Sphinx" customModuleProvider="target">
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7Ir-cU-gQ9" customClass="NewReplyView" customModule="Sphinx" customModuleProvider="target">
<rect key="frame" x="0.0" y="10" width="835" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="8pt-lk-BrU"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -132,16 +132,16 @@
<stackView distribution="equalSpacing" orientation="vertical" alignment="leading" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jwx-pk-wRo">
<rect key="frame" x="0.0" y="2" width="472" height="32"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="puL-ef-n3H">
<rect key="frame" x="-2" y="18" width="476" height="14"/>
<textField focusRingType="none" horizontalHuggingPriority="251" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="puL-ef-n3H">
<rect key="frame" x="-2" y="19" width="476" height="13"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Unknown" id="rRt-hC-3GE">
<font key="font" size="12" name="Roboto-Medium"/>
<color key="textColor" name="SphinxOrange"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="LMq-zJ-1iz">
<rect key="frame" x="-2" y="0.0" width="476" height="16"/>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LMq-zJ-1iz">
<rect key="frame" x="-2" y="0.0" width="476" height="19"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="267-xo-kC9">
<font key="font" size="14" name="Roboto-Light"/>
<color key="textColor" name="Text"/>
Expand Down Expand Up @@ -267,7 +267,7 @@
<constraint firstAttribute="trailing" secondItem="YNt-Zf-UPm" secondAttribute="trailing" id="db7-vE-yP8"/>
<constraint firstItem="YNt-Zf-UPm" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="yY6-dU-yLE"/>
</constraints>
<point key="canvasLocation" x="-2" y="154"/>
<point key="canvasLocation" x="277" y="109"/>
</customView>
</objects>
<resources>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
//
// NewReplyView.swift
// Sphinx
//
// Created by Oko-osi Korede on 05/06/2024.
// Copyright © 2024 Tomas Timinskas. All rights reserved.
//

import Cocoa

class NewReplyView: NSView, LoadableNib {

weak var delegate: NewMessageReplyViewDelegate?

@IBOutlet var contentView: NSView!

@IBOutlet weak var coloredLineView: NSBox!

@IBOutlet weak var mediaContainerView: NSStackView!

@IBOutlet weak var imageVideoView: NSView!
@IBOutlet weak var mediaImageView: AspectFillNSImageView!
@IBOutlet weak var videoOverlay: NSBox!

@IBOutlet weak var mediaIconLabel: NSTextField!

@IBOutlet weak var senderLabel: NSTextField!
@IBOutlet weak var messageLabel: NSTextField!

@IBOutlet weak var replyDivider: NSView!

@IBOutlet weak var closeButtonContainer: NSBox!
@IBOutlet weak var closeButton: CustomButton!

@IBOutlet weak var viewButton: CustomButton!
@IBOutlet weak var replyToLabel: NSTextField!

static let kViewHeight: CGFloat = 50.0

required init?(coder: NSCoder) {
super.init(coder: coder)
loadViewFromNib()
setup()
}

override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
loadViewFromNib()
setup()
}

func setup() {
closeButton.cursor = .pointingHand
viewButton.cursor = .pointingHand
}

func configureWith(
messageReply: BubbleMessageLayoutState.MessageReply,
and bubble: BubbleMessageLayoutState.Bubble,
delegate: NewMessageReplyViewDelegate? = nil
) {
self.delegate = delegate

self.wantsLayer = true
self.layer?.backgroundColor = NSColor.clear.cgColor

viewButton.isHidden = false
closeButtonContainer.isHidden = true

messageLabel.textColor = bubble.direction.isIncoming() ? NSColor.Sphinx.WashedOutReceivedText : NSColor.Sphinx.WashedOutSentText

coloredLineView.fillColor = messageReply.color
senderLabel.textColor = messageReply.color
senderLabel.stringValue = messageReply.alias
messageLabel.stringValue = messageReply.message ?? ""

replyToLabel.stringValue = "reply.to".localized

messageLabel.isHidden = (messageReply.message ?? "").isEmpty

guard let mediaType = messageReply.mediaType else {
mediaContainerView.isHidden = true
mediaIconLabel.isHidden = true
return
}

switch(mediaType) {
case TransactionMessage.TransactionMessageType.imageAttachment.rawValue:
mediaIconLabel.stringValue = "photo_library"
break
case TransactionMessage.TransactionMessageType.videoAttachment.rawValue:
mediaIconLabel.stringValue = "videocam"
break
case TransactionMessage.TransactionMessageType.audioAttachment.rawValue:
mediaIconLabel.stringValue = "mic"
break
case TransactionMessage.TransactionMessageType.fileAttachment.rawValue:
mediaIconLabel.stringValue = "description"
break
case TransactionMessage.TransactionMessageType.pdfAttachment.rawValue:
mediaIconLabel.stringValue = "picture_as_pdf"
break
default:
break
}

mediaContainerView.isHidden = false
mediaIconLabel.isHidden = false
}

func configureForKeyboard(
with podcastComment: PodcastComment,
and delegate: NewMessageReplyViewDelegate
) {
self.delegate = delegate

self.wantsLayer = true
self.layer?.backgroundColor = NSColor.Sphinx.HeaderBG.cgColor

viewButton.isHidden = true
closeButtonContainer.isHidden = false

coloredLineView.fillColor = NSColor.Sphinx.SecondaryText

let (hours, minutes, seconds) = (podcastComment.timestamp ?? 0).getTimeElements()
let title = podcastComment.title ?? "title.not.available".localized
let message = "Share audio clip: \(hours):\(minutes):\(seconds)"
senderLabel.textColor = NSColor.Sphinx.Text
senderLabel.stringValue = title

messageLabel.textColor = NSColor.Sphinx.SecondaryText
messageLabel.stringValue = message
messageLabel.isHidden = message.isEmpty

mediaContainerView.isHidden = true
mediaIconLabel.isHidden = true

self.isHidden = false
}

func configureForKeyboard(
with message: TransactionMessage,
owner: UserContact,
and delegate: NewMessageReplyViewDelegate
) {
self.delegate = delegate

self.wantsLayer = true
self.layer?.backgroundColor = NSColor.Sphinx.HeaderBG.cgColor

viewButton.isHidden = true
closeButtonContainer.isHidden = false

messageLabel.textColor = NSColor.Sphinx.SecondaryText

let senderColor = ChatHelper.getSenderColorFor(message: message)
coloredLineView.fillColor = senderColor
senderLabel.textColor = senderColor
senderLabel.stringValue = message.getMessageSenderNickname(
owner: owner,
contact: nil
)
messageLabel.stringValue = message.getReplyMessageContent()
messageLabel.isHidden = message.getReplyMessageContent().isEmpty

if message.isMediaAttachment() {

if message.isAudio() {
mediaIconLabel.stringValue = "mic"
} else if message.isVideo() {
mediaIconLabel.stringValue = "videocam"
} else if message.isGiphy() || message.isPicture() {
mediaIconLabel.stringValue = "photo_library"
} else if message.isPDF() {
mediaIconLabel.stringValue = "picture_as_pdf"
} else {
mediaIconLabel.stringValue = "description"
}

mediaContainerView.isHidden = false
mediaIconLabel.isHidden = false
} else {
mediaContainerView.isHidden = true
mediaIconLabel.isHidden = true
}

self.isHidden = false
}

func resetAndHide() {
self.isHidden = true
}

@IBAction func replyButtonClicked(_ sender: Any) {
delegate?.didTapMessageReplyView?()
}

@IBAction func closeButtonClicked(_ sender: Any) {
delegate?.didCloseReplyView?()
}

}
Loading