Convert Figma logo to code with AI

JoaquimLey logofaboptions

A multi-functional FAB component with customizable options

1,040
140
1,040
6

Top Related Projects

A menu which can ... BOOM! - Android

Android Floating Action Button based on Material Design specification

Floating Action Button for Android based on Material Design specification

You can easily add awesome animated context menu to your app.

Quick Overview

The JoaquimLey/faboptions repository is a Flutter package that provides a customizable Floating Action Button (FAB) with various options and animations. It allows developers to create a FAB with multiple actions, similar to the "speed dial" feature found in many mobile apps.

Pros

  • Customizable: The package offers a wide range of customization options, allowing developers to tailor the FAB to their specific needs.
  • Animations: The FAB supports various animations, including rotation, scaling, and fading, which can enhance the user experience.
  • Multiple Actions: The package enables the creation of FABs with multiple actions, providing users with quick access to related functionalities.
  • Well-documented: The project has a comprehensive README file and examples, making it easy for developers to get started and understand the available features.

Cons

  • Dependency on Flutter: As a Flutter-specific package, it may not be suitable for non-Flutter projects.
  • Limited Platform Support: The package currently only supports Android and iOS platforms, and there is no web or desktop support.
  • Potential Performance Issues: Depending on the complexity of the FAB and the number of actions, the package may have some performance implications, especially on older or less powerful devices.
  • Lack of Mature Ecosystem: Compared to some other Flutter packages, the faboptions package may have a smaller community and fewer third-party integrations available.

Code Examples

Here are a few code examples demonstrating the usage of the faboptions package:

Creating a Simple FAB

FloatingActionButton(
  onPressed: () {
    // Perform action when FAB is pressed
  },
  child: Icon(Icons.add),
),

Creating a FAB with Multiple Actions

FabOptions(
  icon: Icon(Icons.add),
  options: [
    FabOption(
      icon: Icon(Icons.share),
      label: 'Share',
      onPressed: () {
        // Perform share action
      },
    ),
    FabOption(
      icon: Icon(Icons.edit),
      label: 'Edit',
      onPressed: () {
        // Perform edit action
      },
    ),
    FabOption(
      icon: Icon(Icons.delete),
      label: 'Delete',
      onPressed: () {
        // Perform delete action
      },
    ),
  ],
),

Customizing the FAB Appearance

FabOptions(
  icon: Icon(Icons.add),
  buttonColor: Colors.blue,
  iconColor: Colors.white,
  buttonSize: 56.0,
  iconSize: 24.0,
  options: [
    // Add your options here
  ],
),

Getting Started

To get started with the faboptions package, follow these steps:

  1. Add the package to your project's dependencies in the pubspec.yaml file:
dependencies:
  faboptions: ^1.0.0
  1. Import the package in your Dart file:
import 'package:faboptions/faboptions.dart';
  1. Create a FabOptions widget and customize it to your needs:
FabOptions(
  icon: Icon(Icons.add),
  options: [
    FabOption(
      icon: Icon(Icons.share),
      label: 'Share',
      onPressed: () {
        // Perform share action
      },
    ),
    FabOption(
      icon: Icon(Icons.edit),
      label: 'Edit',
      onPressed: () {
        // Perform edit action
      },
    ),
  ],
),
  1. Adjust the appearance of the FAB by setting the buttonColor, iconColor, buttonSize, and iconSize properties.

  2. Customize the behavior of the FAB and its options by providing the appropriate onPressed callbacks.

For more detailed information and examples, please refer to the faboptions package documentation.

Competitor Comparisons

A menu which can ... BOOM! - Android

Pros of BoomMenu

  • BoomMenu provides a wide range of customization options, allowing developers to create unique and visually appealing menu designs.
  • The library includes various animation effects and transition styles, making the menu interactions more engaging and dynamic.
  • BoomMenu supports multiple menu types, including circular, square, and other custom layouts, catering to different design preferences.

Cons of BoomMenu

  • The BoomMenu library may have a steeper learning curve compared to faboptions, as it offers more advanced features and customization options.
  • The library's documentation and community support may not be as extensive as faboptions, which could make it more challenging for developers to get started or troubleshoot issues.
  • BoomMenu may have a larger file size and dependency footprint compared to faboptions, which could impact the overall performance of the application.

Code Comparison

faboptions

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null).show();
    }
});

BoomMenu

BoomMenuButton bmb = (BoomMenuButton) findViewById(R.id.bmb);
bmb.setButtonEnum(ButtonEnum.Ham);
bmb.setButtonPlaceEnum(ButtonPlaceEnum.SC_4);
bmb.setButtonShadowEffect(true);
bmb.setButtonShadowOffsetX(AndroidUtilities.dp(2));
bmb.setButtonShadowOffsetY(AndroidUtilities.dp(4));

Android Floating Action Button based on Material Design specification

Pros of Clans/FloatingActionButton

  • Provides a variety of customization options for the floating action button, including size, color, and animation.
  • Supports multiple floating action buttons, allowing for a more complex UI design.
  • Includes built-in support for material design guidelines and animations.

Cons of Clans/FloatingActionButton

  • The library may be overkill for simple use cases, where a basic floating action button would suffice.
  • The codebase is larger and more complex than JoaquimLey/faboptions, which may impact performance in some cases.

Code Comparison

JoaquimLey/faboptions:

fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        // Handle click event
    }
});

Clans/FloatingActionButton:

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        // Handle click event
    }
});

The main difference in the code is that Clans/FloatingActionButton requires more setup, as it needs to be explicitly instantiated and configured, while JoaquimLey/faboptions provides a more streamlined approach.

Floating Action Button for Android based on Material Design specification

