A customizable debug screen to view and edit flags that can be used for development in Jetpack Compose applications

Related tags

UI/UX tweaks
Overview

Tweaks

A customizable debug screen to view and edit flags that can be used for development in Jetpack Compose applications

To include the library add to your app's build.gradle:

implementation 'io.github.gmerinojimenez:tweaks:0.0.6'

Or, in case you want to don't add the library in release builds:

debugImplementation 'io.github.gmerinojimenez:tweaks:0.0.6'
releaseImplementation 'io.github.gmerinojimenez:tweaks-no-op:0.0.6'

Then initialize the library in your app's onCreate:

override fun onCreate() {
    super.onCreate()
    Tweaks.init(this@TweakDemoApplication, demoTweakGraph())
}

where demoTweakGraph is the structure you want to be rendered:

    private fun demoTweakGraph() = TweaksGraph(
        category = listOf(
            TweakCategory(
                "Screen 1", listOf(
                    TweakGroup(
                        "Group 1", listOf(
                            ReadOnlyStringTweakEntry(
                                key = "timestamp",
                                name = "Current timestamp",
                                value = flow {
                                    while (true) {
                                        emit("${System.currentTimeMillis() / 1000}")
                                        delay(1000)
                                    }
                                }),
                            EditableStringTweakEntry(
                                key = "value1",
                                name = "Value 1",
                            ),
                            EditableBooleanTweakEntry(
                                key = "value2",
                                name = "Value 2",
                            ),
                            EditableIntTweakEntry(
                                key = "value3",
                                name = "Value 3",
                                defaultUniqueValue = 0,
                            ),
                            ButtonTweakEntry(
                                key = "button1",
                                name = "Demo button"
                            ) {
                                Toast.makeText(this, "Demo button", Toast.LENGTH_LONG).show()
                            }
                        )
                    )
                )
            )
        )
    )

And then, in your NavHost setup, use the extension function NavGraphBuilder.addTweakGraph to fill the navigation graph with the tweak components:

@Composable
    private fun DemoNavHost(
        navController: NavHostController,
        initialScreen: String,
        modifier: Modifier = Modifier,
    ) {
        NavHost(
            navController = navController,
            startDestination = initialScreen,
            modifier = modifier,
        ) {
            addTweakGraph(
                navController = navController,
            )
        }
    }

Please review the app module for configuration examples. Check the available nodes in the graph here

Special thanks to contributors:

Comments
  • Reverting to use flow and using a defaultValue that is not a flow

    Reverting to use flow and using a defaultValue that is not a flow

    • Using flow instead of StateFlow
    • Exposing a suspendable getter that retrieves the last emitted element
    • Instead of having a flow as default value, using a single element
    opened by gmerinojimenez 0
  • Dsl evolution

    Dsl evolution

    Adding entries to the dsl. Usage example:

        private fun demoTweakGraph() = tweaksGraph {
            tweakCategory("Screen 1") {
                tweakGroup("Group 1") {
                    label(
                        key = "timestamp",
                        name = "Current timestamp",
                    ) {
                        flow {
                            while (true) {
                                emit("${System.currentTimeMillis() / 1000}")
                                delay(1000)
                            }
                        }
                    }
                    editableString(
                        key = "value1",
                        name = "Value 1",
                    )
                    editableBoolean(
                        key = "value2",
                        name = "Value 2",
                    )
                    editableInt(
                        key = "value3",
                        name = "Value 3",
                        defaultValue = flow {
                            while (true) {
                                counter += 1
                                emit(counter)
                                delay(1000)
                            }
                        }
                    )
                    editableLong(
                        key = "value4",
                        name = "Value 4",
                        defaultValue = 0L,
                    )
    
                    button(
                        key = "button1",
                        name = "Demo button"
                    ) {
                        Toast.makeText(this@TweakDemoApplication, "Demo button", Toast.LENGTH_LONG)
                            .show()
                    }
                }
            }
        }
    
    opened by gmerinojimenez 0
  • Create Graph creation DSL

    Create Graph creation DSL

    This is a proposal of a DSL to create Tweak graphs. It is intended to be used as follows:

    tweakGraph {
        tweakCategory("Some category Name") {
            tweakGroup("Some gtoup name") {
                addEntry(SomeEntryTweak())
                ....
            }
        }
    }
    

    I've kept the public constructor so the graph can still be built using previous syntax.

    I will update the README.md if this approach is accepted 🙂

    opened by yamal-coding 0
  • Remember state for recomposition

    Remember state for recomposition

    Description

    There was an undesired effect in the demo app that was making the counter example to have a strange behavior. I'm using the remember function on TweakEntry composables so state is resued between recompositions to avoid having to subscribe to a flow again and again:

    I'm taking EditableIntTweakEntryBody as example:

    • value is of type State<T> and its accessor is used in this same Composable function scope
    • Compose compiler makes every Composable function to be recomposed when an object of type State that is observed within its scope is updated
    • Each time this Composable is recomposed it is being subscribed to a cold flow that will start emitting its events from the beggining
    • To avoid creating that flow subscription again and again, we should use remember to keep the reference to that State so it is reused across recompositions

    Result:

    https://user-images.githubusercontent.com/18336786/137685416-9f14e1d6-f672-4090-a62f-62a3650a78e1.mov

    opened by yamal-coding 0
  • Fix duplicate class BuildConfig

    Fix duplicate class BuildConfig

    Duplicate class com.gmerino.tweaks.BuildConfig found in modules jetified-tweaks-0.0.2-runtime (io.github.gmerinojimenez:tweaks:0.0.2) and jetified-tweaks-no-op-0.0.2-runtime (io.github.gmerinojimenez:tweaks-no-op:0.0.2)

    opened by gmerinojimenez 0
