GithubHelp home page GithubHelp logo

aritraroy / flashbar Goto Github PK

View Code? Open in Web Editor NEW
1.7K 22.0 184.0 1.78 MB

⚡️A highly customizable, powerful and easy-to-use alerting library for Android.

License: Apache License 2.0

Kotlin 86.89% Java 13.11%

flashbar's Introduction

Flashbar

A highly customizable, powerful and easy-to-use alerting library for Android.

Specs

Download API License Android Weekly Android Arsenal

This library allows you to show messages or alerts in your app quickly and easily. It can be used as an alternative to Snackbar or Toast and offers a plethora of useful features and customization options for you to play with.

It has been written 100% in Kotlin. ❤️

Table of Contents

Spread Some ❤️

GitHub followers Twitter Follow

Download

This library is available in jCenter which is the default Maven repository used in Android Studio. You can also import this library from source as a module.

dependencies {
    // other dependencies here
    implementation 'com.andrognito.flashbar:flashbar:{latest_version}'
}

Sample Project

We have an exhaustive sample project demonstrating almost every feature of the library in both languages - Java & Kotlin.

Checkout the Java samples here and the Kotlin samples here.

Usage

It is recommended to check the sample project to get a complete understanding of all the features offered by the library.

The library offers a huge amount of customization options and leverages the Builder pattern for ease of use. You will find details of each of these features described below.

Basics

Flashbar attaches a full-height, full-width view (FlashbarContainerView) to the decor view of the Activity and places a full width, dynamic height view(FlashbarView) inside it. These classes are internal classes and are not exposed for public use.

Here's an example of showing a basic flashbar,

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .message("This is a basic flashbar")
        .build()

You can specify the duration (in millis) for which you want the flashbar to be displayed. The default duration is infinite, i.e. it won't dismiss automatically if you do not specify any duration. You can also use these constants, DURATION_SHORT or DURATION_LONG for convenience.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .duration(500)
        .message("This is a flashbar with duration")
        .build()

Gravity

You can show the flashbar either at the top or at the bottom of the screen using the gravity property. By default, it is shown at the bottom.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .message("Flashbar is shown at the top")
        .build()

Or,

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .message("Flashbar is shown at the bottom")
        .build()

Title

You can show an optional title in the flashbar. You can also customize the color, size, typeface and appearance of it.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .title("Hello World!")
        .build();

You can change the color using titleColor(), size using titleSizeInSp(), titleSizeInPx(), typeface using titleTypeface() and appearance using titleAppearance(). Also, look out for other variants of this methods.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .title("Hello World!")
        .titleColorRes(R.color.white)
        .titleSizeInSp(12f)
        .titleAppearance(R.style.CustomTextStyle)
        .titleTypeface(Typeface.createFromAsset(getAssets(), "ShineBright.ttf"))
        .build();

Message

You can show an optional message in the flashbar. You can also customize the color, size and appearance of it.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .message("This is a short message. But your message can be of any length and the view will dynamically adjust itself.")
        .build();

You can change the color using messageColor(), size using messageSizeInSp(), messageSizeInPx(), typeface using messageTypeface() and appearance using messageAppearance(). Also, look out for other variants of this methods.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .message("This is a short message")
        .messageColor(ContextCompat.getColor(this, R.color.white))
        .messageSizeInSp(16f)
        .messageTypeface(Typeface.createFromAsset(assets, "BeautifulAndOpenHearted.ttf"))
        .build()

Background & Overlay

You can change the background color of the flashbar and add a modal overlay as well.

Background

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("The background color can be changed to any color of your choice.")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .build()

You can also change the background using drawables, like the above, to have a cool gradient effect.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can have gradients by setting background drawable.")
        .backgroundDrawable(R.drawable.bg_gradient)
        .build()

Overlay

The overlay creates a dim effect over the entire screen bringing more focus on the flashbar and its content. It is automatically added/removed along with the flashbar.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show a modal overlay to give a dim effect in the entire screen.")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .showOverlay()
        .build()

