@@ -47,7 +47,7 @@ import javax.inject.Inject
4747/* *
4848 * View theme utils for Material views (com.google.android.material.*)
4949 */
50- @Suppress(" TooManyFunctions" )
50+ @Suppress(" TooManyFunctions" , " LargeClass " )
5151class MaterialViewThemeUtils
5252 @Inject
5353 constructor (
@@ -375,30 +375,66 @@ class MaterialViewThemeUtils
375375 )
376376 fun colorCardViewBackground (card : MaterialCardView ) = themeCardView(card)
377377
378- fun colorProgressBar (progressIndicator : LinearProgressIndicator ) {
379- withScheme(progressIndicator) { scheme ->
380- colorProgressBar(progressIndicator, dynamicColor.primary().getArgb(scheme))
378+ /* *
379+ * Themes a [LinearProgressIndicator] using the provided [ColorRole].
380+ *
381+ * @param linearProgressIndicator The progress indicator to theme.
382+ * @param colorRole The color role to be used for the active indicator part. Defaults to [ColorRole.PRIMARY].
383+ */
384+ fun colorProgressBar (
385+ linearProgressIndicator : LinearProgressIndicator ,
386+ colorRole : ColorRole = ColorRole .PRIMARY
387+ ) {
388+ withScheme(linearProgressIndicator) { scheme ->
389+ colorProgressBar(linearProgressIndicator, colorRole.select(scheme))
381390 }
382391 }
383392
393+ /* *
394+ * Themes a [LinearProgressIndicator] using the provided color [Int].
395+ *
396+ * @param linearProgressIndicator The progress indicator to theme.
397+ * @param color The color to be used for the active indicator part.
398+ */
384399 fun colorProgressBar (
385- progressIndicator : LinearProgressIndicator ,
400+ linearProgressIndicator : LinearProgressIndicator ,
386401 @ColorInt color : Int
387402 ) {
388- progressIndicator.setIndicatorColor(color)
403+ withScheme(linearProgressIndicator) { scheme ->
404+ linearProgressIndicator.setIndicatorColor(color)
405+ linearProgressIndicator.trackColor = dynamicColor.secondaryContainer().getArgb(scheme)
406+ }
389407 }
390408
391- fun colorProgressBar (progressIndicator : CircularProgressIndicator ) {
392- withScheme(progressIndicator) { scheme ->
393- colorProgressBar(progressIndicator, dynamicColor.primary().getArgb(scheme))
409+ /* *
410+ * Themes a [CircularProgressIndicator] using the provided [ColorRole].
411+ *
412+ * @param circularProgressIndicator The progress indicator to theme.
413+ * @param colorRole The color role to be used for the active indicator part. Defaults to [ColorRole.PRIMARY].
414+ */
415+ fun colorProgressBar (
416+ circularProgressIndicator : CircularProgressIndicator ,
417+ colorRole : ColorRole = ColorRole .PRIMARY
418+ ) {
419+ withScheme(circularProgressIndicator) { scheme ->
420+ colorProgressBar(circularProgressIndicator, colorRole.select(scheme))
394421 }
395422 }
396423
424+ /* *
425+ * Themes a [CircularProgressIndicator] using the provided color [Int].
426+ *
427+ * @param circularProgressIndicator The progress indicator to theme.
428+ * @param color The color to be used for the active indicator part.
429+ */
397430 fun colorProgressBar (
398- progressIndicator : CircularProgressIndicator ,
431+ circularProgressIndicator : CircularProgressIndicator ,
399432 @ColorInt color : Int
400433 ) {
401- progressIndicator.setIndicatorColor(color)
434+ withScheme(circularProgressIndicator) { scheme ->
435+ circularProgressIndicator.setIndicatorColor(color)
436+ circularProgressIndicator.trackColor = dynamicColor.secondaryContainer().getArgb(scheme)
437+ }
402438 }
403439
404440 fun colorTextInputLayout (textInputLayout : TextInputLayout ) {
0 commit comments