Synth is CRED's inbuilt library for using Neumorphic components in your app.

Overview

Synth

Synth is CRED's inbuilt library for using Neumorphic components in your app.

What really is Neumorphism? It's an impressionistic style, playing with light, shadow, and depth to create a digital experience inspired by the physical world. That's the definition anyway. Our recommendation is you try it out to see what you make of it. If you do create something with Synth, let us know. We're excited to see where you take it.

A note for the curious: if you wish to learn more about Synth, we have a post detailing the concept and CRED's philosophy behind it here.

For iOS, checkout Synth-iOS

Banner

Install

You can install synth by adding this to your build.gradle file:

dependencies {
  implementation 'club.cred.android:synth:1.0.0'
}

Usage & SDK Limitations

To use synth, the parent layout which contains the synth views must specify:

android:clipChildren="false"

Synth renders neumorphic components only on devices running API 28 (Pie) or later. This is because Synth internally uses BlurMaskFilter to render shadows and highlights which are drawn outside of the view bounds — this allows you to align Synth views with other views easily.

The issue below API 28, is, to make BlurMaskFilter work, we need to use hardware acceleration on the view which causes the shadows and highlights to be clipped. We could solve for this by adding padding to the views (similar to how CardView does it) but chose not to because of alignment issues.

In lieu of this, we decided to introduce "compat" version of all our views which render a simple single colored background on the view on devices below API 28.

Buttons

Soft button

Soft Button

Soft button renders the elevated neumorphic platform on which the text is drawn. this elevated platform can be customized in two ways:

  1. By specifying a color for the platform, synth will attempt to compute the light and dark shadow colors
<club.cred.synth.views.SynthButton
    app:neuButtonType="elevated_soft"
    app:neuPlatformColor="@color/button_platform_color"
    ... />
  1. By specifying a complete appearance for all aspects of the elevated platform
<club.cred.synth.views.SynthButton
    app:neuButtonType="elevated_soft"
    ... />
    
<style name="button_platform_appearance">
    <item name="neuLightShadowColor">...</item>
    <item name="neuDarkShadowColor">...</item>
    <item name="neuFillStartColor">...</item>
    <item name="neuFillEndColor">...</item>
    <item name="neuFillPressedStartColor">...</item>
    <item name="neuFillPressedEndColor">...</item>
    <item name="neuBorderStartColor">...</item>
    <item name="neuBorderEndColor">...</item>
    <item name="neuBorderPressedStartColor">...</item>
    <item name="neuBorderPressedEndColor">...</item>
</style>

Flat button

Flat Button

Flat button renders a flat surface on top of the elevated neumorphic platform. This flat surface can be customized in two ways:

  1. By specifying a color for the surface, synth will attempt to compute the gradients, borders, etc of the surface
<club.cred.synth.views.SynthButton
    app:neuButtonType="elevated_flat"
    app:neuFlatButtonColor="@colo/button_surface_color"
    app:neuPlatformAppearance="@style/button_platform_appearance" 
    ... />
  1. By specifying a complete appearance for all aspects of the flat surface
<club.cred.synth.views.SynthButton
    app:neuButtonType="elevated_flat"
    app:neuFlatButtonAppearance="@style/button_flat_appearance"
    
    app:neuPlatformAppearance="@style/button_platform_appearance" 
    ... />
    
<style name="button_flat_appearance">
    <item name="neuButtonStartColor">...</item>
    <item name="neuButtonEndColor">...</item>
    <item name="neuButtonBorder1StartColor">...</item>
    <item name="neuButtonBorder1EndColor">...</item>
    <item name="neuButtonBorder2StartColor">...</item>
    <item name="neuButtonBorder2EndColor">...</item>
    <item name="neuButtonPressedDarkShadowColor">...</item>
</style>

Image button

Image Button

Image button is simply an image view with a neumorphic platform

<club.cred.synth.views.SynthImageButton
    app:neuButtonType="elevated_soft"
    app:srcCompat="@drawable/ic_chevron_left"
    ... />

Adding drawable to buttons

Drawable Button

You can add a drawable to a button (to the left of the text). Synth will render a neumorphic pit on which the drawable is rendered. This pit can be customized in two ways:

  1. By not specifying anything, synth will take either the neuPlatformColor (if it's a soft button) or neuFlatButtonColor (if it's a flat button) and compute the gradient colors and pressed colors.
<club.cred.synth.views.SynthButton
    app:neuButtonType="elevated_soft"
    app:neuButtonDrawable="@drawable/ic_plus"
    app:neuButtonDrawablePitRadius="20dp"
    
    app:neuPlatformColor="@color/button_platform_color"
    .. or ..
    app:neuFlatButtonColor="@color/button_surface_color"
    ... />
  1. By specifying a complete appearance for all aspects of the icon pit