Pros of zendesk/android-floating-action-button

  • Provides a simple and customizable floating action button (FAB) implementation for Android
  • Supports various FAB styles and animations out of the box
  • Actively maintained with regular updates and bug fixes

Cons of zendesk/android-floating-action-button

  • Limited support for advanced FAB features like sub-menus or custom FAB layouts
  • Requires more boilerplate code to integrate with custom UI designs
  • Smaller community and fewer third-party extensions compared to JoaquimLey/faboptions

Code Comparison

zendesk/android-floating-action-button

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null).show();
    }
});

JoaquimLey/faboptions

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        fab.toggle();
    }
});

You can easily add awesome animated context menu to your app.

Pros of Context-Menu.Android

  • Provides a visually appealing and customizable context menu experience for Android apps.
  • Supports various animation styles and configurations to match the desired UI.
  • Offers a simple and intuitive API for integrating the context menu into existing projects.

Cons of Context-Menu.Android

  • May have a larger footprint in the app's overall size compared to a custom implementation.
  • Requires additional dependencies and setup, which may not be necessary for simpler context menu requirements.
  • Might not offer the same level of flexibility and control as a custom-built solution.

Code Comparison

Context-Menu.Android

ContextMenuDialogFragment.Builder builder = new ContextMenuDialogFragment.Builder();
builder.addItem(R.drawable.ic_share, "Share")
      .addItem(R.drawable.ic_save, "Save")
      .setOnItemClickListener(new ContextMenuItemClickListener() {
          @Override
          public void onItemClick(int position) {
              // Handle item click
          }
      });
ContextMenuDialogFragment fragment = builder.build();
fragment.show(getSupportFragmentManager(), "context_menu");

faboptions

val fabOptions = FabOptions(this)
fabOptions.addOption(
    FabOption(
        R.drawable.ic_share,
        "Share",
        onClickListener = { /* Handle share action */ }
    )
)
fabOptions.addOption(
    FabOption(
        R.drawable.ic_save,
        "Save",
        onClickListener = { /* Handle save action */ }
    )
)
fabOptions.show()

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AppIcon

FabOptions

Android Arsenal MaterialUp Bintray minSdkVersion compileSdkVersion

Special thanks to André Mion for the help provided on building this component. Original concept by Praveen Bisht posted on MaterialUp, turned into code into open source library.

Gif concept sample

Android implementation

Gif android sample

How to use

  • Import gradle dependency:

      dependencies {
         	compile 'com.github.joaquimley:faboptions:1.2.0'
      }
    
  • Add the component to your layout:

<com.joaquimley.faboptions.FabOptions
	android:id="@+id/fab_options"
 	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
  	android:layout_gravity="bottom" />
  • Define a menu.xml file with your buttons information e.g.
<menu>
    <item
        android:id="@+id/faboptions_favorite"
        android:icon="@drawable/ic_favorite"
        android:title="Favorite" />
	
    <item
        android:id="@+id/faboptions_textsms"
        android:icon="@drawable/ic_textsms"
        android:title="Message" />
	
    <item
        android:id="@+id/faboptions_download"
        android:icon="@drawable/ic_file_download"
        android:title="Download" />
	
	
    <item
        android:id="@+id/faboptions_share"
        android:icon="@drawable/ic_share"
        android:title="Share" />
</menu>

XML:

  • Bind the buttons menu by adding the custom attribute app:button_menu="@menu/your_fab_buttons" to your component XML.

Programmatically

  • Bind the buttons menu on your FabOptions instance with FabOptions#setMenu(Menu).
FabOptions fabOptions = (FabOptions) findViewById(R.id.fab_options);
fabOptions.setButtonsMenu(R.menu.your_fab_buttons);

Listening for click events

  • Set your FabOptions instance click listener.

  • Handle the click events for each button id defined on the menu.xml.

Customizing

You can change the color of the component, both the FAB and the "background" individually, unless specified the background will always adopt the same value as the app:fab_color attribute (default is the theme's accent color).

 <com.joaquimley.faboptions.FabOptions
        android:id="@+id/fab_options"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:background_color="@color/fabOptionsBackgroundColor"
        app:fab_color="@color/fabOptionsFabColor" />

You can also use Java

fabOptions.setFabColor(R.color.fabOptionsFabColor);
fabOptions.setBackgroundColor(R.color.fabOptionsBackgroundColor);

Note: One is not dependent on the other, you can set individually.

Changing button color

fabOptions.setButtonColor(R.id.faboptions_favorite, R.color.colorAccent)

This will return a boolean value if it's able to change the color.

The sample is also available on the Playstore

Get it on Google Play

Issues: Fell free to open a new issue. Follow the ISSUE_TEMPLATE.MD

Changelog

1.2.0

  • Ability to open and close the component with new exposed open()/close() methods. - #35
  • Change the background color setBackgroundColor() through @ColorInt - #41

1.1.2

  • Fix a bug where buttons were clickable even when hidden - #25

1.1.1

  • Fix a resurfaced issue with related to Snackbar behaviour - #8

1.1.0

  • Backport to API 14 - #21
  • Change button color at runtime with the new #setButtonColor(int) - #22
  • Bug fix on Menu not displayed correctly - #17
  • Customize both background + fab colors. - #16

1.0.2

  • Fix layout measure
  • The component now reacts when a snackbar dismissed by user - #8

1.0.1

  • Fix slight vertical offset on the button's icon - #2

Contributing

Contributions are always welcome!

Follow the "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Merge with current development branch
  5. Push your work back up to your fork
  6. Submit a Pull request your changes can be reviewed (please refere the issue if reported)

Prevent code-style related changes (at least run Ctrl+⌥+O, ⌥+⌘+L) before commiting.

License

Copyright © 2016 Joaquim Ley

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
See the License for the specific language governing permissions and
limitations under the License.