Pular para o conteúdo
CrossFly é 100% open sourceSiga no GitHub
CrossFlyCrossFly
Começar
Todos os exemplos
ReceitasNavegaçãoSobreposições71 linhas · 1 arquivos

Bottom sheet with a fixed footer

BottomSheet already gives you the header, the grabber, the close button and a footer that floats over the scroll. You only fill body().

O que isto mostra

A bottom sheet with a header and a footer that stay put while the middle scrolls.

Rodar na sua máquina

Todo exemplo é uma Window comum, então o launcher só precisa do nome dela.

gradlew lwjgl3:run --args="classname dev.cf.recipe.R04Sheet"
Editar o exemplo

Java é compilado antes de rodar, então o navegador não consegue reconstruir uma edição sozinho — o código que você vê aqui virou JavaScript pelo TeaVM antes de ser publicado. Copie o arquivo para um projeto e ele roda sem mudanças nas quatro plataformas; o comando acima é toda a preparação.

Rodando aquiCrossFly 0.1.32
Iniciando o aplicativo…

Compilado para JavaScript pelo TeaVM — é o mesmo código, não um vídeo dele. · Todos os exemplos

O que ele usa

Tipos do framework que este exemplo toca. Os que têm link têm página de referência.

BottomSheetButtonComponentDebugGridLayoutStylesWidgets

O código

Completo, sem cortes. É o arquivo, não um trecho dele.

Bruto
dev/cf/recipe/R04Sheet.java
package dev.cf.recipe;

import dev.cf.Tones;

import dev.crossfly.ui.*;
import dev.crossfly.ui.color.*;
import dev.crossfly.ui.graphics.*;
import dev.crossfly.ui.layout.*;
import dev.crossfly.ui.style.*;

import static dev.crossfly.ui.Widgets.*;

/**
 * A bottom sheet with a header and a footer that stay put while the middle scrolls.
 */
public class R04Sheet extends Recipe
{
   public String title()
   {
      return "Bottom sheet with a fixed footer";
   }

   public String note()
   {
      return "BottomSheet already gives you the header, the grabber, the close button and a footer"
         + " that floats over the scroll. You only fill body().";
   }

   public void build(Component body) throws Exception
   {
      Button abrir = Tones.action("Open the sheet");
      abrir.testTag("recipe.open");
      abrir.onAction(c -> abrirSheet());
      body.add(LAY_AUTO, abrir);
   }

   private void abrirSheet()
   {
      try
      {
         // The kicker is the small upper-case label above the title.
         final BottomSheet sheet = new BottomSheet("FILTER", "Choose a segment");
         sheet.maxHeightRatio(.7f);

         for (int i = 1; i <= 20; i++)
         {
            // A tonal pill per segment: twenty identical grey lines is a list nobody can aim at.
            Component linha = new Component();
            linha.setLayout(new GridLayout(Position.START, Position.CENTER));
            linha.add(LAY_AUTO, LAY_AUTO, Tones.tile(0xE574, Tones.cycle(i)),
               outgap(label("Segment " + i, 1f, false, Styles.textColor, Position.START),
                  .6f, 0, 0, 0));
            sheet.body()
               .add(LAY_AUTO, outgap(linha, 0, .3f, 0, .3f));
         }

         // The footer does NOT go into the body: it floats over the scroll and stays reachable with
         // the list at its end — which is why it has an API of its own.
         Button aplicar = Tones.action("Apply");
         aplicar.onAction(c -> sheet.hide());
         sheet.footer(aplicar);

         sheet.show();
      }
      catch (Exception e)
      {
         dev.crossfly.util.Debug.handle(e);
      }
   }
}
Para uma IA

Versões desta página legíveis por máquina, para um modelo ler a prateleira em vez de adivinhar a API.

Este exemplo, em JSONEste exemplo, em Markdown
AnteriorSwitching skinsPróximoListing: cards or table