smart_dialogs 2.0.3 copy "smart_dialogs: ^2.0.3" to clipboard
smart_dialogs: ^2.0.3 copied to clipboard

outdated

This package provides easy-to-use dialogs of various types and some other GUI elements (popups, tables, icon panels) for use in Web applications, based on 'dart:html'.

example/main.dart

// Copyright (c) 2019, Dr. Bruno Guigas. All rights reserved. Use of this source
// code is governed by a BSD-style license that can be found in the LICENSE file.
//
// To execute this example, visit the following page:
//   https://smart.specpad.bplaced.net/smart_dialogs/example.html

import 'package:smart_dialogs/smart_dialogs.dart';

import 'dart:async';
import 'dart:html';
import 'src/examples.dart';

main() {
  ExampleDispatcher();
}

/// Displays a dialog to select and execute examples
class ExampleDispatcher {
  static List<String> isChecked;

  static List<String> items = [
    "Info Dialog",
    "Confirm Dialog",
    "Single-Line Input Dialog",
    "Multi-Line Input Dialog",
    "Advanced Input Dialog with Check Buttons",
    "Advanced Input Dialog with Radio Buttons",
    "Advanced Input Dialog with Radio Buttons, 2D",
    "Non-Modal Dialog",
    "System's File Selection Dialog",
    "Change Dialog Attributes",
    "Icon Panel",
    "Popup Menu",
    "Simple Table",
    "Interactive Table"
  ];

  static List<Function> itemsFuncs = [
    showInfoDialog,
    showConfirmDialog,
    showSingleLineInputDialog,
    showMultiLineInputDialog,
    showAdvancedInputDialogCheckButtons,
    showAdvancedInputDialogRadioButtons,
    showAdvancedInputDialog2D,
    showNonModalDialog,
    showFileInputDialog,
    DialogAttributeChanger.changeDialogAttributes,
    showIconPanel,
    showPopupMenu,
    showSimpleTable,
    showInterActiveTable
  ];

  static DivElement app_div;

  ExampleDispatcher() {
    showDialogExamples();
  }

  /// Shows the example options and displays the selected dialog example
  static Future<bool> showDialogExamples() async {
    app_div = (querySelector("#app_div") as DivElement);
    assert(items.length == itemsFuncs.length);
    if (isChecked == null) {
      isChecked = List<String>.filled(items.length, DiaUtils.FALSE);
      isChecked[0] = DiaUtils.TRUE;
    }
    Completer<bool> cpl = new Completer();
    UserInput uin = await Info.get(
        DiaAttr.RADIO,
        "Examples for the Dart package <i>smart_dialogs</i>." +
            "<br>Please select an example and press OK",
        items,
        null,
        List.filled(items.length, null),
        List<int>.filled(items.length, 0),
        isChecked,
        true,
        null);
    if (uin.buttonCode == DiaAttr.DIA_ACT_OK) {
      isChecked = List<String>.filled(isChecked.length, DiaUtils.FALSE);
      for (int i = 0; i < items.length; i++) {
        if (uin.getCheckedState(i) == DiaUtils.TRUE) {
          isChecked[i] = DiaUtils.TRUE;
          DiaAttr.initAttrFromDefaults(); // because itemsFuncs may have changed
          await itemsFuncs[i]();
          break;
        }
      }
    }
    cpl.complete(true);
    return cpl.future;
  }
}
4
likes
0
pub points
25%
popularity

Publisher

verified publisherhiveright.tech

This package provides easy-to-use dialogs of various types and some other GUI elements (popups, tables, icon panels) for use in Web applications, based on 'dart:html'.

Homepage

License

unknown (license)

Dependencies

build_runner, build_web_compilers

More

Packages that depend on smart_dialogs