Coder Social home page Coder Social logo

edward7zhang / morphing-material-dialogs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aditya94a/morphing-material-dialogs

0.0 2.0 0.0 836 KB

Material dialog meets morphing animation

Home Page: http://adityaanand.in

License: MIT License

Java 100.00%

morphing-material-dialogs's Introduction

Morphing Material Dialogs

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. 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.1-alpha2'
	}

Since we'll be morphing a floating action button into a dialog, you should also have the design support library:

	dependencies {
   		implementation "com.android.support:design:26.01"
	}

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="in.adityaanand.morphdialog.MorphDialogActivity"
       android:theme="@style/MorphDialog.Custom.Light">
   </activity>
   <activity
       android:name="in.adityaanand.morphdialog.MorphDialogActivityDark"
       android:theme="@style/MorphDialog.Custom.Dark">
   </activity>

Usage instructions

This library mirror's a subset of afollestad/material-dialogs API. Currently, you can specify the title, content, positive button text and negative button text (all as CharSequences or string resource IDs).

new MorphDialog.Builder(this, fabView)
               .title("Title")
               .content("This is a sentence. Here is another one.") 
               .positiveText(R.string.ok)
               .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();
    }

Misc

P.S: We're at v0.0.1-alpha2 pre-release. Except things to change and break and evolve :)

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?

Doing so will mean that this library would have to duplicate the entire API of MaterialDialogs. I'm currently looking for a cleaner and leaner alternative to accomplishing this (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 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 and check out the minimal implementation that will point you in the direction of a custom solution. Although, I'm certainly open to all ideas, including turning this into a generic morph-anything-to-anything library but doing so may or may not even be possible. Suggestions welcome

morphing-material-dialogs's People

Watchers

 avatar  avatar

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.