You can also customize the overlay color using overlayColor() and also make the overlay block any click/touch events using overlayBlockable().

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show a modal overlay to give a dim effect in the entire screen.")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .showOverlay()
        .overlayColorRes(R.color.modal)
        .overlayBlockable()
        .build()

Actions

There are three types of action buttons available - primary (placed at the right side), positive and negative (placed at the bottom).

Primary

You can customize the primary action button's text color, size, typeface, appearance and also listen to its tap events.

The quickest way to show an action button is to put some text into it.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can click on the primary action button.")
        .primaryActionText("TRY NOW")
        .build()

You can also customize its appearance in a lot of ways,

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .message("You can click on the primary action button.")
        .primaryActionText("TRY")
        .primaryActionTextColorRes(R.color.colorAccent)
        .primaryActionTextSizeInSp(20f)
        .build()

You can also listen to its tap/click events through the OnActionTapListener,

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can click on the primary action button.")
        .primaryActionText("TRY")
        .primaryActionTapListener(object : Flashbar.OnActionTapListener {
            override fun onActionTapped(bar: Flashbar) {
                bar.dismiss()
            }
        })
        .build()

Positive/Negative

You can customize the positive and negative buttons in the same way as the primary button. These buttons appear at the bottom part of the view. You can show the positive, or negative or both the buttons. You can also listen to the tap events in the same way as before.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show either or both of the positive/negative buttons and customize them similar to the primary button.")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .positiveActionText("YES")
        .negativeActionText("NO")
        .positiveActionTextColorRes(R.color.colorAccent)
        .negativeActionTextColorRes(R.color.colorAccent)
        .positiveActionTapListener(object : Flashbar.OnActionTapListener {
            override fun onActionTapped(bar: Flashbar) {
                bar.dismiss()
            }
        })
        .negativeActionTapListener(object : Flashbar.OnActionTapListener {
            override fun onActionTapped(bar: Flashbar) {
                bar.dismiss()
            }
        })
        .build()

Icon & Progress

You can show icon (left) and progress bar (left or right) in the flashbar. You can also customize their look & feel in a lot of ways.

Icon

You can show an icon on the left side of the view using showIcon() which will show the default icon.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show a default icon on the left side of the withView")
        .showIcon()
        .build()

You can show any custom icon (drawable or bitmap) and apply color filters (change modes too) on it. You can also scale the icon up/down and specify scale type using the variants of showIcon(scale, scaleType).

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show a default icon on the left side of the withView")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .showIcon(0.8f, ScaleType.CENTER_CROP)
        .icon(R.drawable.ic_drop)
        .iconColorFilterRes(R.color.colorAccent)
        .build()

Progress

You might also want to show indeterminate progress bars to indicate that you are fetching some data, downloading a file, etc. The progress bar can be shown at either the left or the right hand side of the view.

Caveat: If the progress bar is shown on the left side, then you cannot show the icon with it. If the progress bar is shown on the right side, then you cannot show the action button along with it.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show the progress bar on either the left or right side of the view")
        .showProgress(Flashbar.ProgressPosition.LEFT)
        .build()

You can change the color of the progress bar to any color of your choice.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show the progress bar on either the left or right side of the view")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .showProgress(Flashbar.ProgressPosition.RIGHT)
        .progressTintRes(R.color.colorAccent)
        .build()

Animations

You can customize the enter/exit animation of the flashbar. You can also add custom animations to the icon for drawing attention towards it. The library provides a fluent API-styled animation framework to customize these animations.

Enter/Exit

You can start animating the bar using FlashAnim.with(this).animateBar(). You can change the duration of the animation using duration(), apply custom interpolators using interpolator() or choose from a set of interpolators available, add alpha transition using alpha(), etc.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can change the enter/exit animation of the flashbar")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .enterAnimation(FlashAnim.with(this)
                .animateBar()
                .duration(750)
                .alpha()
                .overshoot())
        .exitAnimation(FlashAnim.with(this)
                .animateBar()
                .duration(400)
                .accelerateDecelerate())
        .build()

