All Projects → alorma → Compose-Settings

alorma / Compose-Settings

Licence: MIT license
Android #JetpackCompose Settings library

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Compose-Settings

bitcoin-market-android
Bitcoin Market app shows you the current Bitcoin market price and price chart of different time intervals 💰
Stars: ✭ 284 (+51.06%)
Mutual labels:  jetpack, compose, jetpack-android, jetpack-compose
Awesome-Android-Open-Source-Projects
👓 A curated list of awesome android projects by open-source contributors.
Stars: ✭ 401 (+113.3%)
Mutual labels:  jetpack, jetpack-android, jetpack-compose
Coffeegram
Android app using Jetpack Compose together with StateFlow and MVI
Stars: ✭ 155 (-17.55%)
Mutual labels:  jetpack, compose, jetpack-compose
samples
Jetpack Compose based project, used to stress-testing compose features / integrations and explore non-trivial functionality
Stars: ✭ 21 (-88.83%)
Mutual labels:  jetpack, compose, jetpack-compose
ComposeBird
Flappy Bird game
Stars: ✭ 193 (+2.66%)
Mutual labels:  jetpack, compose, jetpack-compose
Compose-BreakingBad
🧪 ☠︎ Jetpack Compose - Breaking Bad ☢︎
Stars: ✭ 26 (-86.17%)
Mutual labels:  jetpack, jetpack-android, jetpack-compose
JetComposer
Collection of UIs and Animations built with Jetpack Compose for Android
Stars: ✭ 294 (+56.38%)
Mutual labels:  jetpack, compose, jetpack-compose
PCard
Demo project to showcase adding payment card details using JetPack Compose
Stars: ✭ 61 (-67.55%)
Mutual labels:  jetpack, compose, jetpack-compose
neon
Provides Jetpack Compose support for different image loading libraries.
Stars: ✭ 13 (-93.09%)
Mutual labels:  jetpack, compose, jetpack-compose
Jetpack-compose-sample
Forget about bunch of XML files for maintaining UIs. Jetpack Compose is Android’s modern toolkit for building native UI. Here is a small example to get started.
Stars: ✭ 29 (-84.57%)
Mutual labels:  jetpack, compose, jetpack-compose
Composecookbook
A Collection on all Jetpack compose UI elements, Layouts, Widgets and Demo screens to see it's potential
Stars: ✭ 3,516 (+1770.21%)
Mutual labels:  jetpack, compose, jetpack-compose
Delish
Delish, a Food Recipes App in Jetpack Compose and Hilt based on modern Android tech-stacks and MVI clean architecture.
Stars: ✭ 356 (+89.36%)
Mutual labels:  jetpack, compose, jetpack-compose
RocketXDelight-Playground
Native Android application built with Kotlin and Jetpack Compose. This project also illustrates the usage of advanced libraries such as Ktor, SqlDelight, Hilt, etc with the recommended practices and Unit Tests.
Stars: ✭ 37 (-80.32%)
Mutual labels:  jetpack, jetpack-android, jetpack-compose
CloudBook
👨🏻‍💻 An ordinary person’s technical cloud notes, share the world and record life.
Stars: ✭ 38 (-79.79%)
Mutual labels:  jetpack, jetpack-android, jetpack-compose
PlayWeather
🔥🔥🔥 Compose、Lce、MVVM、深色模式、横屏、无网弱网适配、Room、Hilt、多语言切换,目前Android最新的库基本全用上了,你想要的都有🔥🔥🔥
Stars: ✭ 120 (-36.17%)
Mutual labels:  compose, jetpack-android, jetpack-compose
GitReposCompose
GitReposCompose is an Android application 📱 for showcasing Jetpack Compose for building declarative UI in Android. This demo app uses Github public API for fetching public repositories.
Stars: ✭ 32 (-82.98%)
Mutual labels:  jetpack, jetpack-android, jetpack-compose
arkitekt
Arkitekt is a set of architectural tools based on Android Architecture Components, which gives you a solid base to implement the concise, testable and solid application.
Stars: ✭ 114 (-39.36%)
Mutual labels:  jetpack, compose, jetpack-compose
compose-charts
Simple Jetpack Compose Charts for multi-platform. Including Android, Web, Desktop.
Stars: ✭ 30 (-84.04%)
Mutual labels:  jetpack, compose, jetpack-compose
android-developer-roadmap
🗺 The 2022 Android Developer Roadmap suggests learning paths to understanding Android development.
Stars: ✭ 5,533 (+2843.09%)
Mutual labels:  jetpack, jetpack-compose
MovieBox
TMDb + Kotlin + Coroutines + Retrofit2 + Moshi + Clean Architecture + Koin 2 + Glide
Stars: ✭ 46 (-75.53%)
Mutual labels:  jetpack, jetpack-compose

