Skip to content

Commit

Permalink
Merge pull request #40 from salemove/release/0.4.1
Browse files Browse the repository at this point in the history
Preparing for 0.4.1 release
  • Loading branch information
mc-vladyslav-kupriienko authored May 11, 2021
2 parents 412778f + 5d9f100 commit 12f9ffc
Show file tree
Hide file tree
Showing 42 changed files with 908 additions and 270 deletions.
202 changes: 126 additions & 76 deletions GliaWidgets.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

36 changes: 26 additions & 10 deletions GliaWidgets/Component/Bar/CallButtonBar/CallButtonBar.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit

class CallButtonBar: UIView {
class CallButtonBar: View {
enum Effect {
case none
case blur
Expand All @@ -24,26 +24,40 @@ class CallButtonBar: UIView {
private let style: CallButtonBarStyle
private let stackView = UIStackView()
private var buttons = [CallButton]()
private var effectView = UIVisualEffectView(effect: UIBlurEffect(style: .prominent))
private var effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
private var bottomSpaceConstraint: NSLayoutConstraint!
private var kInsets = UIEdgeInsets(top: 3.0, left: 3.0, bottom: 3.0, right: 3.0)
private var leftConstraint: NSLayoutConstraint!
private var rightConstraint: NSLayoutConstraint!
private var verticalAlignConstrait: NSLayoutConstraint!
private var kInsets = UIEdgeInsets(top: 7.0, left: 3.0, bottom: 7.0, right: 3.0)

init(with style: CallButtonBarStyle) {
self.style = style
super.init(frame: .zero)
super.init()
setup()
layout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
adjustStackConstraints()
}

override func layoutSubviews() {
super.layoutSubviews()
adjustBottomSpacing()
}

func adjustStackConstraints() {
if currentOrientation.isPortrait {
verticalAlignConstrait.autoRemove()
stackView.spacing = 2
leftConstraint.autoInstall()
rightConstraint.autoInstall()
} else {
leftConstraint.autoRemove()
rightConstraint.autoRemove()
stackView.spacing = 12
verticalAlignConstrait.autoInstall()
}
}

func setButton(_ kind: CallButton.Kind, enabled: Bool) {
button(for: kind)?.isEnabled = enabled
}
Expand All @@ -61,15 +75,17 @@ class CallButtonBar: UIView {

stackView.axis = .horizontal
stackView.distribution = .fillEqually
stackView.spacing = 2
}

private func layout() {
addSubview(effectView)
effectView.autoPinEdgesToSuperviewEdges()

addSubview(stackView)
stackView.autoPinEdgesToSuperviewEdges(with: kInsets, excludingEdge: .bottom)
stackView.autoPinEdge(toSuperviewEdge: .top, withInset: kInsets.top)
leftConstraint = stackView.autoPinEdge(toSuperviewEdge: .left, withInset: kInsets.left)
rightConstraint = stackView.autoPinEdge(toSuperviewEdge: .right, withInset: kInsets.right)
verticalAlignConstrait = stackView.autoAlignAxis(toSuperviewAxis: .vertical)
bottomSpaceConstraint = stackView.autoPinEdge(toSuperviewEdge: .bottom)
}

Expand Down
2 changes: 1 addition & 1 deletion GliaWidgets/Component/Header/Header.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Header: UIView {
private let rightItemContainer = UIView()
private let titleLabel = UILabel()
private let contentView = UIView()
private var effectView = UIVisualEffectView(effect: UIBlurEffect(style: .prominent))
private var effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
private var heightConstraint: NSLayoutConstraint?
private let kContentInsets = UIEdgeInsets(top: 0, left: 16, bottom: 10, right: 16)
private let kContentHeight: CGFloat = 30
Expand Down
45 changes: 30 additions & 15 deletions GliaWidgets/Component/ImageView/ImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,38 @@ class ImageView: UIImageView {
private static var cache = [String: UIImage]()
private var downloadID: String = ""

func setImage(_ image: UIImage?, animated: Bool) {
UIView.transition(with: self,
duration: animated ? 0.2 : 0.0,
options: .transitionCrossDissolve,
animations: {
self.image = image
}, completion: nil)
func setImage(_ image: UIImage?, animated: Bool, completionHandler: ((Bool) -> Void)? = nil) {
UIView.transition(
with: self,
duration: animated ? 0.2 : 0.0,
options: .transitionCrossDissolve,
animations: { self.image = image },
completion: completionHandler
)
}

func setImage(from url: String?, animated: Bool, finished: ((UIImage?) -> Void)? = nil) {
func setImage(
from url: String?,
animated: Bool,
imageReceived: ((UIImage?) -> Void)? = nil,
finished: ((UIImage?) -> Void)? = nil
) {
guard
let urlString = url,
let url = URL(string: urlString)
else {
setImage(nil, animated: animated)
finished?(nil)
imageReceived?(nil)
setImage(nil, animated: animated) { _ in
finished?(nil)
}
return
}

if let image = ImageView.cache[urlString] {
setImage(image, animated: animated)
imageReceived?(image)
setImage(image, animated: animated) { _ in
finished?(image)
}
return
}

Expand All @@ -37,8 +48,10 @@ class ImageView: UIImageView {
let image = UIImage(data: data)
else {
DispatchQueue.main.async {
self?.setImage(nil, animated: animated)
finished?(nil)
imageReceived?(nil)
self?.setImage(nil, animated: animated) { _ in
finished?(nil)
}
}
return
}
Expand All @@ -47,8 +60,10 @@ class ImageView: UIImageView {
ImageView.cache[urlString] = image

guard self?.downloadID == downloadID else { return }
self?.setImage(image, animated: animated)
finished?(image)
imageReceived?(image)
self?.setImage(image, animated: animated) { _ in
finished?(image)
}
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions GliaWidgets/Component/ImageView/User/UserImageStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import UIKit
public struct UserImageStyle {
public var placeholderImage: UIImage?
public var placeholderColor: UIColor
public var backgroundColor: UIColor
public var placeholderBackgroundColor: UIColor
public var imageBackgroundColor: UIColor

public init(placeholderImage: UIImage?,
placeholderColor: UIColor,
backgroundColor: UIColor) {
public init(
placeholderImage: UIImage?,
placeholderColor: UIColor,
placeholderBackgroundColor: UIColor,
imageBackgroundColor: UIColor
) {
self.placeholderImage = placeholderImage
self.placeholderColor = placeholderColor
self.backgroundColor = backgroundColor
self.placeholderBackgroundColor = placeholderBackgroundColor
self.imageBackgroundColor = imageBackgroundColor
}
}
19 changes: 17 additions & 2 deletions GliaWidgets/Component/ImageView/User/UserImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class UserImageView: UIView {
layout()
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
Expand All @@ -24,22 +25,31 @@ class UserImageView: UIView {
}

func setImage(_ image: UIImage?, animated: Bool) {
changeImageVisibility(visible: image != nil)
imageView.setImage(image, animated: animated)
}

func setImage(fromUrl url: String?, animated: Bool) {
imageView.setImage(from: url, animated: animated, finished: nil)
imageView.setImage(
from: url,
animated: animated,
imageReceived: { [weak self] image in
self?.changeImageVisibility(visible: image != nil)
}
)
}

private func setup() {
clipsToBounds = true

placeholderImageView.image = style.placeholderImage
placeholderImageView.tintColor = style.placeholderColor
placeholderImageView.backgroundColor = style.backgroundColor
placeholderImageView.backgroundColor = style.placeholderBackgroundColor
updatePlaceholderContentMode()

imageView.isHidden = true
imageView.contentMode = .scaleAspectFill
imageView.backgroundColor = style.imageBackgroundColor
}

private func layout() {
Expand All @@ -60,4 +70,9 @@ class UserImageView: UIView {
placeholderImageView.contentMode = .scaleAspectFit
}
}

private func changeImageVisibility(visible: Bool) {
placeholderImageView.isHidden = visible
imageView.isHidden = !visible
}
}
6 changes: 5 additions & 1 deletion GliaWidgets/Interactor/Interactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ extension Interactor: Interactable {
answer(context, true) { _, _ in }
}
}

var onEngagementTransfer: EngagementTransferBlock {
return { _ in }
}

var onOperatorTypingStatusUpdate: OperatorTypingStatusUpdate {
print("Called: \(#function)")
Expand Down Expand Up @@ -269,7 +273,7 @@ extension Interactor: Interactable {
}

func receive(message: Message) {
print("Called: \(#function)")
print("Called: \(#function). Content: \(message.content)")
notify(.receivedMessage(message))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
1 change: 1 addition & 0 deletions GliaWidgets/Resources/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ enum Color {
static let baseShade = UIColor(hex: 0x6C7683, alpha: 0.5)
static let baseDark = UIColor(hex: 0x2C0735)
static let lightGrey = UIColor(hex: 0xF3F3F3)
static let grey = UIColor(hex: 0x999999)
static let background: UIColor = .white
}
2 changes: 2 additions & 0 deletions GliaWidgets/Resources/L10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ public enum L10n {
public static let title = L10n.tr("Localizable", "chat.endButton.title")
}
public enum Message {
/// Tap on the answer above
public static let choiceCardPlaceholder = L10n.tr("Localizable", "chat.message.choiceCardPlaceholder")
/// Enter Message
public static let placeholder = L10n.tr("Localizable", "chat.message.placeholder")
public enum Status {
Expand Down
5 changes: 3 additions & 2 deletions GliaWidgets/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"chat.connect.connected.firstText" = "{operatorName}";
"chat.connect.connected.secondText" = "{operatorName} has joined the conversation.";
"chat.message.placeholder" = "Enter Message";
"chat.message.choiceCardPlaceholder" = "Tap on the answer above";
"chat.message.status.delivered" = "Delivered";
"chat.upgrade.audio.text" = "Upgraded to Audio Call";
"chat.upgrade.video.text" = "Upgraded to Video Call";
Expand All @@ -77,8 +78,8 @@
"chat.download.failed.separator" = " | ";
"chat.download.failed.retry" = "Retry";

"call.audio.title" = "AUDIO CALL";
"call.video.title" = "VIDEO CALL";
"call.audio.title" = "Audio";
"call.video.title" = "Video";
"call.endButton.title" = "End";
"call.connect.queue.firstText" = "CompanyName";
"call.connect.queue.secondText" = "An MSR will be with you shortly.";
Expand Down
3 changes: 2 additions & 1 deletion GliaWidgets/Theme/Theme+Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ extension Theme {
let operatorImage = UserImageStyle(
placeholderImage: Asset.operatorPlaceholder.image,
placeholderColor: color.baseLight,
backgroundColor: color.primary
placeholderBackgroundColor: color.primary,
imageBackgroundColor: .clear
)
let queueOperator = ConnectOperatorStyle(
operatorImage: operatorImage,
Expand Down
33 changes: 31 additions & 2 deletions GliaWidgets/Theme/Theme+Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ extension Theme {
let operatorImage = UserImageStyle(
placeholderImage: Asset.operatorPlaceholder.image,
placeholderColor: color.baseLight,
backgroundColor: color.primary
placeholderBackgroundColor: color.primary,
imageBackgroundColor: .clear
)
let queueOperator = ConnectOperatorStyle(
operatorImage: operatorImage,
Expand Down Expand Up @@ -84,6 +85,31 @@ extension Theme {
fileDownload: fileDownload,
operatorImage: operatorImage
)
let choiceCardText = ChatTextContentStyle(
textFont: font.bodyText,
textColor: color.baseDark,
backgroundColor: color.baseLight
)
let choiceCardImageFile = ChatImageFileContentStyle(
backgroundColor: color.baseLight
)
let choiceCardOption = ChoiceCardOptionStyle(
textFont: font.bodyText,
normalTextColor: color.baseDark,
normalBackgroundColor: Color.lightGrey,
highlightedTextColor: color.baseLight,
highlightedBackgroundColor: color.primary,
disabledTextColor: Color.grey,
disabledBackgroundColor: Color.lightGrey
)
let choiceCard = ChoiceCardStyle(
mainText: choiceCardText,
frameColor: color.primary,
imageFile: choiceCardImageFile,
fileDownload: fileDownload,
operatorImage: operatorImage,
choiceOption: choiceCardOption
)
let endButton = ActionButtonStyle(
title: Chat.EndButton.title,
titleFont: font.buttonLabel,
Expand All @@ -106,6 +132,7 @@ extension Theme {
messageFont: font.bodyText,
messageColor: color.baseDark,
placeholder: Chat.Message.placeholder,
choiceCardPlaceholder: Chat.Message.choiceCardPlaceholder,
placeholderFont: font.bodyText,
placeholderColor: color.baseNormal,
separatorColor: color.baseShade,
Expand Down Expand Up @@ -137,7 +164,8 @@ extension Theme {
let userImage = UserImageStyle(
placeholderImage: Asset.operatorPlaceholder.image,
placeholderColor: color.baseLight,
backgroundColor: color.primary
placeholderBackgroundColor: color.primary,
imageBackgroundColor: .clear
)
let callBubble = BubbleStyle(
userImage: userImage
Expand All @@ -154,6 +182,7 @@ extension Theme {
closeButton: closeButton,
visitorMessage: visitorMessage,
operatorMessage: operatorMessage,
choiceCard: choiceCard,
messageEntry: messageEntry,
audioUpgrade: audioUpgrade,
videoUpgrade: videoUpgrade,
Expand Down
3 changes: 2 additions & 1 deletion GliaWidgets/Theme/Theme+MinimizedBubble.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ extension Theme {
let userImage = UserImageStyle(
placeholderImage: Asset.operatorPlaceholder.image,
placeholderColor: color.baseLight,
backgroundColor: color.primary
placeholderBackgroundColor: color.primary,
imageBackgroundColor: color.primary
)
let badge = BadgeStyle(
font: font.caption,
Expand Down
Loading

0 comments on commit 12f9ffc

Please sign in to comment.