<club.cred.synth.views.SynthButton
    app:neuButtonType="elevated_flat"
    app:neuButtonDrawable="@drawable/ic_plus"
    app:neuButtonDrawablePitRadius="20dp"
    
    app:neuButtonIconAppearance="@style/button_icon_appearance"
    ... />
    
<style name="button_icon_appearance">
    <item name="neuFillStartColor">...</item>
    <item name="neuFillEndColor">...</item>
    <item name="neuFillPressedStartColor">...</item>
    <item name="neuFillPressedEndColor">...</item>
    <item name="neuButtonCompatColor">...</item>
</style>

All button attributes

Attribute Description Value
app:neuButtonType type of the button elevated_flat or elevated_soft
app:neuButtonRadius corner radius of button dimension
app:neuPlatformColor color of neumorphic platform color
app:neuPlatformAppearance appearance of neumorphic platform style resource
app:neuFlatButtonColor color of flat button surface color
app:neuFlatButtonAppearance appearance of flat button surface style resource
app:neuButtonDrawable drawable resource of left icon drawable resource
app:neuButtonDrawablePitRadius radius of the pit behind the icon dimension
app:neuButtonIconAppearance appearance of the pit behind the icon style resource
app:neuButtonCompatColor color of button on compat devices color

PitView and ElevatedView

Pit and Elevated Views

  • PitView and ElevatedView are simple Views that can be used to simulate a debossed or embossed neumorphic platform
  • They are not ViewGroups so ideally they can be used in a ConstraintLayout with other Views that are constrained to the PitView or ElevatedView.
  • To use these freely with your views, PitDrawable and ElevatedDrawable can be set as background for your Views programmatically.

PitView

PitView shadows can be specified in two ways:

  1. By specifying a color for the pit, synth will attempt to compute the shadows of the pit
<club.cred.synth.views.PitView
  app:pitColor="@color/pit_color"  
  app:neuCornerRadius="14dp"
  ... />
  1. By specifying a complete appearance for all aspects of the pit
<club.cred.synth.views.PitView
  app:pitViewAppearance="@style/pit_view_appearance"  
  app:neuCornerRadius="14dp"
  ... />
    
<style name="pit_view_appearance">
    <item name="neuLightShadowColor">...</item>
    <item name="neuDarkShadowColor">...</item>
    <item name="softEdgeColor">...</item>
    <item name="neuCompatColor">...</item>
</style>

PitView attributes

attribute description value
app:pitColor color of pit from which shadows colors will be computed color
app:pitViewAppearance appearance of pit style resource
app:neuCornerRadius corner radius of pit dimension
app:pitClipType edge(s) of pit which should be clipped (no shadows or corner arc will be drawn) no_clip, top, bottom, left, right, left_right, top_bottom
app:pitDepth depth of pit dimension

ElevatedView

ElevatedView internally uses the same neumorphic platform that is used to draw the buttons. To specify the appearance and shadows of the ElevatedView, the same attributes of soft button can be used:

  1. By specifying app:neuPlatformColor, synth will compute the shadows and gradients of the view.
  2. By specifying the complete appearance using app:neuPlatformAppearance (same as soft button).

ElevatedView attributes

attribute description value
app:neuPlatformColor color of elevated view color
app:neuPlatformAppearance appearance of the elevated view (same as soft button) style resource
app:neuCornerRadius corner radius of the elevated view dimension
app:neuShadowOffset shadow offset dimension

Min SDK

We support a minimum SDK of 21. But the neumorphic components will be rendered appropriately only on devices running SDK version 28 or above.

Contributing

Pull requests are welcome! We'd love help improving this library. Feel free to browse through open issues to look for things that need work. If you have a feature request or bug, please open a new issue so we can track it.

Contributors

Synth would not have been possible if not for the contributions made by CRED's design and frontend teams. Specifically:

License

