Skip to content

Commit

Permalink
fix: 显示空白页时禁止ScrollView滑动
Browse files Browse the repository at this point in the history
  • Loading branch information
林翰 committed Apr 9, 2020
1 parent 9f5fc4e commit 7ef5d82
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 182 deletions.
2 changes: 1 addition & 1 deletion EmptyPage.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'EmptyPage'
s.version = '3.3.0'
s.version = '3.3.1'
s.summary = 'iOS - 轻量级空白页占位图框架...'

s.homepage = 'https://github.com/linhay/EmptyPage'
Expand Down
2 changes: 2 additions & 0 deletions Example/EmptyPage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-EmptyPage_Example/Pods-EmptyPage_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/EmptyPage/EmptyPage.framework",
"${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework",
"${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework",
"${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework",
"${BUILT_PRODUCTS_DIR}/Stem/Stem.framework",
Expand All @@ -380,6 +381,7 @@
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/EmptyPage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJRefresh.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVProgressHUD.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Stem.framework",
Expand Down
2 changes: 1 addition & 1 deletion Example/EmptyPage/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: MainViewController())
window?.rootViewController = UINavigationController(rootViewController: DemoCollectionViewController())
window?.makeKeyAndVisible()
return true
}
Expand Down
21 changes: 0 additions & 21 deletions Example/EmptyPage/DZNEmptyDataSet/DZIndexViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@ import EmptyPage
import SnapKit
import Stem

// MARK: - 初始化
extension UIImage{
/// 获取指定颜色的图片
///
/// - Parameters:
/// - color: UIColor
/// - size: 图片大小
convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
if size.width <= 0 || size.height <= 0 { return nil }
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0)
guard let context = UIGraphicsGetCurrentContext() else { return nil }
context.setFillColor(color.cgColor)
context.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
guard let cgImg = image?.cgImage else { return nil }
self.init(cgImage: cgImg)
}
}

/// from: https://github.com/dzenbot/DZNEmptyDataSet
class DZIndexViewController: UITableViewController {

Expand Down
96 changes: 46 additions & 50 deletions Example/EmptyPage/Demos/DemoCollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,70 @@
import UIKit
import EmptyPage
import SVProgressHUD
import MJRefresh
import Stem
import Stuart

private let reuseIdentifier = "Cell"
class DemoCollectionItemCell: SectionItemCell<Void>,STViewProtocol {

class DemoCollectionViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource {
override class func preferredSize(collectionView: UICollectionView, model: Void? = nil) -> CGSize {
return CGSize(width: collectionView.bounds.width, height: 44)
}

let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
}

var rows = 0
class DemoCollectionSection: SectionProtocol {
var index: Int = 0

unowned var collectionView: UICollectionView

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.addSubview(collectionView)
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: 100, height: 100)
layout.scrollDirection = .vertical
collectionView.backgroundColor = UIColor.gray
collectionView.frame = view.bounds
collectionView.delegate = self
collectionView.dataSource = self
collectionView.collectionViewLayout = layout
collectionView.ep.setFirstLoading(UIView())
collectionView.ep.setEmpty(EmptyStore.custom(block1: event1(), block2: event2()))
self.collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
getData()
}
var itemCount: Int = 3

func event1() -> (() -> ()) {
return { self.getData() }
init(collectionView: UICollectionView) {
self.collectionView = collectionView
collectionView.st.register(DemoCollectionItemCell.self)
}

func event2() -> (() -> ()) {
return {
self.rows = 2
self.collectionView.insertItems(at: [IndexPath(row: 0, section: 0),IndexPath(row: 1, section: 0)])
}
func itemSize(at index: Int) -> CGSize {
DemoCollectionItemCell.preferredSize(collectionView: collectionView)
}

func getData() {
SVProgressHUD.show()
rows = 0
sleep(3) {[weak self] in
guard let base = self else { return }
SVProgressHUD.dismiss()
base.collectionView.reloadData()
}
func itemCell(at indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.st.dequeueCell(indexPath) as DemoCollectionItemCell
cell.backgroundColor = UIColor.st.random
return cell
}


func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}

}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return rows
}
class DemoCollectionViewController: SectionController {

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath)
cell.backgroundColor = .blue
return cell
override func viewDidLoad() {
super.viewDidLoad()
sectionView.mj_header = MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(refresh))
sectionView.ep.setEmpty(EmptyStore.demo.standard(tapEvent: { [weak self] _ in
guard let self = self else {
return
}
self.refresh()
}))
refresh()
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
rows -= 1
collectionView.deleteItems(at: [indexPath])
@objc
func refresh() {
if sectionView.mj_header?.isRefreshing == false {
sectionView.mj_header?.beginRefreshing()
return
}
Gcd.delay(2) { [weak self] in
guard let self = self else {
return
}
self.manager.update(sections: self.manager.sections.isEmpty ? [DemoCollectionSection(collectionView: self.sectionView)] : [])
self.sectionView.mj_header?.endRefreshing()
}
}

}
40 changes: 39 additions & 1 deletion Example/EmptyPage/EmptyStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,46 @@

