Skip to content

Commit

Permalink
Fix icons, build version
Browse files Browse the repository at this point in the history
  • Loading branch information
intoxicated committed Dec 22, 2017
1 parent 7d32383 commit feb8ef6
Show file tree
Hide file tree
Showing 66 changed files with 291 additions and 384 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Change Log
### 2.4.0
#### Update
* Redesigned UserChat UI/UX

#### Bug fixes
* Fixed minor bugs
* Fixed file upload logic (GIF)

### 2.3.3
#### Updated
Expand Down
2 changes: 1 addition & 1 deletion CHPlugin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Pod::Spec.new do |s|
s.dependency 'CHSlackTextViewController'
s.dependency 'MGSwipeTableCell'
s.dependency 'M13ProgressSuite'
s.dependency 'CHPhotoBrowser'
s.dependency 'CHPhotoBrowser', '2.1.7'
s.dependency 'SVProgressHUD'
s.dependency 'CRToast'
s.dependency 'PhoneNumberKit'
Expand Down
6 changes: 3 additions & 3 deletions CHPlugin/Assets/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ Press the button below to refresh.";
"ch.chat.retry_sending_message_question" = "Failed to send message.";
"ch.chat.retry_sending_message.delete" = "Delete";
"ch.chat.new_message" = "New message";
"ch.chat.expect_response_delay.instant" = "Fast";
"ch.chat.expect_response_delay.instant" = "Response Instant";
"ch.chat.expect_response_delay.instant.description" = "Replies within a few minutes.";
"ch.chat.expect_response_delay.normal.description" = "Replies within 30 minutes.";
"ch.chat.expect_response_delay.normal" = "Moderate";
"ch.chat.expect_response_delay.normal" = "Response Normal";
"ch.chat.expect_response_delay.delayed.description" = "It could take more than hours";
"ch.chat.expect_response_delay.delayed" = "Delayed";
"ch.chat.expect_response_delay.delayed" = "Response Delayed";
"ch.chat.expect_response_delay.out_of_working.description" = "Please leave a question and we will get back to you as soon as possible.";
"ch.chat.expect_response_delay.out_of_working" = "Off-hours";
"ch.chat.expect_response_delay.instant.short_description" = "Replies within a few minutes.";
Expand Down
2 changes: 0 additions & 2 deletions CHPlugin/Source/ChannelPlugin/ChannelPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ public final class ChannelPlugin : NSObject {

if !ChannelPlugin.hideLauncherButton &&
!mainStore.state.plugin.mobileHideButton {
// (!mainStore.state.channel.outOfWorkPlugin &&
// mainStore.state.channel.working) {
ChannelPlugin.showLauncher(on: topController?.view, animated: true)
}

Expand Down
6 changes: 3 additions & 3 deletions CHPlugin/Source/Controllers/ProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class ProfileViewController: BaseViewController {
$0.contentMode = .center
}
let versionLabel = UILabel().then {
$0.font = UIFont.systemFont(ofSize: 13)
$0.font = UIFont.systemFont(ofSize: 10)
$0.textColor = CHColors.blueyGrey
}

Expand Down Expand Up @@ -171,9 +171,9 @@ final class ProfileViewController: BaseViewController {
make.top.equalToSuperview().inset(10)
}

self.versionLabel.snp.makeConstraints { (make) in
self.versionLabel.snp.makeConstraints { [weak self] (make) in
make.trailing.equalToSuperview().inset(20)
make.top.equalToSuperview().inset(10)
make.bottom.equalTo((self?.logoImageView.snp.bottom)!)
}
}

Expand Down
31 changes: 0 additions & 31 deletions CHPlugin/Source/Controllers/UserChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ final class UserChatViewController: BaseSLKTextViewController {
var shouldShowGuide: Bool = false
var isFetching = false
var isRequstingReadAll = false
var userChatOpenAt: Date? = nil

var photoUrls = [String]()
var typingManagers = [CHManager]()
Expand Down Expand Up @@ -74,7 +73,6 @@ final class UserChatViewController: BaseSLKTextViewController {
//for proper layout in SlackTextViewController
self.textInputBarLRC = 5
self.textInputBarBC = 5
self.userChatOpenAt = self.userChatId == nil ? Date() : nil

super.viewDidLoad()
self.tableView.isHidden = true
Expand Down Expand Up @@ -510,35 +508,6 @@ final class UserChatViewController: BaseSLKTextViewController {
mainStore.dispatch(CreateMessage(payload: message))
}).disposed(by: self.disposeBag)
}

// fileprivate func createUserChatIfNeed(
// pluginId: String = "",
// userOpenAt: Date? = nil,
// completion: @escaping (String?) -> Void) {
// if self.userChatId != nil {
// completion(self.userChatId)
// return;
// }
//
// CHUserChat.create(
// pluginId: mainStore.state.plugin.id,
// timeStamp: self.userChatOpenAt)
// .subscribe(onNext: { [weak self] (chatResponse) in
// guard let userChat = chatResponse.userChat,
// let session = chatResponse.session else { return }
// self?.userChatId = userChat.id
// self?.chatManager?.chat = userChat
// mainStore.dispatch(CreateUserChat(payload: userChat))
// mainStore.dispatch(CreateSession(payload: session))
// WsService.shared.join(chatId: userChat.id)
//
// completion(userChat.id)
// }, onError: { [weak self] (error) in
// self?.state = .chatNotLoaded
// self?.showError()
// completion(nil)
// }).disposed(by: self.disposeBag)
// }
}

