Interface View


public interface View
What a page shows, top to bottom: the dashboard draws each block in its own style. A block that holds others (a card, columns, tabs) takes a view of its own to fill.
(view, viewer) -> {
    view.stats(stats -> {
        stats.add("Sales today", shop.salesToday()).sub("+12 since this morning").tone(Tone.GOOD);
        stats.add("Stock", shop.stock()).unit("items").spark(shop.stockHistory());
    });
    view.card("Last sales", card -> card.table(table -> {
        table.column("Player").column("Item").column("Price").search().pages(20);
        for (Sale sale : shop.lastSales()) {
            table.row().player(sale.buyer(), sale.name()).text(sale.item()).number(sale.price())
                .buttons(buttons -> buttons.action("Refund", "refund").with("sale", sale.id())
                    .tone(Tone.BAD).confirm("Refund " + sale.name() + "?"));
        }
    }));
}

Text is shown as text, never read as HTML. A view is filled by one thread, the renderer's.

  • Method Details

    • title

      View title(String title)
      Replaces the page's title for this drawing: the name of what a detail page shows.
      Parameters:
      title - the title
      Returns:
      this view
    • subtitle

      View subtitle(String text)
      The line under the page's title.
      Parameters:
      text - the line
      Returns:
      this view
    • stats

      View stats(Consumer<View.Stats> stats)
      A row of figures, each in a tile.
      Parameters:
      stats - what fills it
      Returns:
      this view
    • card

      View card(String title, Consumer<View> content)
      A card: a title over the blocks its view holds.
      Parameters:
      title - the card's title
      content - what fills it
      Returns:
      this view
    • columns

      View columns(int count, Consumer<View> content)
      Blocks side by side, as many per row as fit up to count, one under the other on a phone.
      Parameters:
      count - 2, 3 or 4
      content - what fills it: each block is a column
      Returns:
      this view
    • tabs

      View tabs(Consumer<View.Tabs> tabs)
      Tabs, each with its own blocks; the dashboard remembers the one open.
      Parameters:
      tabs - what fills them
      Returns:
      this view
    • table

      View table(Consumer<View.Table> table)
      A table.
      Parameters:
      table - what fills it
      Returns:
      this view
    • chart

      View chart(Consumer<View.Chart> chart)
      A chart of lines over time.
      Parameters:
      chart - what fills it
      Returns:
      this view
    • bars

      View bars(Consumer<View.Bars> bars)
      Horizontal bars, each against the longest: a ranking, a share.
      Parameters:
      bars - what fills them
      Returns:
      this view
    • facts

      View facts(Consumer<View.Facts> facts)
      Pairs of a label and a value, one under the other.
      Parameters:
      facts - what fills them
      Returns:
      this view
    • progress

      View progress(String label, double fraction)
      A progress bar.
      Parameters:
      label - what it measures
      fraction - from 0 to 1
      Returns:
      this view
    • progress

      View progress(String label, double fraction, Tone tone)
      A progress bar of a colour.
      Parameters:
      label - what it measures
      fraction - from 0 to 1
      tone - its colour
      Returns:
      this view
    • text

      View text(String text)
      A paragraph.
      Parameters:
      text - the paragraph; line breaks are kept
      Returns:
      this view
    • text

      View text(String text, Tone tone)
      A paragraph of a colour: Tone.NEUTRAL for a quieter one.
      Parameters:
      text - the paragraph
      tone - its colour
      Returns:
      this view
    • notice

      View notice(Tone tone, String text)
      A notice that stands out: a warning, a success, an error.
      Parameters:
      tone - its colour and icon
      text - what it says
      Returns:
      this view
    • buttons

      View buttons(Consumer<View.Buttons> buttons)
      A row of buttons.
      Parameters:
      buttons - what fills it
      Returns:
      this view
    • form

      View form(String action, Consumer<View.Form> form)
      A form, sent to an action with the values of its fields (ActionContext.string(String)...).
      Parameters:
      action - the action it runs
      form - what fills it
      Returns:
      this view
    • frame

      View frame(String file)
      One of the plugin's own web pages, in a frame among the blocks, as tall as its content.
      Parameters:
      file - an HTML file of the assets (Extension.assets(String))
      Returns:
      this view
    • frame

      View frame(String file, int height)
      One of the plugin's own web pages, in a frame of a given height.
      Parameters:
      file - an HTML file of the assets
      height - its height in pixels
      Returns:
      this view
    • empty

      View empty(String text)
      A quiet line saying there is nothing to show.
      Parameters:
      text - the line
      Returns:
      this view