B2B网络软件

标题: AIWROK软件苹果TAB界面视图示例 [打印本页]

作者: YYPOST群发软件    时间: 昨天 09:39
标题: AIWROK软件苹果TAB界面视图示例

AIWROK软件苹果TAB界面视图示例
AIWROK软件苹果TAB界面视图示例 B2B网络软件

AIWROK软件苹果TAB界面视图示例 B2B网络软件


  1. // 全新TabView案例 - 基于AIWROK文档实现
  2. // 该示例展示了如何创建一个功能完整的TabView界面,包含多个标签页和交互元素
  3. // 🍎交流QQ群711841924群一,苹果内测群:528816639
  4. // 创建TabView实例
  5. var tab = new TabView();

  6. // 设置Tab标题
  7. var tabTitles = ["首页", "工具", "数据", "设置"];
  8. tab.setTitles(tabTitles);

  9. // 显示TabView界面
  10. tab.show(() => {
  11.     printl("TabView界面已加载完成");
  12.    
  13.     // 为每个Tab添加内容
  14.     for (var i = 0; i < tabTitles.length; i++) {
  15.         tab.addView(i, createTabContent(i, tabTitles[i]));
  16.     }
  17. });

  18. // 创建Tab内容的函数
  19. function createTabContent(index, title) {
  20.     var v = new Vertical();
  21.     v.setBackgroundColor(245, 245, 245); // 浅灰色背景
  22.    
  23.     // 添加标题区域
  24.     var titleHeader = new Horizontal();
  25.     titleHeader.setAlignment("center");
  26.     titleHeader.setSpacing(20);
  27.    
  28.     var titleLabel = new Label();
  29.     titleLabel.setText(title + "页面");
  30.     titleLabel.setTextColor(50, 100, 150); // 蓝色文字
  31.     titleLabel.setFontSize(24);
  32.     titleHeader.addView(titleLabel);
  33.    
  34.     v.addView(titleHeader);
  35.    
  36.     // 添加分隔线
  37.     var divider = new Label();
  38.     divider.setHeight(2);
  39.     divider.setBackgroundColor(200, 200, 200);
  40.     v.addView(divider);
  41.    
  42.     // 添加内容区域
  43.     var contentArea = new Vertical();
  44.     contentArea.setSpacing(20);
  45.    
  46.     // 根据不同Tab添加不同内容
  47.     if (index === 0) { // 首页Tab
  48.         addHomeContent(contentArea);
  49.     } else if (index === 1) { // 工具Tab
  50.         addToolsContent(contentArea);
  51.     } else if (index === 2) { // 数据Tab
  52.         addDataContent(contentArea);
  53.     } else if (index === 3) { // 设置Tab
  54.         addSettingsContent(contentArea);
  55.     }
  56.    
  57.     v.addView(contentArea);
  58.    
  59.     // 添加底部按钮区域
  60.     var buttonArea = new Horizontal();
  61.     buttonArea.setAlignment("center");
  62.     buttonArea.setSpacing(20);
  63.     buttonArea.setBackgroundColor(230, 230, 230);
  64.    
  65.     var refreshButton = new Button();
  66.     refreshButton.setText("刷新");
  67.     refreshButton.setColor(50, 100, 150); // 蓝色背景
  68.     refreshButton.setTextColor(255, 255, 255); // 白色文字
  69.     refreshButton.setWidth(100);
  70.     refreshButton.setHeight(40);
  71.     refreshButton.onClick(() => {
  72.         printl(title + "页面刷新按钮被点击");
  73.         showToast("页面已刷新");
  74.     });
  75.     buttonArea.addView(refreshButton);
  76.    
  77.     var closeButton = new Button();
  78.     closeButton.setText("关闭");
  79.     closeButton.setColor(200, 50, 50); // 红色背景
  80.     closeButton.setTextColor(255, 255, 255); // 白色文字
  81.     closeButton.setWidth(100);
  82.     closeButton.setHeight(40);
  83.     closeButton.onClick(() => {
  84.         printl("关闭按钮被点击");
  85.         tab.dismiss();
  86.     });
  87.     buttonArea.addView(closeButton);
  88.    
  89.     v.addView(buttonArea);
  90.    
  91.     return v;
  92. }

  93. // 添加首页内容
  94. function addHomeContent(container) {
  95.     // 添加欢迎信息
  96.     var welcomeLabel = new Label();
  97.     welcomeLabel.setText("欢迎使用AIWROK开发工具");
  98.     welcomeLabel.setTextColor(80, 80, 80);
  99.     welcomeLabel.setFontSize(18);
  100.     welcomeLabel.setTextAlignment("center");
  101.     container.addView(welcomeLabel);
  102.    
  103.     // 添加间距
  104.     var spacing = new Label();
  105.     spacing.setHeight(30);
  106.     container.addView(spacing);
  107.    
  108.     // 添加功能卡片
  109.     addFeatureCard(container, "快速开发", "使用AIWROK快速构建应用");
  110.     addFeatureCard(container, "跨平台支持", "同时支持iOS和Android");
  111.     addFeatureCard(container, "丰富组件", "提供多种UI组件和工具");
  112. }

  113. // 添加工具内容
  114. function addToolsContent(container) {
  115.     // 添加工具列表
  116.     var toolsList = new Vertical();
  117.    
  118.     addToolItem(toolsList, "OCR文字识别", "识别图片中的文字");
  119.     addToolItem(toolsList, "找图功能", "在屏幕上查找指定图片");
  120.     addToolItem(toolsList, "网络请求", "发送HTTP请求获取数据");
  121.     addToolItem(toolsList, "文件操作", "读取和写入本地文件");
  122.    
  123.     container.addView(toolsList);
  124. }

  125. // 添加数据内容
  126. function addDataContent(container) {
  127.     // 添加数据展示
  128.     var dataHeader = new Label();
  129.     dataHeader.setText("应用数据统计");
  130.     dataHeader.setTextColor(80, 80, 80);
  131.     dataHeader.setFontSize(18);
  132.     container.addView(dataHeader);
  133.    
  134.     // 添加间距
  135.     var spacing = new Label();
  136.     spacing.setHeight(20);
  137.     container.addView(spacing);
  138.    
  139.     // 添加数据项
  140.     addDataItem(container, "今日启动次数", "12");
  141.     addDataItem(container, "总运行时间", "3小时25分钟");
  142.     addDataItem(container, "成功执行任务", "48");
  143.     addDataItem(container, "错误次数", "2");
  144. }

  145. // 添加设置内容
  146. function addSettingsContent(container) {
  147.     // 添加设置列表
  148.     var settingsList = new Vertical();
  149.    
  150.     addSettingItem(settingsList, "通用设置", "基本应用配置");
  151.     addSettingItem(settingsList, "外观设置", "调整应用外观");
  152.     addSettingItem(settingsList, "通知设置", "管理应用通知");
  153.     addSettingItem(settingsList, "关于我们", "应用信息和版本");
  154.    
  155.     container.addView(settingsList);
  156. }

  157. // 添加功能卡片
  158. function addFeatureCard(container, title, description) {
  159.     var card = new Vertical();
  160.     card.setBackgroundColor(255, 255, 255);
  161.     card.setSpacing(15);
  162.    
  163.     var cardTitle = new Label();
  164.     cardTitle.setText(title);
  165.     cardTitle.setTextColor(50, 100, 150);
  166.     cardTitle.setFontSize(16);
  167.     card.addView(cardTitle);
  168.    
  169.     var cardDesc = new Label();
  170.     cardDesc.setText(description);
  171.     cardDesc.setTextColor(100, 100, 100);
  172.     cardDesc.setFontSize(14);
  173.     card.addView(cardDesc);
  174.    
  175.     container.addView(card);
  176. }

  177. // 添加工具项
  178. function addToolItem(container, name, description) {
  179.     var toolItem = new Horizontal();
  180.     toolItem.setBackgroundColor(255, 255, 255);
  181.     toolItem.setSpacing(15);
  182.    
  183.     var toolInfo = new Vertical();
  184.     var toolName = new Label();
  185.     toolName.setText(name);
  186.     toolName.setTextColor(80, 80, 80);
  187.     toolName.setFontSize(16);
  188.     toolInfo.addView(toolName);
  189.    
  190.     var toolDesc = new Label();
  191.     toolDesc.setText(description);
  192.     toolDesc.setTextColor(120, 120, 120);
  193.     toolDesc.setFontSize(14);
  194.     toolInfo.addView(toolDesc);
  195.    
  196.     var toolButton = new Button();
  197.     toolButton.setText("使用");
  198.     toolButton.setColor(50, 100, 150);
  199.     toolButton.setTextColor(255, 255, 255);
  200.     toolButton.setWidth(80);
  201.     toolButton.setHeight(35);
  202.     toolButton.onClick(() => {
  203.         printl(name + "工具被点击");
  204.         showToast("正在启动" + name);
  205.     });
  206.    
  207.     toolItem.addView(toolInfo);
  208.     toolItem.addView(toolButton);
  209.    
  210.     container.addView(toolItem);
  211. }

  212. // 添加数据项
  213. function addDataItem(container, label, value) {
  214.     var dataItem = new Horizontal();
  215.     dataItem.setAlignment("space_between");
  216.     dataItem.setSpacing(10);
  217.    
  218.     var dataLabel = new Label();
  219.     dataLabel.setText(label);
  220.     dataLabel.setTextColor(80, 80, 80);
  221.     dataLabel.setFontSize(16);
  222.    
  223.     var dataValue = new Label();
  224.     dataValue.setText(value);
  225.     dataValue.setTextColor(50, 100, 150);
  226.     dataValue.setFontSize(16);
  227.     dataValue.setTextAlignment("right");
  228.    
  229.     dataItem.addView(dataLabel);
  230.     dataItem.addView(dataValue);
  231.    
  232.     container.addView(dataItem);
  233. }

  234. // 添加设置项
  235. function addSettingItem(container, name, description) {
  236.     var settingItem = new Horizontal();
  237.     settingItem.setBackgroundColor(255, 255, 255);
  238.     settingItem.setSpacing(15);
  239.    
  240.     var settingInfo = new Vertical();
  241.     var settingName = new Label();
  242.     settingName.setText(name);
  243.     settingName.setTextColor(80, 80, 80);
  244.     settingName.setFontSize(16);
  245.     settingInfo.addView(settingName);
  246.    
  247.     var settingDesc = new Label();
  248.     settingDesc.setText(description);
  249.     settingDesc.setTextColor(120, 120, 120);
  250.     settingDesc.setFontSize(14);
  251.     settingInfo.addView(settingDesc);
  252.    
  253.     var arrowLabel = new Label();
  254.     arrowLabel.setText(">");
  255.     arrowLabel.setTextColor(150, 150, 150);
  256.     arrowLabel.setFontSize(18);
  257.    
  258.     settingItem.addView(settingInfo);
  259.     settingItem.addView(arrowLabel);
  260.    
  261.     container.addView(settingItem);
  262. }

  263. // 显示提示信息
  264. function showToast(message) {
  265.     printl("显示提示: " + message);
  266.     // 实际应用中可以调用原生的toast功能
  267. }

  268. // 日志输出函数
  269. function printl(message) {
  270.     console.log("[TabView Example] " + message);
  271. }

  272. // 代码说明:
  273. // 1. 本示例创建了一个包含4个标签页的TabView界面
  274. // 2. 每个标签页都有不同的内容和布局
  275. // 3. 添加了多种UI元素,如按钮、标签、水平/垂直容器等
  276. // 4. 实现了基本的交互功能,如按钮点击事件
  277. // 5. 代码遵循AIWROK平台的方法规范
  278. // 6. 可以根据实际需求修改和扩展功能
复制代码







欢迎光临 B2B网络软件 (http://bbs.niubt.cn/) Powered by Discuz! X3.2