Infrared 0.9.2.4

Infrared 0.9.2.4

测试已测试
Lang语言 Obj-CObjective C
许可 Apache 2
发布最后发布2016 年 8 月

Uros Infrared 维护。



 
依赖
ReactiveCocoa= 2.1.8
RESideMenu~> 4.0.7
IQKeyboardManager>= 0
MBProgressHUD~> 0.9.1
SSKeychain>= 0
 

Infrared 0.9.2.4

  • 作者
  • Uros

Infrared

介绍

Infrared 是一个用于 iOS 开发的库,它允许控制应用的 UI、交互和资源。
这是如何实现的

  • UI
    而不是在 ObjC 代码和 Storyboard 中定义它,Infrared 使用 JSON 描述文件
  • 交互
    在 JavaScript 中处理用户的交互
    (交互也可以在 ObjC 中处理)
  • 资源
    应用使用的所有资源都可以随时更新。这包括本地化、图像、文件、字体等。

JSON UI 示例

标签组件

{
  "id" : "label_id",
  "type" : "label",
  "backgroundColor" : "#ff000080",
  "text" : "IR Label",
  "textAlignment" : "NSTextAlignmentCenter",
  "textColor" : "#ffffffaa",
  "font" : "SystemBold, 16"
}

JavaScript 示例

IR.controller({
    "data" : {
        "text_1" : 'value 1',
        "text_2" : 'value 2',
        "color"  : '#ffffff'
    },
    "actionMethod" : function () {
        // do some UI/Interaction/Data manipulation
    }
});

应用结构

Infrared 账户应用的入口点是 App.json,其中列出用于定义 UI、交互和资源的文件。

App.json 示例

{
  "id": "app_name",
  "screens": [
    {
      "deviceType": "phone",
      "path": "lending_screen.json",
      "controller" : "lending_screen_plugin.js"
    },
    {
      "deviceType": "phone",
      "path": "signin_and_singup_screen.json",
      "controller" : "signin_and_singup_screen_plugin.js"
    }
  ],
  "jsLibraries" : [
    "data_storage.js", "data_processing.js", "network_communication.js"
  ],
  "mainScreenId": "lending_screen_id",
  "i18n" : {
    "default" : "en",
    "languages" : {
      "en" : "en.json",
      "fr" : "fr.json"
    }
  },
  "version": 2
}

设置

最简单的方法是使用 Podfile 并在 AppDelegate 中启动库。

Podfile

pod "Infrared"

AppDelegate 中的代码

如果整个应用应该作为 Infrared 应用(根视图控制器由 mainScreenId 作为 app.json 中指示自动设置)使用以下方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];

    [[Infrared sharedInstance] buildInfraredAppFromPath:@"app.json"];

    return YES;
}

如果 Infrared 视图控制器只是整个 iOS 应用的一部分,则使用以下方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];

    [[Infrared sharedInstance] buildInfraredAppFromPath:@"app.json" setRootViewController:NO];

    return YES;
}

文档

详细的文档可以在项目的 维基页面 中找到


重要

  • master 分支是用于开发的
  • 标签是用于稳定版本的

许可

Infrared iOS 库(infrared_ios)是根据 Apache 许可协议版本 2.0 发布的。请参阅 LICENSE