JCCEmoticonGroup.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // JCCEmoticonGroup.swift
  3. // JChat
  4. //
  5. // Created by deng on 2017/3/9.
  6. // Copyright © 2017年 HXHG. All rights reserved.
  7. //
  8. import UIKit
  9. class JCCEmoticonGroup: JCEmoticonGroup {
  10. init?(contentsOfFile: String) {
  11. guard let dic = NSDictionary(contentsOfFile: contentsOfFile), let arr = dic["emoticons"] as? NSArray else {
  12. return nil
  13. }
  14. let directory = URL(fileURLWithPath: contentsOfFile).deletingLastPathComponent().path
  15. super.init()
  16. type = JCEmoticonType(rawValue: dic["type"] as? Int ?? 0) ?? .small
  17. rows = dic["rows"] as? Int ?? 3
  18. columns = dic["columns"] as? Int ?? 7
  19. rowsInLandscape = dic["rowsInLandscape"] as? Int ?? 2
  20. columnsInLandscape = dic["columnsInLandscape"] as? Int ?? 13
  21. if let img = dic["image"] as? String {
  22. thumbnail = UIImage(contentsOfFile: "\(directory)/\(img)")
  23. }
  24. if type.isSmall {
  25. emoticons = JCCEmoticon.emoticons(with: arr, at: directory)
  26. } else {
  27. emoticons = JCCEmoticonLarge.emoticons(with: arr, at: directory)
  28. }
  29. }
  30. convenience init?(identifier : String) {
  31. let bundle = Bundle.main
  32. guard let path = bundle.path(forResource: "emoticons.bundle/\(identifier)/Info", ofType: "plist") else {
  33. return nil
  34. }
  35. self.init(contentsOfFile: path)
  36. }
  37. open var rows: Int = 3
  38. open var columns: Int = 7
  39. open var rowsInLandscape: Int = 3
  40. open var columnsInLandscape: Int = 13
  41. }