FSPagerView icon indicating copy to clipboard operation
FSPagerView copied to clipboard

Easy to add rx extension

Open yangKJ opened this issue 2 years ago • 0 comments

你好,为了更方便使用,需要给您的库添加Rx扩展 由于FSPagerCollectionViewcollectionViewnumberOfItemsnumberOfSections等属性属于internal访问权限。 我不得不这样做,🥲

post_install do |installer|
  ## Fixed collectionView being internal
  find_and_replace("./Pods/FSPagerView/Sources/FSPagerCollectionView.swift", "class FSPagerCollectionView", "public class FSPagerCollectionView")
  find_and_replace("./Pods/FSPagerView/Sources/FSPagerCollectionView.swift", "override var scrollsToTop", "public override var scrollsToTop")
  find_and_replace("./Pods/FSPagerView/Sources/FSPagerCollectionView.swift", "override var contentInset", "public override var contentInset")
  
  find_and_replace("./Pods/FSPagerView/Sources/FSPagerView.swift", "internal weak var collectionView:", "public weak var collectionView:")
  find_and_replace("./Pods/FSPagerView/Sources/FSPagerView.swift", "internal var numberOfItems:", "public var numberOfItems:")
  find_and_replace("./Pods/FSPagerView/Sources/FSPagerView.swift", "internal var numberOfSections:", "public var numberOfSections:")
end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
    text = File.read(name)
    replace = text.gsub(findstr,replacestr)
    if text != replace
      puts "Fix: " + name
      File.open(name, "w") { |file| file.puts replace }
      STDOUT.flush
    end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

但是这样很麻烦,因此我这边帮你改好访问权限。 希望您看看;

谢谢🙏

yangKJ avatar Mar 04 '22 09:03 yangKJ