मुख्य सामग्री पर जाएँ
CrossFly 100% ओपन सोर्सGitHub पर फ़ॉलो करें
CrossFlyCrossFly
शुरू करें
सभी उदाहरण
रेसिपीनेविगेशनओवरले71 पंक्तियाँ · 1 फ़ाइलें

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().

यह क्या दिखाता है

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

अपनी मशीन पर चलाएँ

हर उदाहरण एक साधारण Window है, इसलिए लॉन्चर को सिर्फ़ उसका नाम चाहिए।

gradlew lwjgl3:run --args="classname dev.cf.recipe.R04Sheet"
इसे बदलना

Java पहले से संकलित होता है, इसलिए ब्राउज़र आपके बदलाव को खुद दोबारा नहीं बना सकता — यहाँ दिखा कोड प्रकाशित होने से पहले TeaVM द्वारा JavaScript में बदला गया था। फ़ाइल को किसी प्रोजेक्ट में कॉपी कीजिए और वह चारों प्लेटफ़ॉर्म पर बिना बदलाव चलती है; ऊपर दी गई कमांड ही पूरी तैयारी है।

यहीं चल रहा हैCrossFly 0.1.32
ऐप शुरू हो रहा है…

TeaVM ने इसे JavaScript में संकलित किया — यह वही कोड है, उसका वीडियो नहीं। · सभी उदाहरण

यह क्या इस्तेमाल करता है

इस उदाहरण में छुए गए फ़्रेमवर्क टाइप। जिनमें लिंक है उनका संदर्भ पृष्ठ मौजूद है।

BottomSheetButtonComponentDebugGridLayoutStylesWidgets

सोर्स कोड

पूरा, बिना कटौती के। यह वही फ़ाइल है, उसका अंश नहीं।

कच्चा
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);
      }
   }
}
एआई सहायक के लिए

इस पृष्ठ के मशीन-पठनीय रूप, ताकि मॉडल API का अनुमान लगाने के बजाय उदाहरण पढ़ सके।

यह उदाहरण, JSON मेंयह उदाहरण, Markdown में
पिछलाSwitching skinsअगलाListing: cards or table