|
1 | | - |
2 | 1 | # AndroidYCoreUI |
3 | | -================== |
| 2 | + |
| 3 | + |
| 4 | +## Y Tags |
| 5 | + |
| 6 | +Y Tag is a UI element in Android (some times referred to as chips) which displays a piece of |
| 7 | +information. |
| 8 | +It consist of a leading icon(optional), Text and a trailing icon (optional). |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- Fully customizable |
| 13 | + - Shape |
| 14 | + - Leading and Trailing Icons |
| 15 | + - Border |
| 16 | + - Background |
| 17 | + - Text style |
| 18 | + - Shadow |
| 19 | +- Provides a container called Tag view container which holds multiple tags |
| 20 | + - Container size can be fixed or variable |
| 21 | + - If container does not have enough space to accommodate the given tags, it will show over flow |
| 22 | + tag which is configurable. |
| 23 | +- Built with Compose UI |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | + |
| 28 | +**Basic** |
| 29 | + |
| 30 | +``` |
| 31 | +TagView(text ="Default") |
| 32 | +``` |
| 33 | + |
| 34 | +**Customizations** |
| 35 | + |
| 36 | +``` |
| 37 | +val text = "Y Tag" |
| 38 | +val tagViewModifiers = TagViewModifiers.Builder() |
| 39 | + .width(140.dp) |
| 40 | + .shape(CircleShape) |
| 41 | + .backgroundColor(backgroundColor) |
| 42 | + .enableBorder(true) |
| 43 | + .borderColor(Color.Red) |
| 44 | + .textColor(Color.Black) |
| 45 | + .maxLines(1) |
| 46 | + .overFlow(TextOverflow.Ellipsis) |
| 47 | + .build() |
| 48 | +val leadingIcon = { tagViewData -> |
| 49 | + IconButton( |
| 50 | + onClick = {}) { |
| 51 | + Icon(painter = painterResource(id = R.drawable.ic_location_24px), |
| 52 | + contentDescription = null, |
| 53 | + tint = iconTint |
| 54 | + ) |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | +val trailingIcon = { tagViewData -> |
| 59 | + IconButton( |
| 60 | + onClick = {}) { |
| 61 | + Icon(painter = painterResource(id = R.drawable.ic_close_20px), |
| 62 | + contentDescription = null, |
| 63 | + tint = iconTint |
| 64 | + ) |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | +TagView(text = text, tagViewModifiers = tagViewModifiers, leadingIcon = leadingIcon, trailingIcon = trailingIcon, enabled = true) |
| 69 | +``` |
| 70 | + |
| 71 | +**Y Tag Container** |
| 72 | + |
| 73 | +``` |
| 74 | + val tagViewData = remember { |
| 75 | + mutableStateListOf<TagViewData>() |
| 76 | + } |
| 77 | + |
| 78 | + tagViewData.addAll( |
| 79 | + TagViewData( |
| 80 | + text = "capsule", |
| 81 | + tagViewModifiers = TagViewModifiers.Builder() |
| 82 | + .width(90.dp) |
| 83 | + .shape(CircleShape) |
| 84 | + .backgroundColor(backgroundColor).textColor(textColor).style(textStyle).build() |
| 85 | + )) |
| 86 | + |
| 87 | + val tagViewContainerModifiers = TagViewContainerModifiers.Builder() |
| 88 | + .shape(RoundedCornerShape(4.dp) |
| 89 | + .tagSpacingVertical(8.dp) |
| 90 | + .tagSpacingHorizontal(8.dp) |
| 91 | + .width(360.dp) |
| 92 | + .height(50.dp) |
| 93 | + .moreTagConfiguration( |
| 94 | + TagViewData( |
| 95 | + overFlowText = { count -> |
| 96 | + "+ $count more" |
| 97 | + }, |
| 98 | + tagViewModifiers = TagViewModifiers.Builder() |
| 99 | + .backgroundColor(colorResource(id = R.color.light_blue_300)) |
| 100 | + .shape(CircleShape).width(80.dp).textAlign(TextAlign.Start).height(30.dp) |
| 101 | + .maxLines(1).overFlow(TextOverflow.Ellipsis).textAlign(TextAlign.Center) |
| 102 | + .textColor(Color.Black).fontWeight(FontWeight.Medium).onCLick { }.build() |
| 103 | + ) |
| 104 | + ).onCLick {} |
| 105 | + .build() |
| 106 | + |
| 107 | + TagViewContainer(tagViewData = tagViewData, tagViewContainerModifiers = tagViewContainerModifiers) |
| 108 | +``` |
| 109 | + |
| 110 | +## Screenshots |
| 111 | + |
| 112 | +<img src="screenshots/Stepper_Screenshot_1.jpg"/> |
| 113 | + |
| 114 | +## Demo |
| 115 | + |
| 116 | +<img src="screenshots/y_tag_13_s.gif"/> |
4 | 117 |
|
5 | 118 | ### How to generate test report |
| 119 | + |
6 | 120 | - Generating jacoco test report |
7 | 121 | - Gradle command `clean build createMergedJacocoReport` |
8 | 122 | - From android studio |
9 | 123 | - Open gradle menu bar from android studio right side panel |
10 | 124 | - Click on the gradle icon and |
11 | 125 | - In command popup window type `clean build createMergedJacocoReport` and press enter |
12 | 126 | - Wait for the execution completion, |
13 | | - - After successful execution each module level execution report will be stored in 'module\build\reports\jacoco\html\index.html'. |
| 127 | + - After successful execution each module level execution report will be stored in ' |
| 128 | + module\build\reports\jacoco\html\index.html'. |
14 | 129 |
|
15 | 130 | ### How to generate dokka report |
16 | | -- Gradle command single module `clean build dokkaHtml` for multi module `clean build dokkaHtmlMultiModule` |
| 131 | + |
| 132 | +- Gradle command single module `clean build dokkaHtml` for multi |
| 133 | + module `clean build dokkaHtmlMultiModule` |
17 | 134 | - From android studio |
18 | 135 | - Open gradle menu bar from android studio right side panel |
19 | 136 | - Click on the gradle icon and |
20 | 137 | - In command popup window type `dokkaHtml` for multi module `dokkaHtmlMultiModule` |
21 | 138 |
|
22 | 139 | ### How to check KTLint |
| 140 | + |
23 | 141 | - Gradle command for checking lint error `ktlintCheck` |
24 | 142 | - Gradle command for formatting code `ktlintFormat` |
25 | | -======= |
| 143 | + ======= |
26 | 144 |
|
27 | 145 |
|
0 commit comments