Skip to content

Commit 0af19eb

Browse files
Merge pull request #703 from nextcloud/feta/noid/search-bar
feat: Add search bar and button content coloring
2 parents 5b0ccf7 + 88f7c3b commit 0af19eb

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

ui/src/main/java/com/nextcloud/android/common/ui/theme/utils/MaterialViewThemeUtils.kt

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ class MaterialViewThemeUtils
141141
}
142142
}
143143

144+
fun themeSearchCardView(cardView: MaterialCardView) {
145+
withScheme(cardView) { scheme ->
146+
cardView.backgroundTintList =
147+
ColorStateList.valueOf(
148+
dynamicColor.surfaceContainerHigh().getArgb(scheme)
149+
)
150+
cardView.setStrokeColor(
151+
buildColorStateList(
152+
android.R.attr.state_checked to dynamicColor.surfaceContainerHigh().getArgb(scheme),
153+
-android.R.attr.state_checked to dynamicColor.surfaceContainerHigh().getArgb(scheme)
154+
)
155+
)
156+
}
157+
}
158+
144159
fun themeDragHandleView(dragHandleView: BottomSheetDragHandleView) {
145160
withScheme(dragHandleView) { scheme ->
146161
dragHandleView.imageTintList = ColorStateList.valueOf(dynamicColor.onSurfaceVariant().getArgb(scheme))
@@ -293,17 +308,26 @@ class MaterialViewThemeUtils
293308
-android.R.attr.state_pressed to dynamicColor.onPrimary().getArgb(scheme)
294309
)
295310

311+
colorMaterialButtonContent(button)
312+
}
313+
}
314+
315+
fun colorMaterialButtonContent(
316+
button: MaterialButton,
317+
colorRole: ColorRole = ColorRole.PRIMARY
318+
) {
319+
withScheme(button) { scheme ->
296320
val contentColorList =
297321
buildColorStateList(
298-
android.R.attr.state_enabled to dynamicColor.primary().getArgb(scheme),
322+
android.R.attr.state_enabled to colorRole.select(scheme),
299323
-android.R.attr.state_enabled to
300324
colorUtil.adjustOpacity(
301-
dynamicColor.primary().getArgb(scheme),
325+
colorRole.select(scheme),
302326
ON_SURFACE_OPACITY_BUTTON_DISABLED
303327
),
304-
-android.R.attr.state_hovered to dynamicColor.primary().getArgb(scheme),
305-
-android.R.attr.state_focused to dynamicColor.primary().getArgb(scheme),
306-
-android.R.attr.state_pressed to dynamicColor.primary().getArgb(scheme)
328+
-android.R.attr.state_hovered to colorRole.select(scheme),
329+
-android.R.attr.state_focused to colorRole.select(scheme),
330+
-android.R.attr.state_pressed to colorRole.select(scheme)
307331
)
308332

309333
button.setTextColor(

0 commit comments

Comments
 (0)