在对话框中选择 <paper-tab> 时调整大小 <paper-dialog>

Resize <paper-dialog> when selecting <paper-tab> inside the dialog

resizeable_dialog.html

<link rel="import" href="../../packages/polymer/polymer.html">

<link rel="import" href="../../packages/paper_elements/paper_dialog.html">
<link rel="import" href="../../packages/paper_elements/paper_button.html">
<link rel="import" href="../../packages/paper_elements/paper_tabs.html">
<link rel="import" href="../../packages/paper_elements/paper_tab.html">
<link rel="import" href="../../packages/paper_elements/paper_icon_button.html">
<link rel="import" href="../../packages/core_elements/core_toolbar.html">
<link rel="import" href="../../packages/core_elements/core_pages.html">

<polymer-element name="resizeable-dialog">
  <template>
    <style>
      :host {
        display: block;
      }
    </style>
    <paper-button on-click="{{open}}">Open Dialog</paper-button>    
    <paper-dialog id="dialog" transition="core-transition-bottom" backdrop>
      <paper-tabs selected="{{selected}}">
        <paper-tab>Page 1</paper-tab>
        <paper-tab>Page 2</paper-tab>
      </paper-tabs>
      <section>
        <core-pages selected="{{selected}}">
          <div style="width: 100px; height: 100px;">
            <div>Page 1: 100x100</div>
            <paper-button on-click="{{notifyResize}}">Call 'notifyResize'</paper-button>          
          </div>
          <div style="width: 400px; height: 400px;">
            <div>Page 2: 400x400</div>
            <paper-button on-click="{{notifyResize}}">Call 'notifyResize'</paper-button>          
          </div>
        </core-pages>
      </section>
    </paper-dialog>

  </template>
  <script type="application/dart" src="resizeable_dialog.dart"></script>
</polymer-element>

resizeable_dialog.dart

library resizable_dialog;

import 'package:polymer/polymer.dart';
import 'package:paper_elements/paper_dialog.dart';

@CustomTag('resizeable-dialog')
class ResizeableDialog extends PolymerElement {

  ResizeableDialog.created() : super.created();
  @observable int selected = 0;

  notifyResize() {
    $['dialog'] as PaperDialog..notifyResize();
    print('"notifyResize" called.');
  }

  open() {
    $['dialog'] as PaperDialog..open();
  }

}

这是我的对话框,我想你对标签栏有所了解。我的问题是 <paper-dialog> 在显示之前的某个时间点计算其尺寸。但是,由于我的 <core-pages> 可以有不同的宽度和高度,我必须在用户选择一个选项卡时调整对话框的大小,以确保当前所选页面的全部内容都可见。

由于某些原因,Dart 中不存在方法 <paper-dialog>.notifyResize()。它在 paper-elements 文档中指定 here,但我无法调用它,因为它在 Dart 中不存在。

我该怎么做?如何让对话框重新测量其尺寸?

你应该可以解决

import 'dart:js' as js;
...
new js.JsObject.fromBrowserObject($['dialog'])
   .callMethod('notifyResize', []);

import 'package:paper_elements/paper_dialog.dart';
...
($['dialog'] as PaperDialog).jsElement
    .callMethod('notifyResize', []);

请在 github.com/dart-lang/paper-elements 存储库(或核心元素,因为我认为此功能应继承自核心覆盖)中创建错误报告