You can also make the flashbar enter/exit from the left/right side of the screen,

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can change the enter/exit animation of the flashbar")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .enterAnimation(FlashAnim.with(this)
                .animateBar()
                .duration(400)
                .slideFromLeft()
                .overshoot())
        .exitAnimation(FlashAnim.with(this)
                .animateBar()
                .duration(250)
                .slideFromLeft()
                .accelerate())
        .build()

Note - You can configure the animations with your desired specifications in the builder and pass it on. You can not call build() on these animations as it is reserved to be used internally from inside the library only.

Icon

You can start animating the icon using FlashAnim.with(this).animateIcon(). You can change the duration of the animation using duration(), apply custom interpolators using interpolator() or choose from a set of interpolators available, add pulsating effect using pulse() and alpha transition using alpha(), etc.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can show a default icon on the left side of the with view.")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .showIcon()
        .icon(R.drawable.ic_drop)
        .iconColorFilterRes(R.color.colorAccent)
        .iconAnimation(FlashAnim.with(this)
                .animateIcon()
                .pulse()
                .alpha()
                .duration(750)
                .accelerate())
        .build()

Event Listeners

You can listen to events like when the flashbar is showing, or dismissing. You can also listen to progress updates when the flashbar is being shown or dismissed to perform animations on other views if needed.

You can also listen to tap events inside or outside the bar.

Show

You can listen to events on OnBarShowListener like onShowing, onShowProgress and onShown. The progress ranges from from 0.0 to 1.0. But in some special cases (like with bounce interpolator) it can go below 0.0 or above 1.0.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .title("Hello World!")
        .message("You can listen to events when the flashbar is shown")
        .barShowListener(object : Flashbar.OnBarShowListener {
            override fun onShowing(bar: Flashbar) {
                Log.d(TAG, "Flashbar is showing")
            }

            override fun onShowProgress(bar: Flashbar, progress: Float) {
                Log.d(TAG, "Flashbar is showing with progress: $progress")
            }

            override fun onShown(bar: Flashbar) {
                Log.d(TAG, "Flashbar is shown")
            }
        })
        .build()

Dismiss

You can listen to events on OnBarDismissListener like onDismissing, onDismissProgress and onDismissed. The progress ranges from from 0.0 to 1.0. But in some special cases (like with bounce interpolator) it can go below 0.0 or above 1.0.

You can also specifically get to know the reason behind the bar dismiss action - TIMEOUT, MANUAL, TAP_OUTSIDE and SWIPE.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .title("Hello World!")
        .duration(500)
        .message("You can listen to events when the flashbar is dismissed")
        .barDismissListener(object : Flashbar.OnBarDismissListener {
            override fun onDismissing(bar: Flashbar, isSwiped: Boolean) {
                Log.d(TAG, "Flashbar is dismissing with $isSwiped")
            }

            override fun onDismissProgress(bar: Flashbar, progress: Float) {
                Log.d(TAG, "Flashbar is dismissing with progress $progress")
            }

            override fun onDismissed(bar: Flashbar, event: Flashbar.DismissEvent) {
                Log.d(TAG, "Flashbar is dismissed with event $event")
            }
        })
        .build()

Taps

You can listen to tap events inside or outside of the bar.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can listen to tap events inside or outside te bar.")
        .listenBarTaps(object : Flashbar.OnTapListener {
            override fun onTap(flashbar: Flashbar) {
                Log.d(TAG, "Bar tapped")
            }
        })
        .listenOutsideTaps(object : Flashbar.OnTapListener {
            override fun onTap(flashbar: Flashbar) {
                Log.d(TAG, "Outside tapped")
            }
        })
        .build()

Miscellaneous

A quick look at some of the miscellaneous features available in flashbar.

Swipe-to-dismiss

You can enable this feature to dismiss the flashbar by swiping it left/right. By default this feature is disabled. You can also know if the bar was dismissed by a swipe from the DismissEvent as SWIPE.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.TOP)
        .title("Hello World!")
        .message("You can swipe the flasbar to dismiss it.")
        .enableSwipeToDismiss()
        .build() 

Shadow

You can show a synthetically generated shadow on the flashbar irrespective of its position - top or bottom. By default the shadow is always shown.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .title("Hello World!")
        .message("You can swipe the flashbar to dismiss it.")
        .castShadow(true, 4)
        .build()

Vibration

The flashbar can produce a short vibration to seek the attention of the user when it is shown, dismissed or both.

Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .title("Hello World!")
        .message("You can swipe the flashbar to dismiss it.")
        .vibrateOn(Flashbar.Vibration.SHOW, Flashbar.Vibration.DISMISS)
        .build()

Roadmap

These are some of the prioritized features in the pipeline awaiting to be implemented in the near future -

  • Add coordinator layout support
  • Add flashbar manager for queue management
  • Add custom layout inflation support
  • Improve shadow rendering

Contribution

I highly encourage the community to step forward and improve this library further. You can fix any reported bug, propose or implement new features, write tests, etc.

Here is a quick list of things to remember -

  • Check the open issues before creating a new one,
  • Help me in reducing the number of open issues by fixing any existing bugs,
  • Check the roadmap to see if you can help in implementing any new feature,
  • You can contribute by writing unit and integration tests for this library,
  • If you have any new idea that aligns with the goal of this library, feel free to raise a feature request and discuss it.

About The Author

Aritra Roy

Design-focussed Engineer. Full-stack Developer. Hardcore Android Geek. UI/UX Designer. Part-time Blogger.

License

Copyright 2016 aritraroy

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.

flashbar's People

Contributors

apan1000 avatar aritraroy avatar elek90 avatar skadyrov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flashbar's Issues

Add buttons for samples in sample app

It would be nice to have a list of all the various types of customisations available as a list of buttons for hiding/showing, similar to this

Bonus: publish the sample to the play store so that we don't need to clone/build the project :)

Shows under dialog fragment

when i use flash bar in a dialogFragment the flashbar displays under the dialog fragment. i pass the dialogFragment's activity to flash bar.

Cannot immediately dismiss Flashbar instance

Consider this code:

class MainActivity : AppCompatActivity() {

    var flashbar : Flashbar? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        setupFlashbar()
    }

    override fun onStart() {
        super.onStart()

        flashbar?.show()
        flashbar?.dismiss()
    }

    fun setupFlashbar() {
        flashbar = Flashbar.Builder(this)
                .message("Test")
                .gravity(Flashbar.Gravity.BOTTOM)
                .build()
    }
}

If you run it, you'll see that flashbar is still shown, regardless of flashbar?.dismiss() being called.
I'm not sure if this is a bug, since method isShowing() is provided so case like that was considered. If so, please add something like onFlashbarShown interface so it's possible to make sure that flashbar is dismissed.

Thanks for reading this. The library is great ♥

Icons on android 5.0

When I add icons as drawables to flashbar i can see only white shapes of icons.

Suggestion isShowing misleading name

Hi. First of all, I love Flashbar. You did a great job there.

I would like to make one suggestion. I think Flashbar.isShowing() is a bit misleading. You use it as an opposition to Flashbar.isDismissing().
Consider using the name Flashbar.isAppearing() or Flashbar.isEmerging() instead. It represents its functionality in a better way.
Flashbar.isShowing() should substitute Flashbar.isShown() in my opinion.

Hope you take it into consideration.
Cheers.

Using Flashbar in java-only projects requires kotlin-stdlib dependency

Not sure if this is by design, but using Flashbar in my non-kotlin enabled Android project resulted in an immediate crash on application run with a ClassNotFoundException. I had to add the kotlin-stdlib dependency to my app gradle in order to get it working.

Would be nice if there was a way around that.

crash in android P

use simple example but have this error :
E/TypefaceCompatApi21Impl: java.lang.NoSuchMethodException java.lang.NoSuchMethodException: addFontWeightStyle [class java.lang.String, int, boolean]

i think you use hide method and this not allow in android P
this is my example:

    Flashbar flashbar = new Flashbar.Builder(this)
            .message(R.string.str_start_sync)
            .gravity(Flashbar.Gravity.BOTTOM)
            .showProgress(Flashbar.ProgressPosition.LEFT)
            .build();
    flashbar.show();

One Bar at a time

Is there a way to make sure i only have one bar showing at any given moment ?

Not working on Oreo

it crashes upon showing the first message

this is the code in a default method in an interface (implemented by Activities) :

default void showToast(String title, String details){
new Flashbar.Builder((Activity)this)
.enableSwipeToDismiss()
.dismissOnTapOutside()
.duration(3000)
.gravity(Flashbar.Gravity.TOP)
.title(title)
.message(details)
.build()
.show();
}

this is the stack trace :

W/StaticLayout: maxLineHeight should not be -1. maxLines:1 lineCount:1
2019-06-25 03:54:13.941 W/System.err: io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.AbstractMethodError: abstract method "void com.cuboh.mobile.presentation.core.behaviors.CustomToasts.showToast(java.lang.Throwable)"
2019-06-25 03:54:13.942 W/System.err: at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
2019-06-25 03:54:13.942 W/System.err: at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:126)
2019-06-25 03:54:13.942 W/System.err: at android.os.Handler.handleCallback(Handler.java:793)
2019-06-25 03:54:13.942 W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2019-06-25 03:54:13.942 W/System.err: at android.os.Looper.loop(Looper.java:176)
2019-06-25 03:54:13.943 W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6701)
2019-06-25 03:54:13.943 W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2019-06-25 03:54:13.943 W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249)
2019-06-25 03:54:13.943 W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
2019-06-25 03:54:13.943 W/System.err: Caused by: java.lang.AbstractMethodError: abstract method "void com.cuboh.mobile.presentation.core.behaviors.CustomToasts.showToast(java.lang.Throwable)"
2019-06-25 03:54:13.943 W/System.err: at com.cuboh.mobile.presentation.features.main.-$$Lambda$NO1rDPnH-993Pc6JvEqcyiJesow.accept(Unknown Source:4)
2019-06-25 03:54:13.944 W/System.err: at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
2019-06-25 03:54:13.944 W/System.err: at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
2019-06-25 03:54:13.944 W/System.err: at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
2019-06-25 03:54:13.944 W/System.err: at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
2019-06-25 03:54:13.944 W/System.err: ... 7 more

Initialization for a style guide

Would recommend having a way of initializing the library once by passing a config object and then the same Flashbar object be used. When you pass the config object, it creates an immutable version of a Flashbar which gets cloned every time you try to customize it further.

This basically allows someone to initialize the Flashbar once based on their own style guide and then keep reusing that configuration.

Varun

Legacy support to AndroidX migration

Cheers! For the great library @aritraroy

It seems library still needs legacy support libraries, Do you have any plans for the androidX migration as such also seen that it is not available on maven?

Can we expect updates in future ? Or library is dead and no more updates can be expected in future.....

Looking forward to hear from you!

Text Position

Hello, Great library guys thank you.
am having a problem with text position inside the Flashbar,
I've tried to set the .titleAppearance() and .messageAppearance() to center or right it did not work.
is there any solution to this?

You cannot download the library with its correction CommonUtils.kt

internal fun Activity.getStatusBarHeightInPx(): Int {
val rectangle = Rect()

window.decorView.getWindowVisibleDisplayFrame(rectangle)

val statusBarHeight = rectangle.top
val contentViewTop = window.findViewById<View>(Window.ID_ANDROID_CONTENT).top
return if (contentViewTop == 0) { //Actionbar is not present
    statusBarHeight
} else {
    contentViewTop - statusBarHeight
}

}

Unwanted Bottom Margin on Oneplus Devices

There's an unwanted bottom margin added to the flashbar on Oneplus Devices.

I tested it out on emulator running on Pie and it works fine.

But on Oneplus 6 running on Pie it adds an unwanted bottom margin as you can see in this picture.

Screenshot of Unwanted Bottom Margin to Flashbar

Unable to use DURATION_INDEFINITE

I'm unable to set indefinite duration for the flashbar message by using Flashbar.DURATION_INDEFINITE.

