Skip to content
Open
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
627 changes: 627 additions & 0 deletions Whatsapp-Swift/Whatsapp-Swift.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Whatsapp-Swift/Whatsapp-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// AppDelegate.swift
// Whatsapp-Swift
//
// Created by Breno Lima on 2/18/16.
// Copyright © 2016 Breno Lima. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return true
}

func applicationWillResignActive(application: UIApplication) {
}

func applicationDidEnterBackground(application: UIApplication) {
}

func applicationWillEnterForeground(application: UIApplication) {
}

func applicationDidBecomeActive(application: UIApplication) {
}

func applicationWillTerminate(application: UIApplication) {
}


}

168 changes: 168 additions & 0 deletions Whatsapp-Swift/Whatsapp-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="1sT-I4-iSp">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="as3-4D-EfA">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="1sT-I4-iSp" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="WyA-tt-cuS">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="S43-eP-bJc" kind="relationship" relationship="rootViewController" id="wKB-M7-jtA"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="eyM-UW-QYy" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-95" y="352"/>
</scene>
<!--Message Controller-->
<scene sceneID="HdW-G0-Oj0">
<objects>
<viewController storyboardIdentifier="Message" id="mA5-hc-8LE" customClass="MessageController" customModule="Whatsapp_Swift" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="lru-in-7mZ">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleAspectFill" image="chat background" id="Piy-Am-tJE">
<rect key="frame" x="0.0" y="64" width="320" height="461"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<gestureRecognizers/>
</imageView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="aRo-1l-mJe">
<rect key="frame" x="0.0" y="64" width="320" height="460"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableView>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="9Mb-lr-IaQ" customClass="Inputbar" customModule="Whatsapp_Swift" customModuleProvider="target">
<rect key="frame" x="0.0" y="524" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<items/>
</toolbar>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<gestureRecognizers/>
<connections>
<outletCollection property="gestureRecognizers" destination="jQh-aR-esj" appends="YES" id="nvT-Y4-PbE"/>
</connections>
</view>
<navigationItem key="navigationItem" id="O80-Xk-5QJ"/>
<connections>
<outlet property="inputbar" destination="9Mb-lr-IaQ" id="Tw4-ZU-XV7"/>
<outlet property="tableView" destination="aRo-1l-mJe" id="O2j-o5-ig0"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="CZs-AA-PH5" sceneMemberID="firstResponder"/>
<tapGestureRecognizer id="jQh-aR-esj">
<connections>
<action selector="userDidTapScreen:" destination="mA5-hc-8LE" id="ryD-BH-YhG"/>
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="766" y="352"/>
</scene>
<!--Chat Controller-->
<scene sceneID="rDK-Mg-OSR">
<objects>
<viewController storyboardIdentifier="Chat" id="S43-eP-bJc" customClass="ChatController" customModule="Whatsapp_Swift" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="fBD-ba-ifk">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="75" sectionHeaderHeight="22" sectionFooterHeight="22" id="E7o-tS-o85">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ChatListCell" id="o6o-Ze-8eI" customClass="ChatCell" customModule="Whatsapp_Swift" customModuleProvider="target">
<rect key="frame" x="0.0" y="86" width="320" height="75"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" tableViewCell="o6o-Ze-8eI" id="5wl-au-ShJ">
<rect key="frame" x="0.0" y="0.0" width="320" height="74"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="user" id="669-sb-uar">
<rect key="frame" x="10" y="10" width="55" height="55"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Username" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="WrY-vw-cCF">
<rect key="frame" x="73" y="10" width="170" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="12:50 PM" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="TAv-SX-P8M">
<rect key="frame" x="243" y="10" width="67" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="This is a big big test message that should use two lines" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="LIb-Ar-Rqt">
<rect key="frame" x="73" y="30" width="206" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="10" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="8" id="wF3-gQ-aG1">
<rect key="frame" x="287" y="37" width="25" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="messageLabel" destination="LIb-Ar-Rqt" id="zcB-JY-kNK"/>
<outlet property="nameLabel" destination="WrY-vw-cCF" id="hER-8c-59t"/>
<outlet property="notificationLabel" destination="wF3-gQ-aG1" id="9vc-1b-Hen"/>
<outlet property="picture" destination="669-sb-uar" id="OTn-Y0-e3i"/>
<outlet property="timeLabel" destination="TAv-SX-P8M" id="3CY-Ki-7vD"/>
</connections>
</tableViewCell>
</prototypes>
</tableView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Created by Rafael Castro" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="KKS-hs-7PA">
<rect key="frame" x="16" y="500" width="288" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="15"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="rafael.castro@hummingbird.com.br" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5LU-c7-qFx">
<rect key="frame" x="16" y="520" width="288" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="15"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.96078431369999995" green="0.96078431369999995" blue="0.96078431369999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<navigationItem key="navigationItem" id="KFF-Mc-1zY"/>
<connections>
<outlet property="tableView" destination="E7o-tS-o85" id="efT-NB-HQ8"/>
<segue destination="mA5-hc-8LE" kind="push" identifier="SegueMessage" id="6qV-Cw-5tq"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nkM-gv-90q" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="331" y="352"/>
</scene>
</scenes>
<resources>
<image name="chat background" width="320" height="461"/>
<image name="user" width="80" height="80"/>
</resources>
</document>
3 changes: 3 additions & 0 deletions Whatsapp-Swift/Whatsapp-Swift/Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#import "DAKeyboardControl.h"
#import "HPGrowingTextView.h"
#import "HPTextViewInternal.h"
35 changes: 35 additions & 0 deletions Whatsapp-Swift/Whatsapp-Swift/Chat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Chat.swift
// Whatsapp
//
// Created by Rafael Castro on 7/24/15. / Swift Version by Breno Oliveira on 02/18/16.
// Copyright (c) 2015 HummingBird. All rights reserved.
//