Copyright 2020 Dreamplug Technologies Private Limited.

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.
Comments
  • App style changed after adding this library

    App style changed after adding this library

    I have added this library in my app which has a black background but it's changed the background colours of views (ex. Textinputlayout) and sizes of a button. Please help me to resolve this issue. This is the theme used in the app

    ` <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/dark_selected</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/selected</item>
            <item name="android:popupMenuStyle">@style/PopupMenu</item>
            <item name="android:itemBackground">@color/unselected</item>
            <item name="android:dropDownListViewStyle">@style/PopupMenu</item>
            <item name="android:textSize">17dp</item>
        </style>`
    
    opened by meashumishra 7
  • Blur Effect

    Blur Effect

    I like to make this kind of Button. Capture

    But I get the blur effect with app:neuButtonType="elevated_flat". As you can see below image 202998535_791637381542785_719696923984093585_n

    Could you please guide me?

    opened by Akshay-Vtro 3
  • Adding child view to club.cred.synth.views.ElevatedView

    Adding child view to club.cred.synth.views.ElevatedView

    Hi ,

    I tried to add child view to ElevatedView and PitView but getting below error .

    club.cred.synth.views.ElevatedView cannot be cast to android.view.ViewGroup
        Caused by: java.lang.ClassCastException: club.cred.synth.views.ElevatedView cannot be cast to android.view.ViewGroup****
    
    

    How to add views to Elevated and PitView

    opened by ashwath20 2
  • Shadow in buttons.

    Shadow in buttons.

    I am using synth in one of my projects. I have 2 problems while implementing the synth library. image

    1. As you can see in the image above, around the buttons, there is some shadows. How can I remove them?
    2. I was trying to remove the black color border around the cancel button, but was not able to remove that. How can I remove it?
    opened by mohitshah3111999 2
  • Issue with dependencies

    Issue with dependencies

    Even after syncing gradle file did not allow me to use components implementation 'club.cred.android:synth:1.0.0'

    I tried using components on the layout file but it was showing reference not found error. eg club.cred.synth.views.SynthButton

    opened by Xfinity-bot 1
  • ElevatedView background colour

    ElevatedView background colour

    Issue

    ElevatedView

    The issue I'm facing is when i try to set a background colour to ElevatedView, somehow it gets the default color predefined SynthUtils.defaultBaseColor in SynthUtils. I'm trying to set the background dynamic based on device theme.

    Note: The PitView background doesn't have this issue.

    Layout

    This is a part of my layout which contains the ElevatedView:

    <androidx.constraintlayout.widget.ConstraintLayout  
      android:id="@+id/relativeHeader"  
      android:layout_width="0dp"  
      android:layout_height="wrap_content"  
      android:layout_marginTop="8dp"  
      android:clipChildren="false"  
      app:layout_constraintEnd_toEndOf="parent"  
      app:layout_constraintStart_toStartOf="parent"  
      app:layout_constraintTop_toTopOf="parent">  
      
     <club.cred.synth.views.ElevatedView  
      android:id="@+id/headerPitView"  
      android:layout_width="0dp"  
      android:layout_height="0dp"  
      android:layout_margin="18dp"  
      app:layout_constraintBottom_toBottomOf="parent"  
      app:layout_constraintEnd_toEndOf="parent"  
      app:layout_constraintStart_toStartOf="parent"  
      app:layout_constraintTop_toTopOf="parent"  
      app:neuCornerRadius="20dp"  
      app:pitColor="?attr/lightBackgroundColor" />
    
    ..................
    

    I'm using this dependency in build.gradle file:

    dependencies {  
      implementation 'club.cred.android:synth:1.0.0'  
    }  
    

    Expectation

    • applying background color other then the default one for ElevatedView
    opened by astrit-veliu 1
  • setIconPitRadius() is not working

    setIconPitRadius() is not working

    I want to change app:neuButtonDrawablePitRadius through code, so I use setIconPitRadius(), but it's not working. Value of attribute is changing - verified using getIconPitRadius() but nothing is changing in UI

    opened by Sarun1001 0
  • issue with dependencies

    issue with dependencies

    Even after syncing gradle file did not allow me to use components implementation 'club.cred.android:synth:1.0.0'

    I tried using components on the layout file but it was showing reference not found error. eg club.cred.synth.views.SynthButton

    opened by emburaan 1
  • Disabled state of button causing weird rectangular shadow

    Disabled state of button causing weird rectangular shadow

    If I disable the button using isEnabled=false, it causes a weird rectangular shadow around the button. Any fix for the same? The button works fine for enabled state.

    image

    opened by ankuranurag2 1
  • Change Shadow Color

    Change Shadow Color

    I just want to know is there any way to change the color of Shadow in Elevated/Pit Views or in SynthButtons /SynthImageButtons????

    Please reply this issue.....

    opened by bhumikash-tech 1
Wallpaper app made using Hilt, Retrofit, Room, Navigation Components, MVI, Coroutines, Flows, ViewModel, LiveData, Datastore Preference.

Android Picture Engine Wallpaper app made using Hilt, Retrofit, Room, Navigation Components, MVI, Coroutines, Flows, ViewModel, LiveData, Datastore Pr

