Skip to content

Commit

Permalink
Added option for changing ListPref selection colour
Browse files Browse the repository at this point in the history
  • Loading branch information
JamalMulla committed May 22, 2022
1 parent f578627 commit 2d7ab93
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ComposePrefs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 21
targetSdk 31
versionCode 2
versionName "1.0.2"
versionName "1.0.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down Expand Up @@ -40,8 +40,8 @@ android {
}

dependencies {
implementation "androidx.compose.ui:ui:1.2.0-alpha01"
implementation "androidx.compose.material:material:1.2.0-alpha01"
implementation "androidx.compose.ui:ui:1.2.0-beta02"
implementation "androidx.compose.material:material:1.2.0-beta02"
implementation "androidx.datastore:datastore-preferences:1.0.0"
}

Expand All @@ -54,7 +54,7 @@ afterEvaluate {

groupId = 'com.github.jamalmulla'
artifactId = 'ComposePrefs'
version = '1.0.2'
version = '1.0.3'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import java.lang.Exception
* @param onValueChange Will be called with the selected key when an item is selected
* @param useSelectedAsSummary If true, uses the current selected item as the summary
* @param dialogBackgroundColor Background color of the Dialog
* @param contentColor Preferred content color passed to dialog's children
* @param textColor Text colour of the [title] and [summary]
* @param selectionColor Colour of the radiobutton of the selected item
* @param enabled If false, this Pref cannot be clicked and the Dialog cannot be shown.
* @param entries Map of keys to values for entries that should be shown in the Dialog.
*/
Expand All @@ -51,6 +53,7 @@ fun ListPref(
dialogBackgroundColor: Color = MaterialTheme.colors.surface,
contentColor: Color = contentColorFor(dialogBackgroundColor),
textColor: Color = MaterialTheme.colors.onBackground,
selectionColor: Color = MaterialTheme.colors.primary,
enabled: Boolean = true,
entries: Map<String, String> = mapOf(), //TODO: Change to List?
) {
Expand Down Expand Up @@ -118,7 +121,7 @@ fun ListPref(
RadioButton(
selected = isSelected,
onClick = { if (!isSelected) onSelected() },
colors = RadioButtonDefaults.colors(selectedColor = MaterialTheme.colors.primary)
colors = RadioButtonDefaults.colors(selectedColor = selectionColor)
)
Text(
text = current.second,
Expand All @@ -134,7 +137,7 @@ fun ListPref(
TextButton(
onClick = { showDialog = false },
) {
Text("Cancel", style = MaterialTheme.typography.body1)
Text("Cancel", style = MaterialTheme.typography.body1, color = textColor)
}

},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ maven { url "https://jitpack.io" }
and in your module `build.gradle` file add the dependencies

``` groovy
implementation "com.github.JamalMulla:ComposePrefs:<version>" // Current is 1.0.2
implementation "com.github.JamalMulla:ComposePrefs:<version>" // Current is 1.0.3
implementation "androidx.datastore:datastore-preferences:1.0.0"
```

Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ android {
dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
implementation 'androidx.activity:activity-compose:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
compose_version = '1.2.0-alpha01'
compose_version = '1.2.0-beta02'
}
repositories {
google()
Expand Down

0 comments on commit 2d7ab93

Please sign in to comment.