Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sridatta Gorugantula
Stickers
Commits
ae201326
Unverified
Commit
ae201326
authored
Oct 14, 2021
by
vamsigoru
Committed by
GitHub
Oct 14, 2021
Browse files
Delete iOS directory
parent
0c51d2e4
Changes
124
Hide whitespace changes
Inline
Side-by-side
iOS/WAStickersThirdParty/Base.lproj/LaunchScreen.storyboard
deleted
100644 → 0
View file @
0c51d2e4
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"13529"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
launchScreen=
"YES"
useTraitCollections=
"YES"
colorMatched=
"YES"
initialViewController=
"01J-lp-oVM"
>
<device
id=
"retina4_7"
orientation=
"portrait"
>
<adaptation
id=
"fullscreen"
/>
</device>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"13527"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<scenes>
<!--View Controller-->
<scene
sceneID=
"EHf-IW-A2E"
>
<objects>
<viewController
id=
"01J-lp-oVM"
sceneMemberID=
"viewController"
>
<layoutGuides>
<viewControllerLayoutGuide
type=
"top"
id=
"bK9-LS-qsM"
/>
<viewControllerLayoutGuide
type=
"bottom"
id=
"wvZ-4g-QJW"
/>
</layoutGuides>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"Ze5-6b-2t3"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"375"
height=
"667"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<color
key=
"backgroundColor"
red=
"1"
green=
"1"
blue=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
</view>
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"iYj-Kq-Ea1"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"53"
y=
"375"
/>
</scene>
</scenes>
</document>
iOS/WAStickersThirdParty/Base.lproj/Main.storyboard
deleted
100644 → 0
View file @
0c51d2e4
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"17156"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
colorMatched=
"YES"
initialViewController=
"Sml-2X-rvl"
>
<device
id=
"retina4_7"
orientation=
"portrait"
appearance=
"light"
/>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"17126"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<scenes>
<!--Sticker Packs-->
<scene
sceneID=
"B1S-hN-MFe"
>
<objects>
<viewController
title=
"Sticker Packs"
id=
"M67-ew-auO"
customClass=
"AllStickerPacksViewController"
customModule=
"WAStickersThirdParty"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<layoutGuides>
<viewControllerLayoutGuide
type=
"top"
id=
"83V-gx-xE9"
/>
<viewControllerLayoutGuide
type=
"bottom"
id=
"ajP-Ty-Icd"
/>
</layoutGuides>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"8NA-Zm-FU0"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"375"
height=
"667"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<tableView
clipsSubviews=
"YES"
contentMode=
"scaleToFill"
alwaysBounceVertical=
"YES"
dataMode=
"prototypes"
style=
"plain"
separatorStyle=
"default"
rowHeight=
"-1"
estimatedRowHeight=
"-1"
sectionHeaderHeight=
"28"
sectionFooterHeight=
"28"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"CD6-Ts-Zg8"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"375"
height=
"647"
/>
<color
key=
"backgroundColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<connections>
<outlet
property=
"dataSource"
destination=
"M67-ew-auO"
id=
"38Z-vo-dea"
/>
<outlet
property=
"delegate"
destination=
"M67-ew-auO"
id=
"K1J-Xe-rti"
/>
</connections>
</tableView>
</subviews>
<color
key=
"backgroundColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<constraints>
<constraint
firstItem=
"CD6-Ts-Zg8"
firstAttribute=
"top"
secondItem=
"8NA-Zm-FU0"
secondAttribute=
"top"
id=
"BZp-Rb-Cjh"
/>
<constraint
firstItem=
"CD6-Ts-Zg8"
firstAttribute=
"leading"
secondItem=
"8NA-Zm-FU0"
secondAttribute=
"leading"
id=
"bIs-fm-lmT"
/>
<constraint
firstItem=
"CD6-Ts-Zg8"
firstAttribute=
"bottom"
secondItem=
"ajP-Ty-Icd"
secondAttribute=
"top"
constant=
"-20"
id=
"fPF-ya-Tm9"
/>
<constraint
firstItem=
"CD6-Ts-Zg8"
firstAttribute=
"trailing"
secondItem=
"8NA-Zm-FU0"
secondAttribute=
"trailing"
id=
"vda-Sj-2Bg"
/>
</constraints>
</view>
<navigationItem
key=
"navigationItem"
title=
"Sticker Packs"
largeTitleDisplayMode=
"never"
id=
"x4y-Ef-GnB"
/>
<connections>
<outlet
property=
"stickerPacksTableView"
destination=
"CD6-Ts-Zg8"
id=
"2vb-pz-MeQ"
/>
<segue
destination=
"Ngp-pe-fiT"
kind=
"show"
identifier=
"stickerPackAnimated"
id=
"xrT-yi-hRx"
/>
<segue
destination=
"Ngp-pe-fiT"
kind=
"show"
identifier=
"stickerPackNotAnimated"
animates=
"NO"
id=
"ejY-ay-Qg6"
/>
</connections>
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"uC1-1q-rug"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"1212"
y=
"915.29235382308855"
/>
</scene>
<!--Sticker Pack View Controller-->
<scene
sceneID=
"edg-Pz-Hza"
>
<objects>
<viewController
storyboardIdentifier=
"stickerPackVC"
useStoryboardIdentifierAsRestorationIdentifier=
"YES"
id=
"Ngp-pe-fiT"
customClass=
"StickerPackViewController"
customModule=
"WAStickersThirdParty"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<layoutGuides>
<viewControllerLayoutGuide
type=
"top"
id=
"xVg-Eq-uuA"
/>
<viewControllerLayoutGuide
type=
"bottom"
id=
"40j-fZ-Ld1"
/>
</layoutGuides>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"lw1-NE-fbo"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"375"
height=
"623"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Label"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"qTI-28-AWf"
>
<rect
key=
"frame"
x=
"16"
y=
"8"
width=
"41.5"
height=
"21"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"21"
id=
"bnw-oc-8F2"
/>
</constraints>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"17"
/>
<color
key=
"textColor"
white=
"0.66666666669999997"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<nil
key=
"highlightedColor"
/>
</label>
<collectionView
clipsSubviews=
"YES"
multipleTouchEnabled=
"YES"
contentMode=
"scaleToFill"
dataMode=
"prototypes"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"opL-AO-nSO"
>
<rect
key=
"frame"
x=
"0.0"
y=
"53"
width=
"375"
height=
"550"
/>
<color
key=
"backgroundColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<collectionViewFlowLayout
key=
"collectionViewLayout"
minimumLineSpacing=
"10"
minimumInteritemSpacing=
"10"
id=
"Cwh-cs-v6O"
>
<size
key=
"itemSize"
width=
"91"
height=
"83"
/>
<size
key=
"headerReferenceSize"
width=
"0.0"
height=
"0.0"
/>
<size
key=
"footerReferenceSize"
width=
"0.0"
height=
"0.0"
/>
<inset
key=
"sectionInset"
minX=
"0.0"
minY=
"0.0"
maxX=
"0.0"
maxY=
"0.0"
/>
</collectionViewFlowLayout>
<cells/>
<connections>
<outlet
property=
"dataSource"
destination=
"Ngp-pe-fiT"
id=
"h9s-zx-g45"
/>
<outlet
property=
"delegate"
destination=
"Ngp-pe-fiT"
id=
"kDI-rU-qED"
/>
</connections>
</collectionView>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"StickerAnimation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"rGq-rW-azI"
>
<rect
key=
"frame"
x=
"60.5"
y=
"10.5"
width=
"16"
height=
"16"
/>
<constraints>
<constraint
firstAttribute=
"width"
constant=
"16"
id=
"fuy-YM-lEh"
/>
<constraint
firstAttribute=
"height"
constant=
"16"
id=
"j9l-nl-xK8"
/>
</constraints>
</imageView>
</subviews>
<color
key=
"backgroundColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<constraints>
<constraint
firstAttribute=
"trailingMargin"
secondItem=
"opL-AO-nSO"
secondAttribute=
"trailing"
constant=
"-16"
id=
"7Vx-Ks-2si"
/>
<constraint
firstAttribute=
"trailingMargin"
relation=
"greaterThanOrEqual"
secondItem=
"rGq-rW-azI"
secondAttribute=
"trailing"
id=
"9f0-UZ-NrE"
/>
<constraint
firstItem=
"rGq-rW-azI"
firstAttribute=
"centerY"
secondItem=
"qTI-28-AWf"
secondAttribute=
"centerY"
id=
"BMg-iK-lQ1"
/>
<constraint
firstItem=
"40j-fZ-Ld1"
firstAttribute=
"top"
secondItem=
"opL-AO-nSO"
secondAttribute=
"bottom"
constant=
"20"
id=
"Bzo-Tv-YcR"
/>
<constraint
firstItem=
"qTI-28-AWf"
firstAttribute=
"leading"
secondItem=
"lw1-NE-fbo"
secondAttribute=
"leadingMargin"
id=
"cl5-Iw-9Za"
/>
<constraint
firstItem=
"opL-AO-nSO"
firstAttribute=
"leading"
secondItem=
"lw1-NE-fbo"
secondAttribute=
"leadingMargin"
constant=
"-16"
id=
"d0x-Kb-TlR"
/>
<constraint
firstItem=
"qTI-28-AWf"
firstAttribute=
"top"
secondItem=
"xVg-Eq-uuA"
secondAttribute=
"bottom"
constant=
"8"
id=
"did-Ku-ViG"
/>
<constraint
firstItem=
"qTI-28-AWf"
firstAttribute=
"trailing"
secondItem=
"rGq-rW-azI"
secondAttribute=
"leading"
constant=
"-3"
id=
"jw6-pu-Hwm"
/>
<constraint
firstItem=
"opL-AO-nSO"
firstAttribute=
"top"
secondItem=
"qTI-28-AWf"
secondAttribute=
"bottom"
constant=
"24"
id=
"rkw-yD-2wR"
/>
</constraints>
</view>
<navigationItem
key=
"navigationItem"
id=
"vdG-Gw-ApK"
/>
<simulatedNavigationBarMetrics
key=
"simulatedTopBarMetrics"
translucent=
"NO"
prompted=
"NO"
/>
<connections>
<outlet
property=
"bottomCollectionViewConstraint"
destination=
"Bzo-Tv-YcR"
id=
"Yzu-5Y-vDZ"
/>
<outlet
property=
"stickerPackAnimationIcon"
destination=
"rGq-rW-azI"
id=
"Rdq-ZU-F2X"
/>
<outlet
property=
"stickerPackPublisherLabel"
destination=
"qTI-28-AWf"
id=
"Zr2-we-2PP"
/>
<outlet
property=
"stickersCollectionView"
destination=
"opL-AO-nSO"
id=
"amO-5H-Gta"
/>
<segue
destination=
"RZ6-Ve-eGr"
kind=
"presentation"
identifier=
"info"
id=
"4ah-bc-CCw"
/>
</connections>
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"b2G-8x-4eR"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"1941.5999999999999"
y=
"914.392803598201"
/>
</scene>
<!--Info-->
<scene
sceneID=
"GSF-2F-TCa"
>
<objects>
<tableViewController
id=
"VuN-R9-mKn"
customClass=
"StickerPackInfoViewController"
customModule=
"WAStickersThirdParty"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<tableView
key=
"view"
clipsSubviews=
"YES"
contentMode=
"scaleToFill"
alwaysBounceVertical=
"YES"
dataMode=
"prototypes"
style=
"grouped"
separatorStyle=
"none"
rowHeight=
"-1"
estimatedRowHeight=
"-1"
sectionHeaderHeight=
"18"
sectionFooterHeight=
"18"
id=
"dwL-sg-TYV"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"375"
height=
"647"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<color
key=
"backgroundColor"
systemColor=
"groupTableViewBackgroundColor"
/>
<connections>
<outlet
property=
"dataSource"
destination=
"VuN-R9-mKn"
id=
"qXF-fg-g5B"
/>
<outlet
property=
"delegate"
destination=
"VuN-R9-mKn"
id=
"48C-xj-PKK"
/>
</connections>
</tableView>
<navigationItem
key=
"navigationItem"
title=
"Info"
id=
"kT8-qH-4Vv"
>
<barButtonItem
key=
"rightBarButtonItem"
style=
"done"
systemItem=
"done"
id=
"djo-Zr-wQq"
>
<connections>
<action
selector=
"donePressed:"
destination=
"VuN-R9-mKn"
id=
"Tfe-jj-1Zm"
/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"pXA-R6-oeZ"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"3641"
y=
"916"
/>
</scene>
<!--Navigation Controller-->
<scene
sceneID=
"cJb-jt-Zt3"
>
<objects>
<navigationController
id=
"RZ6-Ve-eGr"
sceneMemberID=
"viewController"
>
<navigationBar
key=
"navigationBar"
contentMode=
"scaleToFill"
insetsLayoutMarginsFromSafeArea=
"NO"
id=
"OZf-37-dtw"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"375"
height=
"56"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
</navigationBar>
<connections>
<segue
destination=
"VuN-R9-mKn"
kind=
"relationship"
relationship=
"rootViewController"
id=
"ndi-cL-HVq"
/>
</connections>
</navigationController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"UNh-QS-CMO"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"2817"
y=
"915"
/>
</scene>
<!--Navigation Controller-->
<scene
sceneID=
"ay7-pT-DQM"
>
<objects>
<navigationController
automaticallyAdjustsScrollViewInsets=
"NO"
id=
"Sml-2X-rvl"
sceneMemberID=
"viewController"
>
<toolbarItems/>
<navigationBar
key=
"navigationBar"
contentMode=
"scaleToFill"
insetsLayoutMarginsFromSafeArea=
"NO"
largeTitles=
"YES"
id=
"91S-II-eXq"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"375"
height=
"96"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
<color
key=
"barTintColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
</navigationBar>
<nil
name=
"viewControllers"
/>
<connections>
<segue
destination=
"M67-ew-auO"
kind=
"relationship"
relationship=
"rootViewController"
id=
"Gga-oJ-3kI"
/>
</connections>
</navigationController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"v9T-AN-dLq"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"465"
y=
"915"
/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue
reference=
"ejY-ay-Qg6"
/>
</inferredMetricsTieBreakers>
<resources>
<image
name=
"StickerAnimation"
width=
"16"
height=
"16"
/>
<systemColor
name=
"groupTableViewBackgroundColor"
>
<color
red=
"0.94901960784313721"
green=
"0.94901960784313721"
blue=
"0.96862745098039216"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
</systemColor>
</resources>
</document>
iOS/WAStickersThirdParty/GradientView.swift
deleted
100644 → 0
View file @
0c51d2e4
//
// Copyright (c) WhatsApp Inc. and its affiliates.
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
//
import
UIKit
class
GradientView
:
UIView
{
override
var
layer
:
CAGradientLayer
{
return
super
.
layer
as!
CAGradientLayer
}
convenience
init
(
topColor
:
UIColor
,
bottomColor
:
UIColor
)
{
self
.
init
(
frame
:
.
zero
)
backgroundColor
=
.
clear
layer
.
startPoint
=
CGPoint
(
x
:
0.5
,
y
:
0.0
)
layer
.
endPoint
=
CGPoint
(
x
:
0.5
,
y
:
1.0
)
layer
.
colors
=
[
topColor
.
cgColor
,
bottomColor
.
cgColor
]
}
override
class
var
layerClass
:
AnyClass
{
return
CAGradientLayer
.
self
}
}
iOS/WAStickersThirdParty/ImageData.swift
deleted
100644 → 0
View file @
0c51d2e4
//
// Copyright (c) WhatsApp Inc. and its affiliates.
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
//
import
UIKit
extension
CGSize
{
public
static
func
==
(
left
:
CGSize
,
right
:
CGSize
)
->
Bool
{
return
left
.
width
.
isEqual
(
to
:
right
.
width
)
&&
left
.
height
.
isEqual
(
to
:
right
.
height
)
}
public
static
func
<
(
left
:
CGSize
,
right
:
CGSize
)
->
Bool
{
return
left
.
width
.
isLess
(
than
:
right
.
width
)
&&
left
.
height
.
isLess
(
than
:
right
.
height
)
}
public
static
func
>
(
left
:
CGSize
,
right
:
CGSize
)
->
Bool
{
return
!
left
.
width
.
isLessThanOrEqualTo
(
right
.
width
)
&&
!
left
.
height
.
isLessThanOrEqualTo
(
right
.
height
)
}
public
static
func
<=
(
left
:
CGSize
,
right
:
CGSize
)
->
Bool
{
return
left
.
width
.
isLessThanOrEqualTo
(
right
.
width
)
&&
left
.
height
.
isLessThanOrEqualTo
(
right
.
height
)
}
public
static
func
>=
(
left
:
CGSize
,
right
:
CGSize
)
->
Bool
{
return
!
left
.
width
.
isLess
(
than
:
right
.
width
)
&&
!
left
.
height
.
isLess
(
than
:
right
.
height
)
}
}
/**
* Represents the two supported extensions for sticker images: png and webp.
*/
enum
ImageDataExtension
:
String
{
case
png
=
"png"
case
webp
=
"webp"
}
/**
* Stores sticker image data along with its supported extension.
*/
class
ImageData
{
let
data
:
Data
let
type
:
ImageDataExtension
var
bytesSize
:
Int64
{
return
Int64
(
data
.
count
)
}
/**
* Returns whether or not the data represents an animated image.
* It will always return false if the image is png.
*/
lazy
var
animated
:
Bool
=
{
if
type
==
.
webp
{
return
WebPManager
.
shared
.
isAnimated
(
webPData
:
data
)
}
else
{
return
false
}
}()
/**
* Returns the minimum frame duration for an animated image in milliseconds.
* It will always return -1 if the image is not animated.
*/
lazy
var
minFrameDuration
:
Double
=
{
return
WebPManager
.
shared
.
minFrameDuration
(
webPData
:
data
)
*
1000
}()
/**
* Returns the total animation duration for an animated image in milliseconds.
* It will always return -1 if the image is not animated.
*/
lazy
var
totalAnimationDuration
:
Double
=
{
return
WebPManager
.
shared
.
totalAnimationDuration
(
webPData
:
data
)
*
1000
}()
/**
* Returns the webp data representation of the current image. If the current image is already webp,
* the data is simply returned. If it's png, it will returned the webp converted equivalent data.
*/
lazy
var
webpData
:
Data
?
=
{
if
type
==
.
webp
{
return
data
}
else
{
return
WebPManager
.
shared
.
encode
(
pngData
:
data
)
}
}()
/**
* Returns a UIImage of the current image data. If data is corrupt, nil will be returned.
*/
lazy
var
image
:
UIImage
?
=
{
if
type
==
.
webp
{
guard
let
images
=
WebPManager
.
shared
.
decode
(
webPData
:
data
)
else
{
return
nil
}
if
images
.
count
==
0
{
return
nil
}
if
images
.
count
==
1
{
return
images
.
first
}
return
UIImage
.
animatedImage
(
with
:
images
,
duration
:
WebPManager
.
shared
.
totalAnimationDuration
(
webPData
:
data
))
}
else
{
// Static image
return
UIImage
(
data
:
data
)
}
}()
/**
* Returns an image with the new size.
*/
func
image
(
withSize
size
:
CGSize
)
->
UIImage
?
{
guard
let
image
=
image
else
{
return
nil
}
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
UIScreen
.
main
.
scale
)
image
.
draw
(
in
:
CGRect
(
origin
:
.
zero
,
size
:
size
))
let
resizedImage
:
UIImage
=
UIGraphicsGetImageFromCurrentImageContext
()
!
UIGraphicsEndImageContext
()
return
resizedImage
}
init
(
data
:
Data
,
type
:
ImageDataExtension
)
{
self
.
data
=
data
self
.
type
=
type
}
static
func
imageDataIfCompliant
(
contentsOfFile
filename
:
String
,
isTray
:
Bool
)
throws
->
ImageData
{
let
fileExtension
:
String
=
(
filename
as
NSString
)
.
pathExtension
guard
let
imageURL
=
Bundle
.
main
.
url
(
forResource
:
filename
,
withExtension
:
""
)
else
{
throw
StickerPackError
.
fileNotFound
}
let
data
=
try
Data
(
contentsOf
:
imageURL
)
guard
let
imageType
=
ImageDataExtension
(
rawValue
:
fileExtension
)
else
{
throw
StickerPackError
.
unsupportedImageFormat
(
fileExtension
)
}
return
try
ImageData
.
imageDataIfCompliant
(
rawData
:
data
,
extensionType
:
imageType
,
isTray
:
isTray
)
}
static
func
imageDataIfCompliant
(
rawData
:
Data
,
extensionType
:
ImageDataExtension
,
isTray
:
Bool
)
throws
->
ImageData
{
let
imageData
=
ImageData
(
data
:
rawData
,
type
:
extensionType
)
guard
imageData
.
bytesSize
>
0
else
{
throw
StickerPackError
.
invalidImage
}
if
isTray
{
guard
!
imageData
.
animated
else
{
throw
StickerPackError
.
animatedImagesNotSupported
}
guard
imageData
.
bytesSize
<=
Limits
.
MaxTrayImageFileSize
else
{
throw
StickerPackError
.
imageTooBig
(
imageData
.
bytesSize
,
false
)
}
guard
imageData
.
image
!.
size
==
Limits
.
TrayImageDimensions
else
{
throw
StickerPackError
.
incorrectImageSize
(
imageData
.
image
!.
size
)
}
}
else
{
let
isAnimated
=
imageData
.
animated
guard
(
isAnimated
&&
imageData
.
bytesSize
<=
Limits
.
MaxAnimatedStickerFileSize
)
||
(
!
isAnimated
&&
imageData
.
bytesSize
<=
Limits
.
MaxStaticStickerFileSize
)
else
{
throw
StickerPackError
.
imageTooBig
(
imageData
.
bytesSize
,
isAnimated
)
}
guard
imageData
.
image
!.
size
==
Limits
.
ImageDimensions
else
{
throw
StickerPackError
.
incorrectImageSize
(
imageData
.
image
!.
size
)
}
if
isAnimated
{
guard
imageData
.
minFrameDuration
>=
Double
(
Limits
.
MinAnimatedStickerFrameDurationMS
)
else
{
throw
StickerPackError
.
minFrameDurationTooShort
(
imageData
.
minFrameDuration
)
}
guard
imageData
.
totalAnimationDuration
<=
Double
(
Limits
.
MaxAnimatedStickerTotalDurationMS
)
else
{
throw
StickerPackError
.
totalAnimationDurationTooLong
(
imageData
.
totalAnimationDuration
)
}
}
}
return
imageData
}
}
iOS/WAStickersThirdParty/Info.plist
deleted
100644 → 0
View file @
0c51d2e4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
NSPhotoLibraryAddUsageDescription
</key>
<string>
The sticker/s will be saved in your photo library.
</string>
<key>
CFBundleDevelopmentRegion
</key>
<string>
$(DEVELOPMENT_LANGUAGE)
</string>
<key>
CFBundleDisplayName
</key>
<string>
Cuppy
</string>
<key>
CFBundleExecutable
</key>
<string>
$(EXECUTABLE_NAME)
</string>
<key>
CFBundleIdentifier
</key>
<string>
$(PRODUCT_BUNDLE_IDENTIFIER)
</string>
<key>
CFBundleInfoDictionaryVersion
</key>
<string>
6.0
</string>
<key>
CFBundleName
</key>
<string>
$(PRODUCT_NAME)
</string>
<key>
CFBundlePackageType
</key>
<string>
APPL
</string>
<key>
CFBundleShortVersionString
</key>
<string>
1.0
</string>
<key>
CFBundleVersion
</key>
<string>
1.1
</string>
<key>
LSApplicationCategoryType
</key>
<string></string>
<key>
LSApplicationQueriesSchemes
</key>
<array>
<string>
whatsapp
</string>
</array>
<key>
LSRequiresIPhoneOS
</key>
<true/>
<key>
UILaunchStoryboardName
</key>
<string>
LaunchScreen
</string>
<key>
UIMainStoryboardFile
</key>
<string>
Main
</string>
<key>
UIRequiredDeviceCapabilities
</key>
<array>
<string>
armv7
</string>
</array>
<key>
UISupportedInterfaceOrientations
</key>
<array>
<string>
UIInterfaceOrientationPortrait
</string>
<string>
UIInterfaceOrientationLandscapeLeft
</string>
<string>
UIInterfaceOrientationLandscapeRight
</string>
</array>
<key>
UISupportedInterfaceOrientations~ipad
</key>
<array>
<string>
UIInterfaceOrientationPortrait
</string>
<string>
UIInterfaceOrientationPortraitUpsideDown
</string>
<string>
UIInterfaceOrientationLandscapeLeft
</string>
<string>
UIInterfaceOrientationLandscapeRight
</string>
</array>
</dict>
</plist>
iOS/WAStickersThirdParty/Interoperability.swift
deleted
100644 → 0
View file @
0c51d2e4
//
// Copyright (c) WhatsApp Inc. and its affiliates.
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
//
import
UIKit
struct
Interoperability
{
private
static
let
DefaultBundleIdentifier
:
String
=
"WA.WAStickersThirdParty"
private
static
let
PasteboardExpirationSeconds
:
TimeInterval
=
60
private
static
let
PasteboardStickerPackDataType
:
String
=
"net.whatsapp.third-party.sticker-pack"
private
static
let
WhatsAppURL
:
URL
=
URL
(
string
:
"whatsapp://stickerPack"
)
!
static
var
iOSAppStoreLink
:
String
?
static
var
AndroidStoreLink
:
String
?
static
func
canSend
()
->
Bool
{
return
UIApplication
.
shared
.
canOpenURL
(
URL
(
string
:
"whatsapp://"
)
!
)
}
static
func
send
(
json
:
[
String
:
Any
])
->
Bool
{
if
Bundle
.
main
.
bundleIdentifier
?
.
contains
(
DefaultBundleIdentifier
)
==
true
{
fatalError
(
"Your bundle identifier must not include the default one."
)
}
let
pasteboard
=
UIPasteboard
.
general
var
jsonWithAppStoreLink
:
[
String
:
Any
]
=
json
jsonWithAppStoreLink
[
"ios_app_store_link"
]
=
iOSAppStoreLink
jsonWithAppStoreLink
[
"android_play_store_link"
]
=
AndroidStoreLink
guard
let
dataToSend
=
try
?
JSONSerialization
.
data
(
withJSONObject
:
jsonWithAppStoreLink
,
options
:
[])
else
{
return
false
}
if
#available(iOS 10.0, *)
{
pasteboard
.
setItems
([[
PasteboardStickerPackDataType
:
dataToSend
]],
options
:
[
UIPasteboard
.
OptionsKey
.
localOnly
:
true
,
UIPasteboard
.
OptionsKey
.
expirationDate
:
NSDate
(
timeIntervalSinceNow
:
PasteboardExpirationSeconds
)])
}
else
{
pasteboard
.
setData
(
dataToSend
,
forPasteboardType
:
PasteboardStickerPackDataType
)
}
DispatchQueue
.
main
.
async
{
if
canSend
()
{
if
#available(iOS 10.0, *)
{
UIApplication
.
shared
.
open
(
WhatsAppURL
)
}
else
{
UIApplication
.
shared
.
openURL
(
WhatsAppURL
)
}
}
}
return
true
}
static
func
copyImageToPasteboard
(
image
:
UIImage
)
{
UIPasteboard
.
general
.
image
=
image
}
}
iOS/WAStickersThirdParty/Limits.swift
deleted
100644 → 0
View file @
0c51d2e4
//
// Copyright (c) WhatsApp Inc. and its affiliates.
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
//
import
UIKit
struct
Limits
{
static
let
MaxStaticStickerFileSize
:
Int
=
100
*
1024
static
let
MaxAnimatedStickerFileSize
:
Int
=
500
*
1024