Skip to content

Commit

Permalink
update adjust xib load from class bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminlinux committed May 4, 2017
1 parent 6c532a4 commit 90a60e1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
6 changes: 5 additions & 1 deletion iOS/IMUI/Views/IMUIInputView/Controllers/IMUIInputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ open class IMUIInputView: UIView {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

view = Bundle.main.loadNibNamed("IMUIInputView", owner: self, options: nil)?[0] as! UIView
// view = Bundle.main.loadNibNamed("IMUIInputView", owner: self, options: nil)?[0] as! UIView

let bundle = Bundle(for: IMUIInputView.self)
view = bundle.loadNibNamed("IMUIInputView", owner: self, options: nil)?.first as! UIView

self.addSubview(view)
view.frame = self.bounds

Expand Down
26 changes: 15 additions & 11 deletions iOS/IMUI/Views/IMUIInputView/Views/IMUIFeatureView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Photos

private var CellIdentifier = ""

enum IMUIFeatureType {
public enum IMUIFeatureType {
case voice
case gallery
case camera
Expand All @@ -37,13 +37,13 @@ extension IMUIFeatureViewDelegate {
func didChangeSelectedGallery() {}
}

protocol IMUIFeatureCellProtocal {
public protocol IMUIFeatureCellProtocal {
var inputViewDelegate: IMUIInputViewDelegate? { set get }
func activateMedia()
func inactivateMedia()
}

extension IMUIFeatureCellProtocal {
public extension IMUIFeatureCellProtocal {
var inputViewDelegate: IMUIInputViewDelegate? {

get { return nil }
Expand All @@ -55,7 +55,7 @@ extension IMUIFeatureCellProtocal {
}

// TODO: Need to Restructure
class IMUIFeatureView: UIView {
open class IMUIFeatureView: UIView {

@IBOutlet weak var featureCollectionView: UICollectionView!
var view: UIView!
Expand All @@ -69,9 +69,13 @@ class IMUIFeatureView: UIView {
self.setupAllViews()
}

required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
view = Bundle.main.loadNibNamed("IMUIFeatureView", owner: self, options: nil)?[0] as! UIView
// view = Bundle.main.loadNibNamed("IMUIFeatureView", owner: self, options: nil)?[0] as! UIView

let bundle = Bundle(for: IMUIFeatureView.self)
view = bundle.loadNibNamed("IMUIFeatureView", owner: self, options: nil)?.first as! UIView

self.addSubview(view)
view.frame = self.bounds
}
Expand Down Expand Up @@ -142,7 +146,7 @@ class IMUIFeatureView: UIView {

// MARK: - UICollectionViewDelegate, UICollectionViewDataSource
extension IMUIFeatureView: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
switch currentType {
case .gallery:
return IMUIGalleryDataManager.allAssets.count
Expand All @@ -153,7 +157,7 @@ extension IMUIFeatureView: UICollectionViewDelegate, UICollectionViewDataSource
}
}

func numberOfSections(in collectionView: UICollectionView) -> Int {
public func numberOfSections(in collectionView: UICollectionView) -> Int {
collectionView.collectionViewLayout.invalidateLayout()
return 1
}
Expand All @@ -176,7 +180,7 @@ extension IMUIFeatureView: UICollectionViewDelegate, UICollectionViewDataSource
return CGSize.zero
}

func collectionView(_ collectionView: UICollectionView,
public func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

switch currentType {
Expand All @@ -201,7 +205,7 @@ extension IMUIFeatureView: UICollectionViewDelegate, UICollectionViewDataSource
return cell as! UICollectionViewCell
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = collectionView.cellForItem(at: indexPath)!
if cell is IMUIGalleryCell {
let galleryCell = cell as! IMUIGalleryCell
Expand All @@ -210,7 +214,7 @@ extension IMUIFeatureView: UICollectionViewDelegate, UICollectionViewDataSource
}
}

func collectionView(_ collectionView: UICollectionView, didEndDisplaying: UICollectionViewCell, forItemAt: IndexPath) {
public func collectionView(_ collectionView: UICollectionView, didEndDisplaying: UICollectionViewCell, forItemAt: IndexPath) {
let endDisplayingCell = didEndDisplaying as! IMUIFeatureCellProtocal
endDisplayingCell.inactivateMedia()
}
Expand Down
4 changes: 3 additions & 1 deletion iOS/IMUI/Views/IMUIMessageCollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ open class IMUIMessageCollectionView: UIView {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

view = Bundle.main.loadNibNamed("IMUIMessageCollectionView", owner: self, options: nil)?[0] as! UIView
let bundle = Bundle(for: IMUIMessageCollectionView.self)
view = bundle.loadNibNamed("IMUIMessageCollectionView", owner: self, options: nil)?.first as! UIView

self.addSubview(view)
view.frame = self.bounds
self.chatDataManager = IMUIChatDataManager()
Expand Down

0 comments on commit 90a60e1

Please sign in to comment.