PublishNewAlbumTableView.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // PublishNewAlbumTableView.swift
  3. // RainbowPlanet
  4. //
  5. // Created by 南鑫林 on 2019/11/19.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. //
  8. import UIKit
  9. import RxSwift
  10. class PublishNewAlbumTableView: UIView {
  11. let disposeBag = DisposeBag()
  12. /// 配置
  13. var configure : NXLPhotoPickerConfigure?
  14. /// 媒体资源
  15. lazy var photoLibrary: NXLPhotoLibrary = {
  16. let photoLibrary = NXLPhotoLibrary()
  17. photoLibrary.delegate = self
  18. return photoLibrary
  19. }()
  20. /// 资源
  21. lazy var collections: Array<NXLAssetsCollection> = {
  22. let collections = Array<NXLAssetsCollection>()
  23. return collections
  24. }()
  25. override init(frame: CGRect) {
  26. super.init(frame: frame)
  27. }
  28. required init?(coder aDecoder: NSCoder) {
  29. fatalError("init(coder:) has not been implemented")
  30. }
  31. init(configure:NXLPhotoPickerConfigure? = nil) {
  32. self.init()
  33. self.configure = configure
  34. self.setupViews()
  35. self.setupLayouts()
  36. self.setupData()
  37. }
  38. func setupViews() {
  39. backgroundColor = UIColor.white
  40. }
  41. func setupLayouts() {
  42. }
  43. func setupData() {
  44. if NXLPermission.isAllowed(NXLPermissionType.photoLibrary) {
  45. guard let configure = self.configure else { return }
  46. photoLibrary.fetchCollection(configure: configure)
  47. }
  48. }
  49. lazy var tableView: UITableView = {
  50. let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
  51. tableView.separatorStyle = .none
  52. tableView.backgroundColor = UIColor.clear
  53. // tableView.dataSource = self
  54. // tableView.delegate = self
  55. tableView.rowHeight = 80
  56. return tableView
  57. }()
  58. }
  59. extension PublishNewAlbumTableView : NXLPhotoLibraryDelegate {
  60. /// 加载相机collection
  61. func loadCameraRollCollection(collection: NXLAssetsCollection) {
  62. self.collections = [collection]
  63. }
  64. /// 加载所有collections
  65. func loadCompleteAllCollection(collections: [NXLAssetsCollection]) {
  66. self.collections = collections
  67. }
  68. }
  69. //extension PublishNewAlbumTableView : UITableViewDataSource {
  70. // func numberOfSections(in tableView: UITableView) -> Int {
  71. // return 1
  72. // }
  73. //
  74. // func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  75. // return self.collections.count
  76. // }
  77. //
  78. // func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  79. //
  80. // }
  81. //}
  82. //
  83. //extension PublishNewAlbumTableView : UITableViewDelegate {
  84. //
  85. //}