-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aae6177
commit 47f7956
Showing
24 changed files
with
641 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
TinkoffChat/Conversations Module/Conversation Screen/ConversationViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ConversationViewController.swift | ||
// TinkoffChat | ||
// | ||
// Created by Nikita Borodulin on 05/10/2017. | ||
// Copyright © 2017 com.nikitaborodulin. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class ConversationViewController: UIViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// Do any additional setup after loading the view. | ||
} | ||
|
||
override func didReceiveMemoryWarning() { | ||
super.didReceiveMemoryWarning() | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
|
||
/* | ||
// MARK: - Navigation | ||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
// Get the new view controller using segue.destinationViewController. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Conversation.swift | ||
// TinkoffChat | ||
// | ||
// Created by Nikita Borodulin on 06/10/2017. | ||
// Copyright © 2017 com.nikitaborodulin. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Conversation { | ||
let name: String | ||
var messages: [Message]? | ||
var online: Bool | ||
var hasUnreadMessages: Bool | ||
var lastMessageDate: Date? | ||
} |
17 changes: 17 additions & 0 deletions
17
...ffChat/Conversations Module/Conversations List Screen/ConversationCellConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// ConversationCellConfiguration.swift | ||
// TinkoffChat | ||
// | ||
// Created by Nikita Borodulin on 05/10/2017. | ||
// Copyright © 2017 com.nikitaborodulin. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol ConversationCellConfiguration: class { | ||
var name: String? { get set } | ||
var message: String? { get set } | ||
var date: Date? { get set } | ||
var online: Bool { get set } | ||
var hasUnreadMessages: Bool { get set } | ||
} |
77 changes: 77 additions & 0 deletions
77
TinkoffChat/Conversations Module/Conversations List Screen/ConversationTableViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// ConversationCellTableViewCell.swift | ||
// TinkoffChat | ||
// | ||
// Created by Nikita Borodulin on 05/10/2017. | ||
// Copyright © 2017 com.nikitaborodulin. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class ConversationTableViewCell: UITableViewCell, ConversationCellConfiguration { | ||
|
||
@IBOutlet weak var nameLabel: UILabel! | ||
@IBOutlet weak var messageLabel: UILabel! | ||
@IBOutlet weak var dateLabel: UILabel! | ||
|
||
private let onlineBackgroundColor: UIColor = #colorLiteral(red: 1, green: 0.9952996139, blue: 0.816628575, alpha: 1) | ||
private let noMessagesText = "No messages yet" | ||
|
||
|
||
class var identifier: String { | ||
return String(describing: self) | ||
} | ||
|
||
private let dateFormatter = DateFormatter() | ||
|
||
var name: String? { | ||
didSet { | ||
nameLabel.text = name | ||
} | ||
} | ||
|
||
var message: String? { | ||
didSet { | ||
if message != nil { | ||
let pointSize = messageLabel.font.pointSize | ||
messageLabel.font = UIFont.systemFont(ofSize: pointSize) | ||
messageLabel.text = message | ||
} else { | ||
let pointSize = messageLabel.font.pointSize | ||
messageLabel.font = UIFont.italicSystemFont(ofSize: pointSize) | ||
messageLabel.text = noMessagesText | ||
} | ||
|
||
} | ||
} | ||
|
||
var date: Date? { | ||
didSet { | ||
if let date = self.date { | ||
if Calendar.current.compare(Date(), to: date, toGranularity: .day) == .orderedSame { | ||
dateFormatter.dateFormat = "HH:mm" | ||
} else { | ||
dateFormatter.dateFormat = "dd MMM" | ||
} | ||
dateLabel.text = dateFormatter.string(from: date) | ||
} else { | ||
dateLabel.text = "" | ||
} | ||
} | ||
} | ||
|
||
var online: Bool = false { | ||
didSet { | ||
backgroundColor = online ? onlineBackgroundColor : .white | ||
} | ||
} | ||
|
||
var hasUnreadMessages: Bool = false { | ||
didSet { | ||
if hasUnreadMessages { | ||
let pointSize = messageLabel.font.pointSize | ||
messageLabel.font = UIFont.boldSystemFont(ofSize: pointSize) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.