• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎉 RxSwift extensions and MVVM component project architecture.

Rickenbacker

Carthage compatible Releases Compatible CocoaPods Compatible Platform

👌. MVVM + RxSwift + Mediatror + MJRefresh + DZNEmptyDataSet + SkeletonView


English | 简体中文

This is a set of infrastructure based on MVVM + RxSwift

Features

At the moment, the most important features of Rickenbacker can be summarized as follows:

Adapter

This module is mainly to encapsulate the base class.

CatHome

Resource module, which mainly deals with image resource and text resource reading.

  • Read image resource:
R.image("base_black_back")
  • Read text resource:
R.text("base_empty_title")
  • Read color resource:
R.color("background")

BeeBox

Mainly collect RxSwift related useful method classes, etc.

Mediatror

  • This module mainly provides a design component intermediate layer.

  • There are two more representative schemes for designing the component middle layer:

    • Based on the URL registration jump method, refer to Mushroom Street Open Source MGJRouter
    • Mediator method based on Objective-C runtime, refer to CTMediator
  • Briefly talk about the advantages and differences between the two:

    • The way of URL registration is very cumbersome to use and often is not necessary. First of all, you need to register the URL in advance for each page jump, which will involve a lot of string hard coding.
    • Based on the runtime Mediator method, first of all, it does not need to register, which saves a lot of process of contrasting strings. Secondly, it is very easy to pass various parameters for inter-establishment communication.
  • Therefore, the final choice to provide the solution is also the Mediator method;

Test case:

if let vc = Mediator.Second_viewController(title: "biaoti") {
    pushButton.rx.tap
        .bind(to: rx.pushViewController(vc, animated: true))
        .disposed(by: disposeBag)
}
  • Componentized intermediate layer:
extension Mediator {
    static func Second_viewController(title: String) -> UIViewController? {
        self.perform(target: SecondTarget.self,
                     action: "setupSecondViewController",
                     module: "Rickenbacker_Example",
                     params: ["title": title])
    }
}

class SecondTarget: NSObject {
    /// Note prompt, `@objc` must be added here.
    @objc func setupSecondViewController(_ params: NSDictionary) -> UIViewController? {
        guard let title = params["title"] as? String else { return nil }
        let vm = SecondViewModel.init(title: title)
        let vc = SecondViewController.init(viewModel: vm)
        return vc
    }
}

HBDNavigationBar

This module is based on HBDNavigationBar secondary encapsulation of the underlying basic Navigation.

MJRefresh

This module is based on the refresh function of MJRefresh encapsulated UITableView.

  • Inject refresh function, you only need to simply implement the ViewModelHeaderable protocol.
  • Inject load more functions, just simply implement the ViewModelFooterable protocol.

Test case:

extension MJRefreshViewModel: ViewModelHeaderable, ViewModelFooterable {
    
    var enterBeginRefresh: Bool {
        return false
    }
    // Automatic non-sensing pull-up refresh function
    var footer: MJRefreshFooter {
        let footer = MJRefreshAutoFooter()
        footer.triggerAutomaticallyRefreshPercent = -5
        return footer
    }
}

Remarks: Of course, you can also customize header and footer according to your needs.

DZNEmptyDataSet

This module is based on the empty data display function of the DZNEmptyDataSet package UITableView.

  • To inject empty data display function, you only need to simply implement the ViewModelEmptiable protocol.

Test case:

class EmptyViewModel: ViewModel, ViewModelEmptiable, ViewModelHeaderable {
    
    let dataSource: BehaviorRelay<[String]> = BehaviorRelay(value: [])
    
    func loadData() {
        let driver = NetworkService().randomResult().asObservable()
        driver.bind(to: dataSource).disposed(by: disposeBag)
        driver.map { $0.isEmpty }.bind(to: isEmptyData).disposed(by: disposeBag)
        driver.subscribe { _ in } onCompleted: {
            self.refreshSubject.onNext(.endHeaderRefresh)
        }.disposed(by: disposeBag)
    }
}
  • Here also supports custom style design, only need to implement DZNEmptyDataSetSourceable or DZNEmptyDataSetDelegateable agreement, interfaces are directly to DZNEmptyDataSet do turning processing.

Test case:

// Configure empty data display information
extension DZNEmptyDataSetViewController: DZNEmptyDataSetable {
    
    func DZNEmptyDataSetImage(scrollView: UIScrollView) -> UIImage {
        return R.image("base_network_error_black")
    }
    
    func DZNEmptyDataSetImageTintColor(scrollView: UIScrollView) -> UIColor? {
        return UIColor.red
    }
    
    func DZNEmptyDataSetTitle(scrollView: UIScrollView) -> NSAttributedString? {
        NSAttributedString(string: R.text("TEXT"))
    }
    
    func DZNEmptyDataSetDescription(scrollView: UIScrollView) -> NSAttributedString? {
        NSAttributedString(string: R.text("测试网络异常展示"))
    }
    
    func DZNEmptyDataSetVerticalOffset(scrollView: UIScrollView) -> CGFloat {
        return -77
    }
}

CocoaPods

  • If you want use this framework.☠️
pod 'Rickenbacker'

Remarks

The general process is almost like this, the Demo is also written in great detail, you can check it out for yourself.🎷

RickenbackerDemo

Tip: If you find it helpful, please help me with a star. If you have any questions or needs, you can also issue.

Thanks.🎇

About the author


License

Rickenbacker is available under the MIT license. See the LICENSE file for more info.


More Repositories

1

KJCategories

Collection of native ios extensions and classes to boost development process. Such as UIKit, Foundation, QuartzCore, Accelerate, OpenCV, CoreGraphics, os and more. 超实用开发加速工具库
Objective-C
474
star
2

Harbeth

🎨 GPU accelerated image / video and camera filter library based on Metal. Support macOS & iOS. 图像、视频、相机滤镜框架
Metal
416
star
3

RxNetworks

🧚 MVP Network Api library. 插件版网络基础架构,支持响应式。
Swift
221
star
4

KJPlayerDemo

Audio and video player, breakpoint resuming playback, record played time, free watching limit, etc. 🎷多内核多功能播放器
Objective-C
188
star
5

KJNetworkPlugin

🎡A lightweight but powerful Network library. Network Plugin, Support batch and chain operation. 插件机制、上传、下载、批量、链式网络架构
Objective-C
65
star
6

Foggy

Automatic crash protection.自动防护异常崩溃 🌇
Objective-C
45
star
7

Opencv-ios

OpenCV image at iOS system. 🎨
Objective-C++
37
star
8

KJBannerViewDemo

轮播图无限自动循环滚动、缩放布局、缓存预加载读取、支持自定义继承,网络GIF和网图混合轮播,支持Storyboard和Xib中创建并配置属性,多种分页控件选择,自动清理缓存等等
Objective-C
27
star
9

ImageX

👓 GIFs and images displayed. 动态图像滤镜播放图像框架。
Swift
26
star
10

Kakapos

🌀 High-performance and flexible video edit and export framework.
Shell
23
star
11

PT

Automatically generate componentized modules 自动生成组件化模块
Ruby
20
star
12

StudyDatas

整理平时的学习资料源码大礼包 🥁..
Objective-C++
20
star
13

Moonlit

播放器,支持边下边播边缓存的播放器方案,支持免费试看、跳过片头片尾、记忆观看记录、画中画播放等等
Swift
12
star
14

KJEmitterView

OC开发分类加速库,你想要的这都有!!!!
Objective-C
11
star
15

CacheX

📦 Mixed cached storage warehouse with disk and memory. Support OC and Swift.
Swift
8
star
16

Color

🎨. Pixel color extension with Swift and SwiftUI.
Swift
8
star
17

iDay

🫥 Metal Daily Share And Shell Script. 每日分享
Shell
8
star
18

gcd

Objective-C
7
star
19

WebDiscernDemo

长按识别网页图片工具
Objective-C
6
star
20

MajiaDemos

MajiaDemos.
Objective-C
5
star
21

PunchCardDemo

打卡管理器
Swift
5
star
22

MPlanet

♻️MVVM + RxSwift 搭建组件化宿主项目架构
4
star
23

blockchain

区块链钱包相关,支持生成助记词、私钥、公钥、地址等🧸
C
4
star
24

KJXIBAdaptiveDemo

xib适配工具
Objective-C
3
star
25

RxPagerView

FSPagerView appending RxSwift extension.
Swift
3
star
26

KJScanDemo

一款项目提炼出来的扫描二维码工具
Objective-C
2
star
27

RxSkeletonView

RxSkeletonView
Swift
2
star
28

KJNetWorkingDemo

一款基于AFNetWorking和YYCache二次封装网络请求工具 其中包含加密和解密 按App版本缓存数据等等
Objective-C
2
star
29

Boxes

Collect macos extensions.
Swift
2
star
30

KJWorkboxDemo

本地消息推送工具、APNs推送工具 自带缓存机制网络图片下载工具 快速识别网页当中的图片 跳转处理工具 加密解密工具 谓词工具等等
Objective-C
1
star
31

Heyuan

12-26 10:09 最新和源版本
Objective-C
1
star
32

KJPredicateDemo

利用谓词写的一套工具
Objective-C
1
star
33

KJJumpControllerDemo

一款万能控制器跳转工具
Objective-C
1
star
34

Cryptograph

This is blockchain cryptograph library. 区块链密钥相关库
Swift
1
star
35

FFmpeg-ios

FFmpeg static libraries compiled for iOS.
1
star
36

YangKJ

1
star
37

KJBaseHandler

Base
Objective-C
1
star
38

KJMoreTargetDemo

同工程里面创建两个Target,然后通过判断Target来修改代码,这样都是基于同一套代码做修改,只是部分不相同的地方通过Target来添加不同代码,后期修改维护成本低
Objective-C
1
star
39

KJExtensionHandler

持续更新中,Category各种工具集合,Button图文混排、点击事件封装、View圆角渐变、Xib属性、TextView输入框扩展、限制字数、撤销,富文本,多语言,加密解密,数组算法,字符串加减乘除幂运算等等等
Objective-C
1
star