import UIKit
import Foundation

class Chat {
var contact:Contact!
var numberOfUnreadMessages:Int = 0

var lastMessage:Message! {
willSet (val) {
if self.lastMessage != nil {
if self.lastMessage.date.earlierDate(val.date) != self.lastMessage.date {
self.lastMessage = val
}
}
}
}

var identifier:String {
get {
return self.contact.identifier
}
}

func save() {
LocalStorage.sharedInstance.storeChat(self)
}
}
59 changes: 59 additions & 0 deletions Whatsapp-Swift/Whatsapp-Swift/ChatCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// ChatListCell.swift
// Whatsapp
//
// Created by Rafael Castro on 7/24/15. / Swift Version by Breno Oliveira on 02/18/16.
// Copyright (c) 2015 HummingBird. All rights reserved.
//

import UIKit

class ChatCell:UITableViewCell {
@IBOutlet weak var nameLabel:UILabel!
@IBOutlet weak var messageLabel:UILabel!
@IBOutlet weak var timeLabel:UILabel!
@IBOutlet weak var picture:UIImageView!
@IBOutlet weak var notificationLabel:UILabel!

override var imageView:UIImageView {
set {

}
get {
return self.picture
}
}

var chat:Chat! {
didSet {
self.nameLabel.text = chat.contact.name
self.messageLabel.text = chat.lastMessage.text
self.updateTimeLabelWithDate(chat.lastMessage.date)
self.updateUnreadMessagesIcon(chat.numberOfUnreadMessages)
}
}

override func awakeFromNib () {
self.picture.layer.cornerRadius = self.picture.frame.size.width/2
self.picture.layer.masksToBounds = true
self.notificationLabel.layer.cornerRadius = self.notificationLabel.frame.size.width/2
self.notificationLabel.layer.masksToBounds = true
self.nameLabel.text = ""
self.messageLabel.text = ""
self.timeLabel.text = ""
}

func updateTimeLabelWithDate(date:NSDate) {
let df = NSDateFormatter()
df.timeStyle = .ShortStyle
df.dateStyle = .NoStyle
df.doesRelativeDateFormatting = false
self.timeLabel.text = df.stringFromDate(date)
}

func updateUnreadMessagesIcon(numberOfUnreadMessages:Int)
{
self.notificationLabel.hidden = numberOfUnreadMessages == 0
self.notificationLabel.text = String(numberOfUnreadMessages)
}
}
Loading