Releases(0.0.18)
Owner
Guillermo Merino Jiménez
Guillermo Merino Jiménez
GreenDroid is a development library for the Android platform. It makes UI developments easier and consistent through your applications.

#GreenDroid Foreword : This project, initially initiated by me, Cyril Mottier, is not maintained anymore and can be considered as deprecated. As a con

Cyril Mottier 2.6k Jan 4, 2023
Multiplatform UI DSL with screen management in common code for mobile (android & ios) Kotlin Multiplatform development

Mobile Kotlin widgets This is a Kotlin MultiPlatform library that provides declarative UI and application screens management in common code. You can i

IceRock Development 320 Dec 30, 2022
PCard Add payment card screen made using JetPack Compose

PCard Add payment card screen made using JetPack Compose Find this repository useful? ❤️ Support it by joining stargazers for this repository. ⭐ And f

Mohamed Elbehiry 61 Dec 16, 2022
FloatingView can make the target view floating above the anchor view with cool animation

FloatingView FloatingView can make the target view floating above the anchor view with cool animation Links 中文版 README Blog about FloatingView demo.ap

UFreedom 1.8k Dec 27, 2022
Android library for creating an expandable to full screen view inside a viewgroup composition.

Expandable Panel Android Library Check ExpandablePanel Demo application on GooglePlay: Details This Android library implements the expand by sliding l

Jorge Castillo 422 Nov 10, 2022
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

Frederik Schweiger 1.5k Dec 30, 2022
A simple and customizable two or three states Switch View

RMSwitch A simple View that works like a switch, but with more customizations. With the option to choose between two or three states. (from v1.1.0) **

Riccardo Moro 656 Dec 2, 2022
Customizable Item Setting View Android

ItemSettingView Simple ItemSettingView and Custom Installation Add it in your root build.gradle at the end of repositories: allprojects { reposito

Andhika Yuana 15 Aug 19, 2022
Fully customizable implementation of "Snowfall View" on Android.

Android-Snowfall Fully customizable implementation of "Snowfall View" on Android. That's how we use it in our app Hotellook Compatibility This library

Jetradar Mobile 1.2k Dec 21, 2022
A View on which you can freely draw, customizing paint width, alpha and color, and take a screenshot of the content. Useful for note apps, signatures or free hand writing.

FreeDrawView A View that let you draw freely on it. You can customize paint width, alpha and color. Can be useful for notes app, signatures or hands-f

Riccardo Moro 643 Nov 28, 2022
💳 A quick and easy flip view through which you can create views with two sides like credit cards, poker cards etc.

The article on how this library was created is now published. You can read it on this link here. →. ?? EasyFlipView Built with ❤︎ by Wajahat Karim and

Wajahat Karim 1.3k Dec 14, 2022
Android View for displaying and selecting values in a circle-shaped View, with animations and touch gestures.

CircleDisplay Android View for displaying and selecting (by touch) values / percentages in a circle-shaped View, with animations. Features Core featur

Philipp Jahoda 287 Nov 18, 2022
A color picker and a color preference for use in Android applications.

HSV-Alpha Color Picker for Android This library implements a color picker and a color preference for use in Android applications. Features I couldn't

Martin Stone 279 Nov 26, 2022
A nicer-looking, more intuitive and highly customizable alternative for radio buttons and dropdowns for Android.

SwipeSelector Undergoing for some API changes for a 2.0 major version, see example usage in the sample module! What and why? Bored of dull looking rad

Iiro Krankka 1.1k Dec 30, 2022
The CustomCalendarView provides an easy and customizable calendar to create a Calendar. It dispaly the days of a month in a grid layout and allows to navigate between months

Custom-Calendar-View To use the CustomCalendarView in your application, you first need to add the library to your application. You can do this by eith

Nilanchala Panigrahy 113 Nov 29, 2022
A simple screen that is shown when your app gets crashed instead of the normal crash dialog. It's very similar to the one in Flutter.

Red Screen Of Death What A simple screen that is shown when your app gets crashed instead of the normal crash dialog. It's very similar to the one in

Ahmad Melegy 178 Dec 9, 2022
Displays your screen time in a permanent notification.

Screen Time Displays your screen time in a permanent notification. By making screen time more prominent, you can get a better sense of how much of the

Markus Fisch 24 Nov 29, 2022
GIFView is a library for showing GIFs in applications

GIFView GIFView is a library for showing GIFs in applications. Setup In your project's build.gradle file: allprojects { repositories { ...

Tzlil Gavra 20 Apr 19, 2022
:balloon: A lightweight popup like tooltips, fully customizable with an arrow and animations.

Balloon ?? A lightweight popup like tooltips, fully customizable with arrow and animations. Including in your project Gradle Add below codes to your r

Jaewoong Eum 2.8k Jan 5, 2023