Compose Settings

Versions

Maven Central

Compatible with Compose

This library provides a set of Settings like composable items to help android Jetpack Compose developers build complex settings screens without all the boilerplate

Install

allprojects {
  repositories {
    //...
    mavenCentral()
  }
}

Add dependencies:

Material 2 version
implementation 'com.github.alorma:compose-settings-ui:$version'

Material 3 version
implementation 'com.github.alorma:compose-settings-ui-m3:$version'

Demo

Menu link Switch Checkbox

Usage

This library provide some @Composable items that can be used to build your settings screen.

Scaffold, Column... is not provided by the library, you can place items wherever you want.

Menu Link

Android docs

This can be used to open another settings screen, open link, show a dialog...

SettingsMenuLink(
  icon = { Icon(imageVector = Icons.Default.Wifi, contentDescription = "Wifi") },
  title = { Text(text = "Hello") },
  subtitle = { Text(text = "This is a longer text") },
  onClick = {},
)

action can be provided:

SettingsMenuLink(
  title = { Text(text = "Menu 4") },
  action = { ... },
)

Switch && Checkboxes

Android docs - Switch

Android docs - Checkbox

This can be used to enable or disable a feature

SettingsCheckbox(
  icon = { Icon(imageVector = Icons.Default.Wifi, contentDescription = "Wifi") },
  title = { Text(text = "Hello") },
  subtitle = { Text(text = "This is a longer text") },
  onCheckedChange = { newValue -> },
)
SettingsCheckbox(
  icon = { Icon(imageVector = Icons.Default.Wifi, contentDescription = "Wifi") },
  title = { Text(text = "Hello") },
  subtitle = { Text(text = "This is a longer text") },
  onCheckedChange = { newValue -> },
)

State

In order to provide a default value for the setting and recompose when state changes, you must use state parameter.

Installation

implementation 'com.github.alorma:compose-settings-storage-preferences:$version'
val state = rememberBooleanSettingState()
SettingsCheckbox(state = state)

val state = rememberFloatSettingState()
SettingSlider(state = state)

And, you can react to state change, for example:

val state = rememberBooleanSettingState()

if (state.value) {
  Text("Enabled")
} else {
  Text("Disabled")
}

val state = rememberBooleanSettingState()

if (state.value > 0.5f) {
  Icon(imageVector = Icons.Default.BrightnessLow)
} else {
  Icon(imageVector = Icons.Default.BrightnessHigh)
}

This library provide default value for state as false, however if you need to pass a different value (true), you can use:

val state = rememberBooleanSettingState(defaultValue = true)
val state = rememberFloatSettingState(defaultValue = 0.1f)

The library provides a preferences version of the state, so when setting state is changed, the value is persisted on the preferences.

val state = rememberPreferenceBooleanSettingState(key = "pref_key", defaultValue = true)
val state = rememberPreferenceFloatSettingState(key = "pref_key", defaultValue = 0.1f)
val state = rememberPreferenceIntSettingState(key = "pref_key", defaultValue = 1)

Also, the library provides a DataStore (Both Preference and Proto) version of the state, so when setting state is changed, the value is persisted on the DataStore preferences.

Add dependencies:

PreferenceDataStore version
implementation 'com.github.alorma:compose-settings-storage-datastore:$version'

ProtoDatastore version
implementation 'com.github.alorma:compose-settings-storage-datastore-proto:$version'

And you have to add ProtoBuf dependencies in addition.
// PreferenceDataStore
val state = rememberPreferenceDataStoreBooleanSettingState(key = "pref_key", defaultValue = true)
val state = rememberPreferenceDataStoreFloatSettingState(key = "pref_key", defaultValue = 0.1f)
val state = rememberPreferenceDataStoreIntSettingState(key = "pref_key", defaultValue = 1)


// ProtoDataStore
val datastoreState = rememberProtoDataStoreState(
  // "filename" is optional, but it is recommended to set the protobuf file name so that it wouldn't conflict with other datastore definition.
  filename = "compose_settings_datastore_proto.pb",
  serializer = SettingsSerializer,
)

val state = rememberProtoDataStoreTransformSettingState(
  protoDataStoreState = dataStoreState,
  encoder = {savedValue, newValue -> savedValue.toBuilder().setProtoValue(newValue).build() },
  decoder = { it.protoValue }
)
val state = rememberProtoDataStoreSettingState(protoDataStoreState = dataStoreState)
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].