Unverified Commit ae201326 authored by vamsigoru's avatar vamsigoru Committed by GitHub
Browse files

Delete iOS directory

parent 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 AllStickerPacksViewController: UIViewController {
@IBOutlet private weak var stickerPacksTableView: UITableView!
private var needsFetchStickerPacks = true
private var stickerPacks: [StickerPack] = []
private var selectedIndex: IndexPath?
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 11.0, *) {
navigationItem.largeTitleDisplayMode = .automatic
}
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.alpha = 0.0
stickerPacksTableView.register(UINib(nibName: "StickerPackTableViewCell", bundle: nil), forCellReuseIdentifier: "StickerPackCell")
stickerPacksTableView.tableFooterView = UIView()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let selectedIndex = selectedIndex {
stickerPacksTableView.deselectRow(at: selectedIndex, animated: true)
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if needsFetchStickerPacks {
let alert: UIAlertController = UIAlertController(title: "Don't ship this sample app!", message: "If you want to ship your sticker packs to the App Store, create your own app with its own user interface. Your app must have minimum to no resemblance to this sample app.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: { action in
self.needsFetchStickerPacks = false
self.fetchStickerPacks()
}))
present(alert, animated: true)
}
}
private func fetchStickerPacks() {
let loadingAlert = UIAlertController(title: "Loading sticker packs", message: "\n\n", preferredStyle: .alert)
loadingAlert.addSpinner()
present(loadingAlert, animated: true)
do {
try StickerPackManager.fetchStickerPacks(fromJSON: StickerPackManager.stickersJSON(contentsOfFile: "sticker_packs")) { stickerPacks in
loadingAlert.dismiss(animated: false) {
self.navigationController?.navigationBar.alpha = 1.0
if stickerPacks.count > 1 {
self.stickerPacks = stickerPacks
self.stickerPacksTableView.reloadData()
} else {
self.show(stickerPack: stickerPacks[0], animated: false)
}
}
}
} catch StickerPackError.fileNotFound {
fatalError("sticker_packs.wasticker not found.")
} catch {
fatalError(error.localizedDescription)
}
}
private func show(stickerPack: StickerPack, animated: Bool) {
// "stickerPackNotAnimated" still animates the push transition on iOS 8 and earlier.
let identifier = animated ? "stickerPackAnimated" : "stickerPackNotAnimated"
performSegue(withIdentifier: identifier, sender: stickerPack)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let vc = segue.destination as? StickerPackViewController,
let stickerPack = sender as? StickerPack {
vc.title = stickerPack.name
vc.stickerPack = stickerPack
vc.navigationItem.hidesBackButton = stickerPacks.count <= 1
}
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if let navigationBar = navigationController?.navigationBar {
let contentInset: UIEdgeInsets = {
if #available(iOS 11.0, *) {
return scrollView.adjustedContentInset
} else {
return scrollView.contentInset
}
}()
if scrollView.contentOffset.y <= -contentInset.top {
navigationBar.shadowImage = UIImage()
} else {
navigationBar.shadowImage = nil
}
}
}
@objc func addButtonTapped(button: UIButton) {
let loadingAlert: UIAlertController = UIAlertController(title: "Sending to WhatsApp", message: "\n\n", preferredStyle: .alert)
loadingAlert.addSpinner()
present(loadingAlert, animated: true)
stickerPacks[button.tag].sendToWhatsApp { completed in
loadingAlert.dismiss(animated: true)
}
}
}
// MARK: - UITableViewDelegate
extension AllStickerPacksViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
selectedIndex = indexPath
show(stickerPack: stickerPacks[indexPath.row], animated: true)
}
}
// MARK: - UITableViewDataSource
extension AllStickerPacksViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return stickerPacks.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell: StickerPackTableViewCell = tableView.dequeueReusableCell(withIdentifier: "StickerPackCell") as? StickerPackTableViewCell else { return UITableViewCell() }
cell.stickerPack = stickerPacks[indexPath.row]
let addButton = UIButton(type: .contactAdd)
addButton.tag = indexPath.row
addButton.isEnabled = Interoperability.canSend()
addButton.addTarget(self, action: #selector(addButtonTapped(button:)), for: .touchUpInside)
cell.accessoryView = addButton
return cell
}
}
//
// 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
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 13.0, *) {
window?.overrideUserInterfaceStyle = .light
}
// Override point for customization after application launch.
return true
}
}
//
// 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 RoundedButton: UIButton {
override init(frame: CGRect) {
super.init(frame: frame)
adjustsImageWhenHighlighted = false
layer.masksToBounds = true
layer.cornerRadius = 10.0
titleLabel?.font = .boldSystemFont(ofSize: titleLabel!.font.pointSize)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class AquaButton: RoundedButton {
override var isHighlighted: Bool {
get {
return super.isHighlighted
}
set (newHighlighted) {
super.isHighlighted = newHighlighted
imageView?.tintColor = newHighlighted ? UIColor.white.withAlphaComponent(0.5) : .white
}
}
override var isEnabled: Bool {
didSet{
if isEnabled {
imageView!.tintColor = .white
} else {
imageView!.tintColor = .lightGray
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
adjustsImageWhenHighlighted = false
backgroundColor = UIColor(red: 0.0, green: 0.5, blue: 1.0, alpha: 1.0)
imageView!.tintColor = .white
setTitleColor(UIColor.white.withAlphaComponent(0.5), for: .highlighted)
setTitleColor(UIColor.lightGray.withAlphaComponent(1.0), for: .disabled)
imageEdgeInsets.left = -25
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class GrayRoundedButton: RoundedButton {
private let aquaColor: UIColor = UIColor(red: 0.0, green: 0.5, blue: 1.0, alpha: 1.0)
override var isHighlighted: Bool {
get {
return super.isHighlighted
}
set (newHighlighted) {
super.isHighlighted = newHighlighted
imageView?.tintColor = newHighlighted ? aquaColor.withAlphaComponent(0.5) : aquaColor
}
}
override var isEnabled: Bool {
didSet{
if isEnabled {
tintColor = UIColor.white
} else {
tintColor = UIColor.gray
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
adjustsImageWhenHighlighted = false
backgroundColor = UIColor(red: 0.973, green: 0.969, blue: 0.988, alpha: 1.0)
layer.borderColor = UIColor.black.withAlphaComponent(0.1).cgColor
layer.borderWidth = 1.0
imageView!.tintColor = aquaColor
setTitleColor(aquaColor, for: .normal)
setTitleColor(aquaColor.withAlphaComponent(0.5), for: .highlighted)
imageEdgeInsets.left = -25
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Cuppy_120.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Cuppy_180.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Cuppy_1024.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Share@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Share@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment