Viper 1.2.2

Viper 1.2.2

测试测试版
语言语言 SwiftSwift
许可证 MIT
发布上次发布2021年6月
SPM支持SPM

incetro维护。



Viper 1.2.2

  • incetro

Viper是用Swift编写的框架,可以让您更方便、更容易地构建VIPER架构

组件

  • [x] TransitionHandler
  • [x] ViewInput
  • [x] AssembliesCollector
  • [x] InteractorOutput - 为Presenters提供的辅助协议
  • [x] ContentManager - 为ContentManagers提供的辅助协议
  • [x] ModuleInput协议
  • [x] ModuleOutput协议

用法

TransitionHandler

此组件使VIPER模块之间的转换变得简单

使用工厂打开其他模块

/// With 'present' option

transitionHandler?.openModule(usingFactory: factory, type: SecondModuleInput.self)
                  
   .to(preferred: TransitionStyle.present)
                  
   .then { moduleInput in
    
    moduleInput.setData(data)
}

/// Or with 'navigationController' options

transitionHandler?.openModule(usingFactory: factory, type: SecondModuleInput.self)
                  
   .to(preferred: TransitionStyle.navigationController(navigationStyle: .push))
                  
   .then { moduleInput in
    
    moduleInput.setData(data)
}

使用segue标识符打开其他模块

transitionHandler?.performSegue(segueIdentifier)

/// Or with setup block

transitionHandler?.openModuleUsingSegue(with: segueIdentifier, to: SecondModuleInput.self) { moduleInput in
    
    moduleInput.setData(data)
}

关闭您的模块

transitionHandler?.closeCurrentModule(true)

ViewInput

此组件可以帮助您显示View的不同状态

/// Start showing progress
view?.startIndication()

/// Stop progress
view?.stopIndication()

/// Show unknown error's message
view?.showError()

/// Show success view
view?.showSuccess()

/// Show the given message
view?.showMessage("Message")

/// Show the given error message
view?.showErrorMessage("Error message")

AssembliesCollector

此组件简化了与组件的工作

class YourModuleAssembly: CollectableAssembly {

    required init() {

    }
    
    /// Register your dependencies through Swinject.
    /// You may not call this method because 
    /// AssembliesCollector automatically call it :)
    
    func assemble(in container: Container) {
    
    }
}

其他协议

如何使用InteractorOutput、ContentManager、ModuleInput、ModuleOutput?请看示例 ;)

需求

  • iOS 8.0+
  • Xcode 8.1, 8.2, 8.3和9.0
  • Swift 3.0, 3.1, 3.2和4.0

沟通

  • 如果您发现了错误,请提交问题。
  • 如果您有功能请求,请提交问题。
  • 如果您想贡献,请提交拉取请求。

安装

手动

如果您不希望使用任何依赖关系管理器,您可以手动将 Viper 整合到您的项目中。

嵌入式框架

  • 打开终端,cd 到您顶级项目目录,并运行以下命令(如果您的项目不是作为 git 仓库初始化)

    $ git init
  • 通过以下命令将 Viper 作为 git 子模块 添加

    $ git submodule add https://github.com/incetro/Viper.git
  • 打开新的 Viper 文件夹,并将 Viper.xcodeproj 拖动到您的应用程序 Xcode 项目的项目导航器中。

    它应该位于您应用程序图标下蓝色项目图标的下方。无论是在所有其他 Xcode 组之上还是之下,并无关系。

  • 在项目导航器中选择 Viper.xcodeproj,并验证部署目标与应用程序目标相匹配。

  • 然后,在项目导航器(蓝色项目图标)中选择您的应用程序项目,导航到目标配置窗口,并在侧边栏的“目标”标题下选择应用程序目标。

  • 在窗口顶部的标签栏中,打开“通用”面板。

  • 在“嵌入式二进制文件”部分下点击 + 按钮。

  • 您将看到两个不同的 Viper.xcodeproj 文件夹,每个文件夹内都有一个位于“Products”文件夹中的两个不同版本的 Viper.framework

    您可以选择“Products”文件夹中的任何一个,但必须选择顶部或底部的 Viper.framework

  • 选择顶部的 Viper.framework 用于 iOS,底部的用于 OS X。

  • 就是这样!

    Viper.framework 将自动添加为目标依赖关系、链接框架和嵌入框架,在复制文件构建阶段完成所有这些操作即可在模拟器和设备上构建。

作者

incetro,[email protected]。灵感来源于 ViperMcFlurry

许可

VIPER 提供在 MIT 许可之下。有关更多信息,请参阅 LICENSE 文件。