繁体   English   中英

如何在Appgyver类固醇中创建自定义的webview

[英]How to create a customized webview in Appgyver Steroids

我打算创建以下设计:

在此处输入图片说明

  • 主视图应显示一个网页
  • 它应该在左侧有一个抽屉
  • 抽屉应由应用程序标题中的“汉堡”图标触发

我现在具有以下应用程序结构:

主视图:

<div class="padding" ng-controller="IndexController">
    <super-navbar>
        <super-navbar-title>
            My first app!
        </super-navbar-title>
    </super-navbar>    
</div>

控制器:

angular
  .module('example')
  .controller('IndexController', function($scope, $document, supersonic) {
      $scope.navbarTitle = "Index";         
      addEventListener('load', load, false);
      steroids.view.displayLoading();
      var googleLayer = null;
      googleLayer = new steroids.views.WebView({ location: "http://example.com/page1" });;
      googleLayer.preload({}, {
          onSuccess: replaceLayer
      });

      function load() {        

          var options = {
              side: "left",
              width: 150
          }
          supersonic.ui.views.find("leftDrawer").then(function (leftDrawer) {
              supersonic.ui.drawers.init(leftDrawer);
              supersonic.ui.drawers.open("leftDrawer")
          });

      }
      function replaceLayer() {          
          steroids.layers.replace({
              view: googleLayer,
          }, {
              onSuccess: function () {
                  //alert("The layer stack has been replaced.");
              },
              onFailure: function (error) {
                  //alert("Could not replace the layer stack: " + error.errorDescription);
              }
          });
      }      
  });

结构咖啡:

# Read more about app structure at http://docs.appgyver.com

module.exports =

  # See styling options for tabs and other native components in app/common/native-styles/ios.css or app/common/native-styles/android.css
#tabs
    rootView:
     location: "example#getting-started"

  preloads: [
    {
      id: "learn-more"
      location: "example#learn-more"
    }
    {
      id: "using-the-scanner"
      location: "example#using-the-scanner"
    }
  ]

  drawers:
    left:
      id: "leftDrawer"
      location: "example#drawer"
      showOnAppLoad: true
     options:
      animation: "swingingDoor"

 # initialView:
  #   id: "initialView"
   #  location: "example#initial-view"

到目前为止的行为:

  • 该应用程序启动并显示一个加载圆圈(由于steroids.view.displayLoading();
  • 加载圆圈消失并且网页加载(因为googleLayer替换了初始视图)
  • 没有显示抽屉

我认为,应该进行以下修改:

  • 初始视图应该已经加载了页面(如何?它只是一个div)
  • 抽屉应该在工作
  • 应该有一个可点击的“汉堡”图标

我应该进行哪些修改才能实现所需的行为? 我找不到任何适当的教程或足够的文档。

您的初始视图已被评论。 去除 ”#”

关于您要午餐的第一个视图:

您必须使用TabsInitialView并且选项卡的工作方式是使用第一个选项卡内容作为预先选择的内容并显示它。 因此,如果您对其进行评论或使其保持打开状态,InitialView将毫无意义。

Structure.coffee

tabs: [
    {
      title: "Index"
      id: "index"
      location: "home#index" # Supersonic module#view type navigation
    }
    {
      title: "About"
      id: "geolocation"
      location: "home#drawer"
    }
    {
      title: "Internet"
      id: "internet"
      location: "http://google.com" # URLs are supported!
    }
  ]

对于仅使用InitialView的情况,请注释上面的行,并取消注释下面的行,这是:

  rootView:
    location: "example#getting-started"

关于抽屉,首先,请确保要使用此数组,以便将其作为module.exports =一部分。

对于可点击的汉堡包,您现在无法在导航栏中将其显示为图标(我想这个限制是因为将超音速指令呈现为本机UI)。

要解决此问题 ,您可以完全替换它(我不建议这样做,可能会影响应用程序的性能)。

或者只是将此代码添加到要显示它的<super-navbar>内部内容中(在您的情况下为getting-started.html

<super-navbar-button onclick="supersonic.ui.drawers.open('left')" >
    &equiv;
</super-navbar-button>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM