All Projects → AdityaAnand1 → Morphing Material Dialogs

AdityaAnand1 / Morphing Material Dialogs

Licence: mit
Material dialog ❤️ morphing animation. An android kotlin UI library for building beautiful animations for converting a floating action button into a material dialog.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Morphing Material Dialogs

Mediapicker
Easy customizable picker for all your needs in Android application
Stars: ✭ 105 (-86.97%)
Mutual labels:  android-app, material-design, android-application, android-sdk, android-ui
Ibackdrop
A library to simply use Backdrop in your project (make it easy). Read more ->
Stars: ✭ 137 (-83%)
Mutual labels:  android-app, material-design, android-application, android-sdk, android-ui
Android-daily-read-tips
log for articles and info in android for every developer
Stars: ✭ 13 (-98.39%)
Mutual labels:  android-sdk, android-application, android-ui, android-app
Android Inappbilling
A sample which uses Google's Play Billing Library and it does InApp Purchases and Subscriptions.
Stars: ✭ 114 (-85.86%)
Mutual labels:  android-app, android-application, android-sdk, android-ui
Shotang App
The New Home Screen is designed in a modular way with the core focus on product discovery. Search, Deals, Products everything has been brought upfront. The hamburger menu has been replaced with a bottom navigation bar for easy reachability. On the tech side too, this design allows us to run new deals and other experiments in an agile manner which wasn't possible in the previous version.
Stars: ✭ 132 (-83.62%)
Mutual labels:  android-app, material-design, android-application, android-ui
Androidkex
Extensions for Kotlin. Use the power of Kotlin to make your code smaller and beautiful.
Stars: ✭ 35 (-95.66%)
Mutual labels:  android-app, android-application, android-sdk, android-ui
Datingapp
Dating UI kit is used for online meet up with girls and boys . The screen contains more than 30 icons and most of all required elements required to design an application like this. The XML and JAVA files contains comments at each and every point for easy understanding. Everything was made with a detail oriented style and followed by today's web trends. Clean coded & Layers are well-organized, carefully named, and grouped.
Stars: ✭ 97 (-87.97%)
Mutual labels:  android-app, material-design, android-application, android-ui
Music Player Go
🎶🎼 Very slim music player 👨‍🎤 100% made in Italy 🍕🌳🌞🍝🌄
Stars: ✭ 654 (-18.86%)
Mutual labels:  android-app, material-design, android-application, android-ui
Modern Android Development
Modern Android Development tools & key points
Stars: ✭ 219 (-72.83%)
Mutual labels:  android-app, android-application, android-sdk, android-ui
Bottomsheet
BottomSheet dialog library for Android
Stars: ✭ 219 (-72.83%)
Mutual labels:  android-app, material-design, android-application, android-ui
Android Arsenal.com
Source to android-arsenal.herokuapp.com
Stars: ✭ 541 (-32.88%)
Mutual labels:  android-app, android-application, android-sdk, android-ui
CustomFontView
Custom View classes for TextView, EditText & Buttons - to set custom fonts
Stars: ✭ 26 (-96.77%)
Mutual labels:  android-sdk, android-application, android-ui, android-app
Cameraxdemo
A sample camera app with CameraX API from Android Jetpack
Stars: ✭ 112 (-86.1%)
Mutual labels:  android-app, android-application, android-sdk, android-ui
Awesomedialog
A Beautiful Dialog Library for Kotlin Android
Stars: ✭ 163 (-79.78%)
Mutual labels:  android-app, material-design, android-sdk, android-ui
media-picker
Easy customizable picker for all your needs in Android application
Stars: ✭ 167 (-79.28%)
Mutual labels:  android-sdk, android-application, android-ui, android-app
Motiontoast
🌈 A Beautiful Motion Toast Library for Kotlin Android
Stars: ✭ 767 (-4.84%)
Mutual labels:  android-app, material-design, android-sdk, android-ui
PlantShopUI-Android
Check out the new style for App Design aims for the Online Plant Shop Service using jetpack compose...😉😀😁😎
Stars: ✭ 29 (-96.4%)
Mutual labels:  android-application, android-ui, android-app
FutureFurnitureUI-Android
Check out the new style for App Design aims for Furniture E-commerce...😉😀😁😎
Stars: ✭ 117 (-85.48%)
Mutual labels:  android-application, android-ui, android-app
Quill
👻 [MOVED TO https://github.com/TryGhost/Ghost-Android] The beautiful Android app for your Ghost blog.
Stars: ✭ 552 (-31.51%)
Mutual labels:  android-app, material-design, android-application
Superbottomsheet
Android native BottomSheet on steroids 💪
Stars: ✭ 548 (-32.01%)
Mutual labels:  android-app, android-application, android-ui

Morphing Material Dialogs

Release Build Status GitHub license

A library for fab-to-dialog morphing (as in Nick Butcher's Plaid) with Aidan Follestad's Material Dialogs.

Table of Contents

  1. Setup Instructions
  2. Usage Instructions
  3. Customization
  4. Misc

Setup Instructions

Add the following to your root (project) level build.gradle:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Add the library to your app's build.gradle

	dependencies {
		implementation 'com.github.AdityaAnand1:Morphing-Material-Dialogs:0.0.3'
		//you should also have the design support library, since we're using the native floating action button
   		implementation "com.android.support:design:27.0.2"
	}

In your styles.xml, override the MorphDialog.Base themes (at least one, both if you wish to support light and dark themes for your app)

    <style name="MorphDialog.Custom.Light" parent="MorphDialog.Base.Light">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/accent</item>
    </style>

    <style name="MorphDialog.Custom.Dark" parent="MorphDialog.Base.Dark">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/accent</item>
    </style>

In your app's manifest file, add the following (at least one, both if you wish to support light and dark themes for your app)

   <activity
       android:name="com.adityaanand.morphdialog.MorphDialogActivity"
       android:theme="@style/MorphDialog.Custom.Light">
   </activity>
   <activity
       android:name="com.adityaanand.morphdialog.MorphDialogActivityDark"
       android:theme="@style/MorphDialog.Custom.Dark">
   </activity>

Usage instructions

This library mirror's a subset of afollestad/material-dialogs API.

new MorphDialog.Builder(this, fabView)
               .title("Title")
               .content("This is a sentence. Here is another one.") 
               .positiveText(R.string.ok)
               .onPositive((MorphDialog dialog1, MorphDialogAction which) -> {
                   Toast.makeText(this, "onPositive", Toast.LENGTH_SHORT).show();
               })
               .useDarkTheme(true) //optional, default is false
               .show();

For example, if you have a floating action button in your activity

       <android.support.design.widget.FloatingActionButton
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:onClick="morph"/>

Then your morph() might look like:

    public void morph(View view) {
        new MorphDialog.Builder(this, (FloatingActionButton) view)
                .title("Title")
                .content("This is a sentence. Here is another one.")
                .show();
    }

Customization

Listen for action button callbacks

MorphDialog is not a dialog. It's another activity and the only way to get back the result of any interactions with it is through onActivityResult().

In order to use the .onPositive(), .onNegative(), .onNeutral or .onAny() callbacks, you must pass on the activity result to the morphDialog object. You must do this for each dialog that you are using individually.

    MorphDialog dialog1;
    MorphDialog dialog2;
    
    void buildDialog(){
     dialog1 = new MorphDialog.Builder(this, (FloatingActionButton) view)
                .title("Title")
                .content("This is a sentence. Here is another one.")
                .positiveText(R.string.ok)
                .negativeText("Cancel")
                .neutralText("More")
                .onPositive((MorphDialog dialog1, MorphDialogAction which) -> {
                    Toast.makeText(this, "onPositive", Toast.LENGTH_SHORT).show();
                })
                .onNegative((MorphDialog dialog1, MorphDialogAction which) -> {
                    Toast.makeText(this, "onNegative", Toast.LENGTH_SHORT).show();
                })
                .onNeutral((MorphDialog dialog1, MorphDialogAction which) -> {
                    Toast.makeText(this, "onNeutral", Toast.LENGTH_SHORT).show();
                })
                .build();
	}
	
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        dialog1.onActivityResult(requestCode, resultCode, data);
        dialog2.onActivityResult(requestCode, resultCode, data);
    }

If you have a large number of dialogs you may prefer to use the helper function instead, which uses a varargs parameter to register the callback to multiple dialog objects:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
	MorphDialog.registerOnActivityResult(requestCode, resultCode, data, dialog1, dialog2, dialog3);
    }

Also, note that you will receive the callbacks only after the animation has ended.

Set Canceleable

If you do not want the dialog to close when tapping outside the dialog you can use builder.cancelable(false)

Customize Colors

The following methods can be used to customize the different colors in your dialog

new MorphDialog.Builder(context, (FloatingActionButton) view)
                .contentColor(Color.BLUE)
                .backgroundColor(Color.GREEN)
                .neutralColorRes(R.color.primary)
                .positiveColor(Color.BLACK)
                .titleColor(Color.YELLOW);

Theme overrides

Override the android:windowBackground attribute to provide a custom color for the area outside of the dialog.

    <style name="MorphDialog.Custom.Light" parent="MorphDialog.Base.Light">
        <item name="android:windowBackground">@color/windowBackground</item>
    </style>

Misc

What happens below API 21 (<Lollipop)?

Nothing. Since this library uses activity transitions which are properly supported only for Lollipop and up, the dialog pops up normally without any morphing animation below Lollipop.

Why does the library not support all of Material Dialogs features?

The problem is passing the instructions to build a MaterialDialog (i.e,a MaterialDialog.Builder object) to another activity. The Builder class is not Parcelable and contains a lot of context aware fields like custom views. In the current architecture, there's no clear path to doing this without explicitly adding memory leaks. (Suggestions welcome)

I want to morph from something other than a fab/ I want to morph to something other than MorphDialog

Currently, this library does not support morphing something-other-than-a-fab to something-other-than-a-material-dialog transition. If you'd like for it to work in another setting, say a custom view, head over to the standalone module and check out the minimal implementation (without all the library plumbing) that should point you in the direction of a custom solution.


Fun fact: This library was originally built for Timbre.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].