import UIKit
import EmptyPage

struct DZNEmptyDataSet {

}

struct DemoSet {

func standard(tapEvent: ((EmptyPageForStandard) -> Void)?) -> EmptyPageView {
return EmptyPageView.Template.standard
.change(hspace: .button, value: 30)
.change(vspace: .textWithButton, value: 10)
.change(vspace: .titleWithText, value: 10)
.config(button: { (item) in
item.layer.borderColor = UIColor("#2ca3fa").cgColor
item.layer.borderWidth = 1
item.layer.cornerRadius = 5
item.titleLabel?.font = UIFont.systemFont(ofSize: 14)
item.backgroundColor = .white
item.setTitleColor(UIColor("#2ca3fa"), for: .normal)
item.contentEdgeInsets = UIEdgeInsets(top: 8, left: 20, bottom: 8, right: 20)
})
.set(image: UIImage(named: "empty-1001")!)
.set(title: "Nobody is following",
color: UIColor("#536571"),
font: UIFont.boldSystemFont(ofSize: 18))
.set(text: "Following people helps you keep what they're saying and recommending.",
color: UIColor("#c3ccd1"))
.set(buttonTitle: "Find interesting people to follow >>")
.set(tap: tapEvent)
.mix()
.set(backgroundColor: UIColor.white)
}

}

class EmptyStore {


static let dzn = DZNEmptyDataSet()
static let demo = DemoSet()

class var loading: EmptyPageView{
return EmptyPageView.Template.image
.set(image: UIImage(named: "load-0"))
Expand Down
1 change: 1 addition & 0 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ target 'EmptyPage_Example' do
pod 'Stuart', :git => '[email protected]:linhay/Stuart.git', :branch => 'master'
pod 'Stem', :git => '[email protected]:linhay/Stem.git', :branch => 'develop'
pod 'SVProgressHUD'
pod 'MJRefresh'
pod 'SwiftLint'
end
8 changes: 6 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PODS:
- EmptyPage/Core (3.3.0)
- EmptyPage/Standard (3.3.0):
- EmptyPage/Core
- MJRefresh (3.3.1)
- SnapKit (5.0.0)
- Stem (0.0.31):
- Stem/AVKit (= 0.0.31)
Expand Down Expand Up @@ -174,6 +175,7 @@ PODS:

DEPENDENCIES:
- EmptyPage (from `../EmptyPage.podspec`)
- MJRefresh
- SnapKit (= 5.0.0)
- "Stem (from `[email protected]:linhay/Stem.git`, branch `develop`)"
- "Stuart (from `[email protected]:linhay/Stuart.git`, branch `master`)"
Expand All @@ -182,6 +184,7 @@ DEPENDENCIES:

SPEC REPOS:
trunk:
- MJRefresh
- SnapKit
- SVProgressHUD
- SwiftLint
Expand All @@ -201,17 +204,18 @@ CHECKOUT OPTIONS:
:commit: c7fa7ed8607342a7e6d91760e03ab29880552b30
:git: "[email protected]:linhay/Stem.git"
Stuart:
:commit: 4fe44369e7d99d644ad2eb04711c75ae8026028e
:commit: e43b576351fcd78423887448208d278342746ca1
:git: "[email protected]:linhay/Stuart.git"

SPEC CHECKSUMS:
EmptyPage: b85eb9d70cda567e418becd1677a41865904595b
MJRefresh: eeda70fbf0ad277f3178cef1cd0c3532591d6237
SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf
Stem: ea4aa174339e851a15619fd7d370cc3570667f6c
Stuart: b5fccbcb300fd684f248d371c7b36be7494a88b3
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftLint: 5553187048b900c91aa03552807681bb6b027846

PODFILE CHECKSUM: 002741590eaee6030d7a9e6ee37c8ae6caa87b12
PODFILE CHECKSUM: b80657be41226e1ebd399ce57699ca21ef6fed65

COCOAPODS: 1.9.0
8 changes: 6 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7ef5d82

Please sign in to comment.