Skip to content

Commit a46071c

Browse files
committed
Added option for changing ListPref selection colour
1 parent c8ecb05 commit a46071c

4 files changed

Lines changed: 15 additions & 21 deletions

File tree

ComposePrefs3/build.gradle

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,13 @@ android {
3939
}
4040

4141
dependencies {
42-
implementation "androidx.compose.ui:ui:1.2.0-beta01"
43-
implementation "androidx.compose.material3:material3:1.0.0-alpha11"
44-
implementation "androidx.compose.material3:material3-window-size-class:1.0.0-alpha11"
42+
implementation "androidx.compose.ui:ui:1.2.0-beta02"
43+
implementation "androidx.compose.material3:material3:1.0.0-alpha12"
44+
implementation "androidx.compose.material3:material3-window-size-class:1.0.0-alpha12"
4545
implementation "androidx.datastore:datastore-preferences:1.0.0"
4646
}
4747

4848

49-
android {
50-
publishing {
51-
singleVariant('release') {
52-
withSourcesJar()
53-
}
54-
// ...
55-
}
56-
}
57-
5849
afterEvaluate {
5950
publishing {
6051
publications {
@@ -63,7 +54,7 @@ afterEvaluate {
6354

6455
groupId = 'com.github.jamalmulla'
6556
artifactId = 'ComposePrefs3'
66-
version = '1.0.0'
57+
version = '1.0.1'
6758
}
6859
}
6960
}

ComposePrefs3/src/main/java/com/jamal/composeprefs3/ui/prefs/ListPref.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import java.lang.Exception
3131
* @param onValueChange Will be called with the selected key when an item is selected
3232
* @param useSelectedAsSummary If true, uses the current selected item as the summary
3333
* @param dialogBackgroundColor Background color of the Dialog
34+
* @param contentColor Preferred content color passed to dialog's children
3435
* @param textColor Text colour of the [title] and [summary]
36+
* @param selectionColor Colour of the radiobutton of the selected item
3537
* @param enabled If false, this Pref cannot be clicked and the Dialog cannot be shown.
3638
* @param entries Map of keys to values for entries that should be shown in the Dialog.
3739
*/
@@ -49,6 +51,7 @@ fun ListPref(
4951
dialogBackgroundColor: Color = MaterialTheme.colorScheme.surface,
5052
contentColor: Color = contentColorFor(dialogBackgroundColor),
5153
textColor: Color = MaterialTheme.colorScheme.onBackground,
54+
selectionColor: Color = MaterialTheme.colorScheme.primary,
5255
enabled: Boolean = true,
5356
entries: Map<String, String> = mapOf(), //TODO: Change to List?
5457
) {
@@ -116,7 +119,7 @@ fun ListPref(
116119
RadioButton(
117120
selected = isSelected,
118121
onClick = { if (!isSelected) onSelected() },
119-
colors = RadioButtonDefaults.colors(selectedColor = MaterialTheme.colorScheme.primary)
122+
colors = RadioButtonDefaults.colors(selectedColor = selectionColor)
120123
)
121124
Text(
122125
text = current.second,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ maven { url "https://jitpack.io" }
219219
and in your module `build.gradle` file add the dependencies
220220

221221
``` groovy
222-
implementation "com.github.JamalMulla:ComposePrefs3:<version>" // Current is 1.0.0
222+
implementation "com.github.JamalMulla:ComposePrefs3:<version>" // Current is 1.0.1
223223
implementation "androidx.datastore:datastore-preferences:1.0.0"
224224
```
225225

app/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ dependencies {
5252
implementation 'androidx.core:core-ktx:1.7.0'
5353
implementation 'androidx.appcompat:appcompat:1.4.1'
5454
implementation 'com.google.android.material:material:1.6.0'
55-
implementation "androidx.compose.ui:ui:1.2.0-beta01"
56-
implementation "androidx.compose.material3:material3:1.0.0-alpha11"
57-
implementation "androidx.compose.material3:material3-window-size-class:1.0.0-alpha11"
58-
implementation "androidx.compose.ui:ui-tooling-preview:1.2.0-beta01"
55+
implementation "androidx.compose.ui:ui:1.2.0-beta02"
56+
implementation "androidx.compose.material3:material3:1.0.0-alpha12"
57+
implementation "androidx.compose.material3:material3-window-size-class:1.0.0-alpha12"
58+
implementation "androidx.compose.ui:ui-tooling-preview:1.2.0-beta02"
5959
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
6060
implementation 'androidx.activity:activity-compose:1.4.0'
6161
testImplementation 'junit:junit:4.+'
6262
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
6363
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
64-
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.2.0-beta01"
65-
debugImplementation "androidx.compose.ui:ui-tooling:1.2.0-beta01"
64+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.2.0-beta02"
65+
debugImplementation "androidx.compose.ui:ui-tooling:1.2.0-beta02"
6666

6767
// ComposePrefs library
6868
implementation project(':ComposePrefs3')

0 commit comments

Comments
 (0)