Simone Conigliaro 59 Sep 27, 2022
Wallum is a superfast ⚡ lightweight wallpaper app, built using Kotlin, Retrofit, MVVM, Paging 3, Hilt, and Navigation Components

Show some ❤️ and star the repo to show support for the project Wallum Android App Wallum is a super-fast ?? , lightweight wallpaper app built purely w

Aditya Verma 19 Dec 6, 2022
Finder Job simple app using (Retrofit , Dagger hilt , coroutines , navigation components)

Job Finder I'm finished building a simple project Job Finder App technology used [dagger hilt, coroutines, navigation components, LiveData, Skelton pa

Gamal Ragab 12 Nov 21, 2022
Simple Notes app, MVVM with Google Architectural components Room database, LiveData and ViewModel. Written in Kotlin using androidx libraries

Simple Notes app, MVVM with Google Architectural components Room database, LiveData and ViewModel. Written in Kotlin using androidx libraries. Implemented Firebase Auth and Database, and used Room database

Javokhir Jambulov 3 Aug 1, 2022
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Madalin Valceleanu 2.3k Jan 3, 2023
Patter Lock using Hilt, Coroutines, Flow and Custom View Components based on MVVM architecture.

Pattern Lock App Sample project for created Pattern Lock View using custom view. Preview Usage Step 1 Add the PatterLockView in your XML layout file.

Furkan Özcan 5 Aug 22, 2021
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.

Popular Movies Stage 1 + Stage 2 Discover the most popular and top rated movies playing. Movies data fetched using themoviedb.org API. ✨ Screenshots M

Yassin AJDI 189 Nov 26, 2022
A quiz app built with trivia api. This app was built with mvvm architecture, dagger-hilt, retrofit, room database, and navigation components.

A quiz app built with trivia api. This app was built with mvvm architecture, dagger-hilt, retrofit, room database, and navigation components.

Stephen Odumirin 3 Dec 19, 2022
🛒A Minimal Expense E-Commerce App built to demonstrate the use of modern android architecture components [Navigation, Room, MotionLayout, etc..] with MVVM Architecture. ✔

E-Store A Simple E-Commerce App ?? built to demonstrate the use of modern android architecture component with MVVM Architecture ?? . Made with love ❤️

Ameen Essa 14 Nov 3, 2022
Movie Android App written in Kotlin, MVVM, RxJava, Coroutine (Upcoming), Android Architecture Components and Jetpack Compose (Upcoming).

MovieHunt MovieHunt is a sample Android project using The Movie DB API based on MVVM architecture. It showcases the latest Android tech stacks with we

Engine Bai 596 Dec 31, 2022
Android News App built in kotlin with implementation of MVVM architecture, android navigation components and retrofit. Displays news to users allowing them to share and save news.

News-App Android news app built in kotlin that fetches news data from news api with Retrofit and displays news to users. This App follow MVVM architec

Raj Manjrekar 16 Dec 29, 2022
Taskify - An app to manage your daily tasks and boost your productivity. Taskify is built using kotlin and follows all modern android Development practices and hence is a good learning resource for beginners

Taskify Taskify is an app to manage your daily tasks and boost your productivity Video Introduction ?? This is a small introduction video about Taskif

Vaibhav Jaiswal 101 Jan 4, 2023
Vaibhav Jaiswal 57 Jan 3, 2023
Alkaa is a to-do application project to study the latest components, architecture and tools for Android development

Alkaa (begin, start in Finnish) is a to-do application project to study the latest components, architecture and tools for Android development. The project evolved a lot since the beginning is available on Google Play! ❤️

Igor Escodro 851 Jan 9, 2023
MovieTray - An application built to play around JetPack components.

Its a playground application focusing on Paging3, MVVM architecture, Kotlin Extension functions, Retrofit, DSL, Navigation component, MotionLayout, SharedElementTransition, Single Activity Architecture, DataStore etc.

Niharika Arora 98 Nov 15, 2022
MVVM News Application with clean code architecture & android jetpack components.

Android - Clean Architecture - Kotlin The purpose of this repo is to follow up Clean Architecture principles by bringing them to Android. The repo con

Rafsan Ahmad 38 Aug 8, 2022
Small training project where dagger, dagger hilt and other components are used for clean architecture

LeagueNow ?? LeagueNow is a sample soccer team list Android application ?? built to demonstrate use of modern Android development tools - (Kotlin, Arc

Kevin Serrano 1 Oct 21, 2021
Weather application example with Android Architecture components and Clean Architecture

Weather application example with Android Architecture components and Clean Architecture Weather app that shows how to architect an android app in a cl

null 2 Dec 3, 2021