{"id":15040792,"url":"https://github.com/aditya94a/morphing-material-dialogs","last_synced_at":"2025-04-04T07:07:42.306Z","repository":{"id":48490981,"uuid":"100109717","full_name":"Aditya94A/Morphing-Material-Dialogs","owner":"Aditya94A","description":"Material dialog :heart: morphing animation. An android kotlin UI library for building beautiful animations for converting a floating action button into a material dialog.","archived":false,"fork":false,"pushed_at":"2021-07-22T23:14:45.000Z","size":7838,"stargazers_count":894,"open_issues_count":6,"forks_count":64,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-10-30T05:57:40.238Z","etag":null,"topics":["android","android-app","android-application","android-sdk","android-ui","material-design"],"latest_commit_sha":null,"homepage":"https://adi.bio","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aditya94A.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-12T12:03:04.000Z","updated_at":"2024-08-16T06:13:41.000Z","dependencies_parsed_at":"2022-09-10T09:22:30.046Z","dependency_job_id":null,"html_url":"https://github.com/Aditya94A/Morphing-Material-Dialogs","commit_stats":null,"previous_names":["adityaanand1/morphing-material-dialogs"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aditya94A%2FMorphing-Material-Dialogs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aditya94A%2FMorphing-Material-Dialogs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aditya94A%2FMorphing-Material-Dialogs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aditya94A%2FMorphing-Material-Dialogs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aditya94A","download_url":"https://codeload.github.com/Aditya94A/Morphing-Material-Dialogs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135144,"owners_count":20889421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-app","android-application","android-sdk","android-ui","material-design"],"created_at":"2024-09-24T20:45:04.877Z","updated_at":"2025-04-04T07:07:42.285Z","avatar_url":"https://github.com/Aditya94A.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"screenies/1.gif\" width=\"300\" align=\"right\" hspace=\"20\"\u003e\n\n# Morphing Material Dialogs\n[![Release](https://jitpack.io/v/AdityaAnand1/Morphing-Material-Dialogs.svg)](https://jitpack.io/#AdityaAnand1/Morphing-Material-Dialogs)\n[![Build Status](https://travis-ci.org/AdityaAnand1/Morphing-Material-Dialogs.svg)](https://travis-ci.org/AdityaAnand1/Morphing-Material-Dialogs)\n[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/AdityaAnand1/Morphing-Material-Dialog/blob/master/LICENSE.txt)\n\n\n\nA library for fab-to-dialog morphing (as in Nick Butcher's [Plaid](https://github.com/nickbutcher/plaid)) with Aidan Follestad's [Material Dialogs](https://github.com/afollestad/material-dialogs).\n\n# Table of Contents\n1. [Setup Instructions](https://github.com/AdityaAnand1/Morphing-Material-Dialogs#setup-instructions)\n2. [Usage Instructions](https://github.com/AdityaAnand1/Morphing-Material-Dialogs#usage-instructions)\n3. [Customization](https://github.com/AdityaAnand1/Morphing-Material-Dialogs#customization)\n4. [Misc](https://github.com/AdityaAnand1/Morphing-Material-Dialogs#misc)\n\n## Setup Instructions\n\n Add the following to your root (project) level build.gradle:\n\n```gradle\n\tallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url 'https://jitpack.io' }\n\t\t}\n\t}\n```\n\nAdd the library to your app's build.gradle\n\n```gradle\n\tdependencies {\n\t\timplementation 'com.github.AdityaAnand1:Morphing-Material-Dialogs:0.0.3'\n\t\t//you should also have the design support library, since we're using the native floating action button\n   \t\timplementation \"com.android.support:design:27.0.2\"\n\t}\n```\n\nIn your styles.xml, override the MorphDialog.Base themes (at least one, both if you wish to support light and dark themes for your app)\n\n```xml\n    \u003cstyle name=\"MorphDialog.Custom.Light\" parent=\"MorphDialog.Base.Light\"\u003e\n        \u003citem name=\"colorPrimary\"\u003e@color/primary\u003c/item\u003e\n        \u003citem name=\"colorPrimaryDark\"\u003e@color/primary_dark\u003c/item\u003e\n        \u003citem name=\"colorAccent\"\u003e@color/accent\u003c/item\u003e\n    \u003c/style\u003e\n\n    \u003cstyle name=\"MorphDialog.Custom.Dark\" parent=\"MorphDialog.Base.Dark\"\u003e\n        \u003citem name=\"colorPrimary\"\u003e@color/primary\u003c/item\u003e\n        \u003citem name=\"colorPrimaryDark\"\u003e@color/primary_dark\u003c/item\u003e\n        \u003citem name=\"colorAccent\"\u003e@color/accent\u003c/item\u003e\n    \u003c/style\u003e\n ```\n \n 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)\n \n ```xml\n    \u003cactivity\n        android:name=\"com.adityaanand.morphdialog.MorphDialogActivity\"\n        android:theme=\"@style/MorphDialog.Custom.Light\"\u003e\n    \u003c/activity\u003e\n    \u003cactivity\n        android:name=\"com.adityaanand.morphdialog.MorphDialogActivityDark\"\n        android:theme=\"@style/MorphDialog.Custom.Dark\"\u003e\n    \u003c/activity\u003e\n ```\n \n ## Usage instructions\n \nThis library mirror's a subset of [afollestad/material-dialogs](https://github.com/afollestad/material-dialogs) API.\n  \n ```java\n new MorphDialog.Builder(this, fabView)\n                .title(\"Title\")\n                .content(\"This is a sentence. Here is another one.\") \n                .positiveText(R.string.ok)\n                .onPositive((MorphDialog dialog1, MorphDialogAction which) -\u003e {\n                    Toast.makeText(this, \"onPositive\", Toast.LENGTH_SHORT).show();\n                })\n                .useDarkTheme(true) //optional, default is false\n                .show();\n ```\n \n \nFor example, if you have a floating action button in your activity\n \n ```xml\n        \u003candroid.support.design.widget.FloatingActionButton\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:onClick=\"morph\"/\u003e\n```\n\nThen your `morph()` might look like:\n\n```java\n    public void morph(View view) {\n        new MorphDialog.Builder(this, (FloatingActionButton) view)\n                .title(\"Title\")\n                .content(\"This is a sentence. Here is another one.\")\n                .show();\n    }\n```\n\n## Customization\n\n### Listen for action button callbacks\n\nMorphDialog 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()`.\n\nIn 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.\n\n```\n    MorphDialog dialog1;\n    MorphDialog dialog2;\n    \n    void buildDialog(){\n     dialog1 = new MorphDialog.Builder(this, (FloatingActionButton) view)\n                .title(\"Title\")\n                .content(\"This is a sentence. Here is another one.\")\n                .positiveText(R.string.ok)\n                .negativeText(\"Cancel\")\n                .neutralText(\"More\")\n                .onPositive((MorphDialog dialog1, MorphDialogAction which) -\u003e {\n                    Toast.makeText(this, \"onPositive\", Toast.LENGTH_SHORT).show();\n                })\n                .onNegative((MorphDialog dialog1, MorphDialogAction which) -\u003e {\n                    Toast.makeText(this, \"onNegative\", Toast.LENGTH_SHORT).show();\n                })\n                .onNeutral((MorphDialog dialog1, MorphDialogAction which) -\u003e {\n                    Toast.makeText(this, \"onNeutral\", Toast.LENGTH_SHORT).show();\n                })\n                .build();\n\t}\n\t\n    \n    @Override\n    protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n        super.onActivityResult(requestCode, resultCode, data);\n        dialog1.onActivityResult(requestCode, resultCode, data);\n        dialog2.onActivityResult(requestCode, resultCode, data);\n    }\n```\n\nIf 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:\n\n```\n    @Override\n    protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n        super.onActivityResult(requestCode, resultCode, data);\n\tMorphDialog.registerOnActivityResult(requestCode, resultCode, data, dialog1, dialog2, dialog3);\n    }\n```\n\nAlso, note that you will receive the callbacks only after the animation has ended. \n\n### Set Canceleable\n\nIf you do not want the dialog to close when tapping outside the dialog you can use `builder.cancelable(false)`\n\n### Customize Colors\n\nThe following methods can be used to customize the different colors in your dialog\n```\nnew MorphDialog.Builder(context, (FloatingActionButton) view)\n                .contentColor(Color.BLUE)\n                .backgroundColor(Color.GREEN)\n                .neutralColorRes(R.color.primary)\n                .positiveColor(Color.BLACK)\n                .titleColor(Color.YELLOW);\n```\n\n### Theme overrides\n\nOverride the `android:windowBackground` attribute to provide a custom color for the area outside of the dialog.\n\n```\n    \u003cstyle name=\"MorphDialog.Custom.Light\" parent=\"MorphDialog.Base.Light\"\u003e\n        \u003citem name=\"android:windowBackground\"\u003e@color/windowBackground\u003c/item\u003e\n    \u003c/style\u003e\n```\n\n\n## Misc\n\n#### What happens below API 21 (\u003cLollipop)?\n\nNothing. 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.\n\n#### Why does the library not support all of Material Dialogs features?\n\nThe 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](https://github.com/AdityaAnand1/Morphing-Material-Dialogs/issues/new))\n\n#### I want to morph **from something other than a fab**/ I want to morph **to something other than MorphDialog**\n\nCurrently, 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](https://github.com/AdityaAnand1/Morphing-Material-Dialogs/tree/master/standalone) module and check out the minimal implementation (without all the library plumbing) that should point you in the direction of a custom solution.\n\n----\n\nFun fact: This library was originally built for [Timbre](https://play.google.com/store/apps/details?id=xeus.timbre).\n\n\u003cimg src=\"screenies/timbre.gif\" width=\"300\" hspace=\"20\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faditya94a%2Fmorphing-material-dialogs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faditya94a%2Fmorphing-material-dialogs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faditya94a%2Fmorphing-material-dialogs/lists"}