Neda Topoljanac | 5297c4e | 2021-12-15 14:58:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package androidx.wear.tiles.material; |
| 18 | |
| 19 | import static androidx.wear.tiles.ColorBuilders.argb; |
| 20 | |
| 21 | import androidx.annotation.ColorInt; |
| 22 | import androidx.annotation.NonNull; |
| 23 | import androidx.wear.tiles.ColorBuilders.ColorProp; |
| 24 | |
| 25 | /** |
| 26 | * Represents the background and content colors used in a chip Tiles component. |
| 27 | * |
| 28 | * <p>See {@link ChipDefaults#PRIMARY} for the default colors used in a primary styled {@link Chip}. |
| 29 | * See {@link ChipDefaults#SECONDARY} for the default colors used in a secondary styled {@link |
| 30 | * Chip}. |
| 31 | */ |
| 32 | public class ChipColors { |
| 33 | @NonNull private final ColorProp mBackgroundColor; |
| 34 | @NonNull private final ColorProp mIconTintColor; |
| 35 | @NonNull private final ColorProp mContentColor; |
| 36 | @NonNull private final ColorProp mSecondaryContentColor; |
| 37 | |
| 38 | /** |
| 39 | * Constructor for the {@link ChipColors} object. |
| 40 | * |
| 41 | * @param backgroundColor The background color to be used for a chip Tiles component. Should be |
| 42 | * in ARGB format. |
| 43 | * @param iconTintColor The tint color to be used for an icon in a chip Tiles component. Should |
| 44 | * be in ARGB format. |
| 45 | * @param contentColor The text color to be used for a main text in a chip Tiles component. |
| 46 | * Should be in ARGB format. |
| 47 | * @param secondaryContentColor The text color to be used for a label text in a chip Tiles |
| 48 | * component. Should be in ARGB format. |
| 49 | */ |
| 50 | public ChipColors( |
| 51 | @ColorInt int backgroundColor, |
| 52 | @ColorInt int iconTintColor, |
| 53 | @ColorInt int contentColor, |
| 54 | @ColorInt int secondaryContentColor) { |
| 55 | mBackgroundColor = argb(backgroundColor); |
| 56 | mIconTintColor = argb(iconTintColor); |
| 57 | mContentColor = argb(contentColor); |
| 58 | mSecondaryContentColor = argb(secondaryContentColor); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Constructor for the {@link ChipColors} object. |
| 63 | * |
| 64 | * @param backgroundColor The background color to be used for a chip Tiles component. Should be |
| 65 | * in ARGB format. |
| 66 | * @param contentColor The content color to be used for all items inside a chip Tiles component. |
| 67 | * Should be in ARGB format. |
| 68 | */ |
| 69 | public ChipColors(@ColorInt int backgroundColor, @ColorInt int contentColor) { |
| 70 | mBackgroundColor = argb(backgroundColor); |
| 71 | mIconTintColor = argb(contentColor); |
| 72 | mContentColor = argb(contentColor); |
| 73 | mSecondaryContentColor = argb(contentColor); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Constructor for the {@link ChipColors} object. |
| 78 | * |
| 79 | * @param backgroundColor The background color to be used for a chip Tiles component. |
| 80 | * @param iconTintColor The tint color to be used for an icon in a chip Tiles component. |
| 81 | * @param contentColor The text color to be used for a main text in a chip Tiles component. |
| 82 | * @param secondaryContentColor The text color to be used for a label text in a chip Tiles |
| 83 | * component. |
| 84 | */ |
| 85 | public ChipColors( |
| 86 | @NonNull ColorProp backgroundColor, |
| 87 | @NonNull ColorProp iconTintColor, |
| 88 | @NonNull ColorProp contentColor, |
| 89 | @NonNull ColorProp secondaryContentColor) { |
| 90 | mBackgroundColor = backgroundColor; |
| 91 | mIconTintColor = iconTintColor; |
| 92 | mContentColor = contentColor; |
| 93 | mSecondaryContentColor = secondaryContentColor; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Constructor for the {@link ChipColors} object. |
| 98 | * |
| 99 | * @param backgroundColor The background color to be used for a chip Tiles component. |
| 100 | * @param contentColor The content color to be used for all items inside a chip Tiles component. |
| 101 | */ |
| 102 | public ChipColors(@NonNull ColorProp backgroundColor, @NonNull ColorProp contentColor) { |
| 103 | mBackgroundColor = backgroundColor; |
| 104 | mIconTintColor = contentColor; |
| 105 | mContentColor = contentColor; |
| 106 | mSecondaryContentColor = contentColor; |
| 107 | } |
| 108 | |
| 109 | /** The background color to be used on a chip Tiles components. */ |
| 110 | @NonNull |
| 111 | public ColorProp getBackgroundColor() { |
| 112 | return mBackgroundColor; |
| 113 | } |
| 114 | |
| 115 | /** The tint color to be used on a chip Tiles components. */ |
| 116 | @NonNull |
| 117 | public ColorProp getIconTintColor() { |
| 118 | return mIconTintColor; |
| 119 | } |
| 120 | |
| 121 | /** The main text color to be used on a chip Tiles components. */ |
| 122 | @NonNull |
| 123 | public ColorProp getContentColor() { |
| 124 | return mContentColor; |
| 125 | } |
| 126 | |
| 127 | /** The label text color to be used on a chip Tiles components. */ |
| 128 | @NonNull |
| 129 | public ColorProp getSecondaryContentColor() { |
| 130 | return mSecondaryContentColor; |
| 131 | } |
| 132 | } |