I get the following error:

Duration cannot be negative or zero

Please make changes in the code regarding this and allow an exception for Flashbar.DURATION_INDEFINITE

Problem with NoActionBar bar activity

Hi, I tried to use this in my new app and it's working fine but when I used this with a no NoActionBar activity it's not showing properly on Flashbar.Gravity.TOP

This is my code which I am writing

Flashbar.Builder builder = new Flashbar.Builder(activity) .gravity(gravity) .title(title) .message(body) .enableSwipeToDismiss() .backgroundColorRes(R.color.colorPrimarylight) .enterAnimation(FlashAnim.with(activity) .animateBar() .duration(Flashbar.DURATION_SHORT) .alpha() .overshoot()); _flashBar=builder.build();

This is the preview of the problem

untitled

What should I do ?

New message will override old one if send together

Case: If I send 2 or more message in just one seconds and time to display one individual message is 2 seconds. Than the new one will override the previous one. Any way that new message will appear after old one is gone.

Position issue?

Hello,

Great work guys!

Is there ia issue with the TOP positioning or is just me?

image

Input dialog

Add an EditText to the Flashbar dialog for taking input from users.

Allow this EditText to be customizable to accept both plain text(one-line and multiline) and passwords.

This dialog can be used as an input dialog box.

The action button gets hidden under navigation bar on Tablet Devices using `Flashbar.Gravity.BOTTOM`

Summary

The action button gets hidden under the navigation bar when used in tablets, making them untapable.

  • Library Version Tested: 1.0.1 and 1.0.2
  • OS Version: 6.0.1, 7.1.1 (Used emulator)

Screencast

screencapture-1526087965459

Code Used

flashbar = Flashbar.Builder(this)
        .gravity(Flashbar.Gravity.BOTTOM)
        .title("Title")
        .message("Message")
        .backgroundColorRes(R.color.colorPrimaryDark)
        .positiveActionText(R.string.btn_cta_preceed)
        .negativeActionText(R.string.btn_cta_okay)
        .positiveActionTextColorRes(R.color.colorAccent)
        .negativeActionTextColorRes(R.color.colorAccent)
        .positiveActionTapListener(object : Flashbar.OnActionTapListener {
            override fun onActionTapped(bar: Flashbar) {
                bar.dismiss()
            }
        })
        .negativeActionTapListener(object : Flashbar.OnActionTapListener {
            override fun onActionTapped(bar: Flashbar) {
                bar.dismiss()
            }
        })
        .build()

Flutter version of Flashbar

Hi @aritraroy. I passing by to let you know that I liked the idea so much that I'm developing a Flutter version of Flashbar: Flushbar.
It is still in early stages though. I hope I can make something as good as Flashbar. If you want to check it out, Flushbar.

Cheers!

Enhacement

hi, how are you guys, thanks for this fantastic library.

just want to know if there is a chance to add a feature so that the user will see the flashbar after some opportunities like after 3 launches of the app or 3 days, and once he clicked the positive button the FlashBar will never been shown again.

otherwise. your app is greeeeeat

Overlay Animation?

Using the overlay feature is cool, but the abrupt-ness of its appearance/disappearance doesn't match well with the rest of my UI. Is it possible to add fade-in/fade-out animations to the overlay's appearance/disappearance?

Duration issues.

The duration seems to get confused when dismissing the flash bar and opening one up again right afterwards.

Button on screen that fires the flash bar .show();

Showing flash bar with duration 5000 and positive button "dismiss"

Tapping on dismiss then quickly pressing the button to show another one

The flash bar closes before 5 seconds has elapsed. Presumably using the time from the first flash bar. Ideally this timer would get reset when the flash bar is dismissed.

Top and Bottom Margin

Hello,

Is there a way to add a top or bottom margin to the Flashbar view? It always stick to top or bottom, I tried changing fb_bottom_compensation_margin to a negative value, it works but the content does't go up with the view.

Thanks.

Failed to resolve

when i try to add it to gradle
this message appear
Failed to resolve: com.andrognito.flashbar:flashbar:1.0.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.