// MARK: - StoreSubscriber
Expand Down
2 changes: 1 addition & 1 deletion CHPlugin/Source/Controllers/UserChatsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class UserChatsViewController: BaseViewController {
let controller = ProfileViewController()
let navigation = MainNavigationController(rootViewController: controller)
navigation.modalPresentationStyle = .overCurrentContext
self.present(navigation, animated: true, completion: nil)
self.navigationController?.present(navigation, animated: true, completion: nil)
}
}

Expand Down
15 changes: 9 additions & 6 deletions CHPlugin/Source/Managers/ChatManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ChatManager {

let disposeBag = DisposeBag()

fileprivate var welcomedAt = Date()
fileprivate var typingPersons = [CHEntity]()
fileprivate var timeStorage = [String: Timer]()
fileprivate var animateTyping = false
Expand Down Expand Up @@ -289,18 +290,20 @@ extension ChatManager {
}
}

func createChat(
pluginId: String = "",
userOpenAt: Date? = nil,
completion: @escaping (String?) -> Void) {
func createChat(pluginId:String = "", completion: @escaping (String?) -> Void) {
if self.chatId != "" {
completion(self.chatId)
return;
}

var pluginId = pluginId
if pluginId == "" {
pluginId = mainStore.state.plugin.id
}

CHUserChat.create(
pluginId: mainStore.state.plugin.id,
timeStamp: userOpenAt)
pluginId: pluginId,
timeStamp: self.welcomedAt)
.subscribe(onNext: { [weak self] (chatResponse) in
guard let userChat = chatResponse.userChat,
let session = chatResponse.session else { return }
Expand Down
4 changes: 4 additions & 0 deletions CHPlugin/Source/Models/CHUserChat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ extension CHUserChat {
func isReady() -> Bool {
return self.state == "ready" || self.state == "open"
}

func isEngaged() -> Bool {
return self.state == "resolved" || self.state == "closed" || self.state == "following"
}
}

extension CHUserChat: Equatable {
Expand Down
25 changes: 14 additions & 11 deletions CHPlugin/Source/Utils/LocalMessageFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ enum MessageType {

struct LocalMessageFactory {

static func generate(type: MessageType,
messages: [CHMessage] = [],
userChat: CHUserChat? = nil,
text: String? = nil) -> [CHMessage] {
static func generate(
type: MessageType,
messages: [CHMessage] = [],
userChat: CHUserChat? = nil,
text: String? = nil) -> [CHMessage] {

switch type {
case .DateDivider:
Expand Down Expand Up @@ -80,11 +81,12 @@ struct LocalMessageFactory {
let date = messages[element.0]
.createdAt
.add(components: [Calendar.Component.nanosecond: -100])
let msg = CHMessage(chatId:chatId,
message:element.1,
type: .DateDivider,
createdAt: date,
id: element.1)
let msg = CHMessage(
chatId:chatId,
message:element.1,
type: .DateDivider,
createdAt: date,
id: element.1)
newMessages.insert(msg, at: element.0 + 1)
}

Expand All @@ -102,8 +104,9 @@ struct LocalMessageFactory {
}

//insert new message model into proper position
private static func insertNewMessage(messages: [CHMessage],
userChat: CHUserChat) -> [CHMessage] {
private static func insertNewMessage(
messages: [CHMessage],
userChat: CHUserChat) -> [CHMessage] {
guard let session = userChat.session else { return messages }
guard let lastReadAt = session.lastReadAt else { return messages }

Expand Down
1 change: 1 addition & 0 deletions CHPlugin/Source/Views/CHMBubbleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class CHMBubbleView : BaseView {
self.roundCorners(corners: [.topRight, .bottomRight, .bottomLeft], radius: Constant.cornerRadius)
}

//TODO: fix layout properly
self.messageView.snp.remakeConstraints({ [weak self] (make) in
if self?.messageView.text == "" {
return
Expand Down
6 changes: 1 addition & 5 deletions CHPlugin/Source/Views/CHMImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
import NVActivityIndicatorView
import M13ProgressSuite
import DKImagePickerController
import SDWebImage
import SnapKit

class CHMImageView : BaseView {
Expand Down Expand Up @@ -97,10 +96,7 @@ class CHMImageView : BaseView {
self.placeholder = nil
}

self.imageView.sd_setImage(with: url, placeholderImage: self.imageView.image, options: .retryFailed,
progress: { (recv, total) in

}, completed: { [weak self] (image, error, cacheType, url) in
self.imageView.sd_setImage(with: url, completed: { [weak self] (image, error, cacheType, url) in
self?.imageView.alpha = 1
self?.indicatorView.stopAnimating()
})
Expand Down
21 changes: 14 additions & 7 deletions CHPlugin/Source/Views/Cells/UserChatCell/UserChatCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class UserChatCell: BaseTableViewCell, Reusable {
)
}

let multiAvatarView = MultiAvatarView()
let avatarView = AvatarView()

let badge = Badge()

Expand All @@ -85,19 +85,19 @@ final class UserChatCell: BaseTableViewCell, Reusable {
self.selectedBackgroundView = self.bgView
self.contentView.addSubview(self.titleLabel)
self.contentView.addSubview(self.timestampLabel)
self.contentView.addSubview(self.multiAvatarView)
self.contentView.addSubview(self.avatarView)
self.contentView.addSubview(self.badge)
self.contentView.addSubview(self.messageLabel)

self.multiAvatarView.snp.remakeConstraints { (make) in
self.avatarView.snp.remakeConstraints { (make) in
make.top.equalToSuperview().inset(Metric.cellTopPadding)
make.left.equalToSuperview().inset(Metric.cellLeftPadding)
make.size.equalTo(CGSize(width: Metric.avatarWidth, height: Metric.avatarHeight))
}

self.titleLabel.snp.remakeConstraints { [weak self] (make) in
make.top.equalToSuperview().inset(Metric.cellTopPadding)
make.left.equalTo((self?.multiAvatarView.snp.right)!).offset(Metric.avatarRightPadding)
make.left.equalTo((self?.avatarView.snp.right)!).offset(Metric.avatarRightPadding)
}

self.timestampLabel.snp.remakeConstraints { [weak self] (make) in
Expand All @@ -108,7 +108,7 @@ final class UserChatCell: BaseTableViewCell, Reusable {

self.messageLabel.snp.remakeConstraints { [weak self] (make) in
make.top.equalTo((self?.titleLabel.snp.bottom)!).offset(Metric.titleBottomPadding)
make.left.equalTo((self?.multiAvatarView.snp.right)!).offset(Metric.avatarRightPadding)
make.left.equalTo((self?.avatarView.snp.right)!).offset(Metric.avatarRightPadding)
//if (self?.badge.isHidden)! {
make.right.equalToSuperview().inset(76)
//} else {
Expand All @@ -134,10 +134,10 @@ final class UserChatCell: BaseTableViewCell, Reusable {
self.messageLabel.text = viewModel.lastMessage

if let avatar = viewModel.avatar {
self.multiAvatarView.configure([avatar])
self.avatarView.configure(avatar)
} else {
let channel = mainStore.state.channel
self.multiAvatarView.configure([channel])
self.avatarView.configure(channel)
}

self.messageLabel.textColor = viewModel.isClosed ?
Expand All @@ -159,4 +159,11 @@ final class UserChatCell: BaseTableViewCell, Reusable {
return Metric.cellHeight
}

override func setHighlighted(_ highlighted: Bool, animated: Bool) {
let avatarColor = self.avatarView.initialLabel.backgroundColor
super.setHighlighted(highlighted, animated: animated)
if highlighted {
self.avatarView.initialLabel.backgroundColor = avatarColor
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ class ChatStatusDefaultView : BaseView {
self.businessHoursLabel.snp.makeConstraints { (make) in
make.leading.equalToSuperview().inset(18)
make.trailing.equalToSuperview().inset(18)
make.top.equalToSuperview().inset(15)
make.bottom.equalToSuperview().inset(15)
make.centerY.equalToSuperview()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ class NavigationTitleView : BaseView {
self.titleLabel.textColor = plugin.textUIColor
self.subtitleLabel.textColor = plugin.textUIColor

if userChat?.isReady() == true || userChat == nil {
self.configureForReady(channel: channel, plugin: plugin)
} else if let host = userChat?.lastTalkedHost, !(host is CHBot) {
if let host = userChat?.lastTalkedHost, userChat?.isEngaged() == true {
self.configureForFollow(host: host, plugin: plugin)
} else if !channel.working {
self.configureForOff(channel: channel, plugin: plugin)
} else {
self.configureForReady(channel: channel, plugin: plugin)
}
}

Expand Down
Loading

0 comments on commit feb8ef6

Please sign in to comment.