TSCollectionViewVM+Config.swift 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. //
  2. // TSCollectionViewVM+Ex.swift
  3. // AIRingtone
  4. //
  5. // Created by 100Years on 2025/2/28.
  6. //
  7. struct TSColVVMSizeConfig {
  8. var sectionInset: UIEdgeInsets
  9. var lineSpacing: CGFloat
  10. var itemSpacing: CGFloat
  11. var originalSize:CGSize
  12. //一行几个cell
  13. var cellRowNum:Int
  14. var cellSize:CGSize
  15. var cellClass: UICollectionViewCell.Type
  16. var headerViewSize:CGSize
  17. var headerView:UICollectionReusableView.Type
  18. var footerViewSize:CGSize
  19. var footerView:UICollectionReusableView.Type
  20. }
  21. //MARK: 主题引导
  22. let themeGuideConfig:TSColVVMSizeConfig = {
  23. let sectionInset = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
  24. let lineSpacing = 0.0
  25. let itemSpacing = 0.0
  26. let originalSize = CGSizeMake(343, 109)
  27. let cellRowNum = 1
  28. let originalScale = originalSize.width/originalSize.height
  29. var w = k_ScreenWidth-sectionInset.left-sectionInset.right
  30. w = w - lineSpacing * CGFloat((cellRowNum-1))
  31. w = w/CGFloat(cellRowNum)
  32. let h = w/originalScale
  33. let cellSize = CGSizeMake(w, h)
  34. let cellClass = TSThemeBannerCell.self
  35. let headerViewSize = CGSize.zero
  36. let headerView = TSColVVMSectionHeaderView.self
  37. let footerViewSize = CGSizeMake(k_ScreenWidth, 60)
  38. let footerView = UICollectionReusableView.self
  39. var config = TSColVVMSizeConfig(
  40. sectionInset: sectionInset,
  41. lineSpacing: lineSpacing,
  42. itemSpacing: itemSpacing,
  43. originalSize: originalSize,
  44. cellRowNum: cellRowNum,
  45. cellSize: cellSize,
  46. cellClass: cellClass,
  47. headerViewSize: headerViewSize,
  48. headerView: headerView,
  49. footerViewSize: footerViewSize,
  50. footerView: footerView
  51. )
  52. return config
  53. }()
  54. //MARK: 主题内容
  55. let themeContentConfig:TSColVVMSizeConfig = {
  56. let sectionInset = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
  57. let lineSpacing = 16.0
  58. let itemSpacing = 16.0
  59. let originalSize = CGSizeMake(163.0, 353.0)
  60. let cellRowNum = 2
  61. let originalScale = originalSize.width/originalSize.height
  62. var w = k_ScreenWidth-sectionInset.left-sectionInset.right
  63. w = w - lineSpacing * CGFloat((cellRowNum-1))
  64. w = w/CGFloat(cellRowNum)
  65. let h = w/originalScale
  66. let cellSize = CGSizeMake(w, h)
  67. let cellClass = TSThemeContentCell.self
  68. let headerViewSize = CGSizeMake(k_ScreenWidth, 0)
  69. let headerView = TSColVVMSectionHeaderView.self
  70. let footerViewSize = CGSizeMake(k_ScreenWidth, 0)
  71. let footerView = UICollectionReusableView.self
  72. var config = TSColVVMSizeConfig(
  73. sectionInset: sectionInset,
  74. lineSpacing: lineSpacing,
  75. itemSpacing: itemSpacing,
  76. originalSize: originalSize,
  77. cellRowNum: cellRowNum,
  78. cellSize: cellSize,
  79. cellClass: cellClass,
  80. headerViewSize: headerViewSize,
  81. headerView: headerView,
  82. footerViewSize: footerViewSize,
  83. footerView: footerView
  84. )
  85. return config
  86. }()
  87. //MARK: 海报内容
  88. let posterHistoryConfig:TSColVVMSizeConfig = {
  89. let sectionInset = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
  90. let lineSpacing = 8.0
  91. let itemSpacing = 8.0
  92. let originalSize = CGSizeMake(109.0, 194.0)
  93. let cellRowNum = 3
  94. let originalScale = originalSize.width/originalSize.height
  95. var w = k_ScreenWidth-sectionInset.left-sectionInset.right
  96. w = w - lineSpacing * CGFloat((cellRowNum-1))
  97. w = w/CGFloat(cellRowNum)
  98. let h = w/originalScale
  99. let cellSize = CGSizeMake(w, h)
  100. let cellClass = TSAIPhotoImageCell.self
  101. let headerViewSize = CGSizeMake(k_ScreenWidth, 0)
  102. let headerView = TSColVVMSectionHeaderView.self
  103. let footerViewSize = CGSizeMake(k_ScreenWidth, 0)
  104. let footerView = UICollectionReusableView.self
  105. var config = TSColVVMSizeConfig(
  106. sectionInset: sectionInset,
  107. lineSpacing: lineSpacing,
  108. itemSpacing: itemSpacing,
  109. originalSize: originalSize,
  110. cellRowNum: cellRowNum,
  111. cellSize: cellSize,
  112. cellClass: cellClass,
  113. headerViewSize: headerViewSize,
  114. headerView: headerView,
  115. footerViewSize: footerViewSize,
  116. footerView: footerView
  117. )
  118. return config
  119. }()
  120. //MARK: 头像内容
  121. let photoHistoryConfig:TSColVVMSizeConfig = {
  122. let sectionInset = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
  123. let lineSpacing = 8.0
  124. let itemSpacing = 8.0
  125. let originalSize = CGSizeMake(109.0, 109.0)
  126. let cellRowNum = 3
  127. let originalScale = originalSize.width/originalSize.height
  128. var w = k_ScreenWidth-sectionInset.left-sectionInset.right
  129. w = w - lineSpacing * CGFloat((cellRowNum-1))
  130. w = w/CGFloat(cellRowNum)
  131. let h = w/originalScale
  132. let cellSize = CGSizeMake(w, h)
  133. let cellClass = TSAIPhotoImageCell.self
  134. let headerViewSize = CGSizeMake(k_ScreenWidth, 0)
  135. let headerView = TSColVVMSectionHeaderView.self
  136. let footerViewSize = CGSizeMake(k_ScreenWidth, 0)
  137. let footerView = UICollectionReusableView.self
  138. var config = TSColVVMSizeConfig(
  139. sectionInset: sectionInset,
  140. lineSpacing: lineSpacing,
  141. itemSpacing: itemSpacing,
  142. originalSize: originalSize,
  143. cellRowNum: cellRowNum,
  144. cellSize: cellSize,
  145. cellClass: cellClass,
  146. headerViewSize: headerViewSize,
  147. headerView: headerView,
  148. footerViewSize: footerViewSize,
  149. footerView: footerView
  150. )
  151. return config
  152. }()
  153. //MARK: ring Categories 分类配置
  154. let ringCategoriesConfig:TSColVVMSizeConfig = {
  155. let sectionInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
  156. let lineSpacing = 16.0
  157. let itemSpacing = 16.0
  158. let originalSize = CGSizeMake(104.0, 104.0)
  159. let cellRowNum = 3
  160. let originalScale = originalSize.width/originalSize.height
  161. var w = k_ScreenWidth-sectionInset.left-sectionInset.right
  162. w = w - lineSpacing * CGFloat((cellRowNum-1))
  163. w = w/CGFloat(cellRowNum)
  164. let h = w/originalScale
  165. let cellSize = CGSizeMake(w, h)
  166. let cellClass = TSDiscoverCell.self
  167. let headerViewSize = CGSizeMake(k_ScreenWidth, 0)
  168. let headerView = TSColVVMSectionHeaderView.self
  169. let footerViewSize = CGSizeMake(k_ScreenWidth, 0)
  170. let footerView = UICollectionReusableView.self
  171. var config = TSColVVMSizeConfig(
  172. sectionInset: sectionInset,
  173. lineSpacing: lineSpacing,
  174. itemSpacing: itemSpacing,
  175. originalSize: originalSize,
  176. cellRowNum: cellRowNum,
  177. cellSize: cellSize,
  178. cellClass: cellClass,
  179. headerViewSize: headerViewSize,
  180. headerView: headerView,
  181. footerViewSize: footerViewSize,
  182. footerView: footerView
  183. )
  184. return config
  185. }()
  186. //MARK: ring list 配置
  187. let ringListConfig:TSColVVMSizeConfig = {
  188. let sectionInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
  189. let lineSpacing = 13.0
  190. let itemSpacing = 13.0
  191. let originalSize = CGSizeMake(343.0, 72)
  192. let cellRowNum = 1
  193. let originalScale = originalSize.width/originalSize.height
  194. var w = k_ScreenWidth-sectionInset.left-sectionInset.right
  195. w = w - lineSpacing * CGFloat((cellRowNum-1))
  196. w = w/CGFloat(cellRowNum)
  197. let h = w/originalScale
  198. let cellSize = CGSizeMake(w, h)
  199. let cellClass = TSAIRintoneHistoryCell.self // TSDiscoverListCell.self
  200. let headerViewSize = CGSizeMake(k_ScreenWidth, 0)
  201. let headerView = TSColVVMSectionHeaderView.self
  202. let footerViewSize = CGSizeMake(k_ScreenWidth, 0)
  203. let footerView = UICollectionReusableView.self
  204. var config = TSColVVMSizeConfig(
  205. sectionInset: sectionInset,
  206. lineSpacing: lineSpacing,
  207. itemSpacing: itemSpacing,
  208. originalSize: originalSize,
  209. cellRowNum: cellRowNum,
  210. cellSize: cellSize,
  211. cellClass: cellClass,
  212. headerViewSize: headerViewSize,
  213. headerView: headerView,
  214. footerViewSize: footerViewSize,
  215. footerView: footerView
  216. )
  217. return config
  218. }()