18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/License:
--------------------------------------------------------------------------------
1 | Copyright 2022 Canopas Software LLP
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Intro Showcase View
4 | []( https://android-arsenal.com/details/1/8387 )
5 |
6 |
7 |
8 |
9 |
10 | An android library to highlight different features of the app built using Jetpack Compose.
11 |
12 | The library is inspired by the [TapTargetView](https://github.com/KeepSafe/TapTargetView) that is useful for legacy views.
13 |
14 |
15 |
16 | ## Configuration
17 |
18 | Available on [Maven Central](https://search.maven.org/artifact/com.canopas.intro-showcase-view/introshowcaseview).
19 |
20 | Add the dependency
21 | ```gradle
22 | implementation 'com.canopas.intro-showcase-view:introshowcaseview:2.0.1'
23 |
24 | ```
25 | # Documentation
26 | Please see [sample application](https://github.com/canopas/Intro-showcase-view/tree/master/app) and [the website](https://canopas.github.io/compose-intro-showcase/) for more information.
27 |
28 | # Further reading
29 | For more details about the library implementation, checkout the [Article](https://blog.canopas.com/intro-showcase-view-in-jetpack-compose-ac044cd3bf28)
30 |
31 | # Bugs and Feedback
32 | For bugs, questions and discussions please use the [Github Issues](https://github.com/canopas/Intro-showcase-view/issues).
33 |
34 | # Credits
35 |
36 | Intro showcaseview is owned and maintained by the [Canopas team](https://canopas.com/). You can follow them on X at [@canopassoftware](https://x.com/canopassoftware) for project updates and releases. If you are interested in building apps or designing products, please let us know. We'd love to hear from you!
37 |
38 |
39 |
40 | # Licence
41 |
42 | ```
43 | Copyright 2022 Canopas Software LLP
44 |
45 | Licensed under the Apache License, Version 2.0 (the "License");
46 | you may not use this file except in compliance with the License.
47 | You may obtain a copy of the License at
48 |
49 | http://www.apache.org/licenses/LICENSE-2.0
50 |
51 | Unless required by applicable law or agreed to in writing, software
52 | distributed under the License is distributed on an "AS IS" BASIS,
53 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
54 | See the License for the specific language governing permissions and
55 | limitations under the License.
56 | ```
57 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | .idea
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | }
5 |
6 | android {
7 | namespace = "com.canopas.campose.showcase"
8 | compileSdk 34
9 |
10 | defaultConfig {
11 | applicationId "com.canopas.campose.jettaptarget"
12 | minSdk 21
13 | targetSdk 34
14 | versionCode 1
15 | versionName "1.0"
16 |
17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18 | vectorDrawables {
19 | useSupportLibrary true
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_17
31 | targetCompatibility JavaVersion.VERSION_17
32 | }
33 | kotlinOptions {
34 | jvmTarget = '17'
35 | }
36 | buildFeatures {
37 | compose true
38 | }
39 | composeOptions {
40 | kotlinCompilerExtensionVersion compose_compiler_version
41 | }
42 | packagingOptions {
43 | resources {
44 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
45 | }
46 | }
47 | }
48 |
49 | dependencies {
50 | implementation project(path: ':showcase')
51 |
52 | implementation platform("androidx.compose:compose-bom:$compose_bom_version")
53 |
54 | implementation 'androidx.core:core-ktx:1.12.0'
55 | implementation "androidx.compose.ui:ui"
56 | implementation "androidx.compose.material:material"
57 | implementation "androidx.compose.ui:ui-tooling-preview"
58 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
59 | implementation 'androidx.activity:activity-compose:1.8.2'
60 | testImplementation 'junit:junit:4.13.2'
61 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
62 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
63 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.5.4"
64 | debugImplementation "androidx.compose.ui:ui-tooling"
65 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/canopas/campose/showcase/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.campose.showcase
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | /**
10 | * Instrumented test, which will execute on an Android device.
11 | *
12 | * See [testing documentation](http://d.android.com/tools/testing).
13 | */
14 | @RunWith(AndroidJUnit4::class)
15 | class ExampleInstrumentedTest {
16 | @Test
17 | fun useAppContext() {
18 | // Context of the app under test.
19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
20 | assertEquals("com.canopas.campose.jettaptarget", appContext.packageName)
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/canopas/campose/showcase/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.campose.showcase
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.Image
7 | import androidx.compose.foundation.layout.Arrangement
8 | import androidx.compose.foundation.layout.Box
9 | import androidx.compose.foundation.layout.Column
10 | import androidx.compose.foundation.layout.Row
11 | import androidx.compose.foundation.layout.Spacer
12 | import androidx.compose.foundation.layout.fillMaxHeight
13 | import androidx.compose.foundation.layout.fillMaxSize
14 | import androidx.compose.foundation.layout.fillMaxWidth
15 | import androidx.compose.foundation.layout.height
16 | import androidx.compose.foundation.layout.padding
17 | import androidx.compose.foundation.layout.size
18 | import androidx.compose.foundation.shape.CircleShape
19 | import androidx.compose.material.Button
20 | import androidx.compose.material.FloatingActionButton
21 | import androidx.compose.material.FloatingActionButtonDefaults
22 | import androidx.compose.material.Icon
23 | import androidx.compose.material.IconButton
24 | import androidx.compose.material.MaterialTheme
25 | import androidx.compose.material.Scaffold
26 | import androidx.compose.material.Surface
27 | import androidx.compose.material.Text
28 | import androidx.compose.material.TopAppBar
29 | import androidx.compose.material.icons.Icons
30 | import androidx.compose.material.icons.filled.ArrowBack
31 | import androidx.compose.material.icons.filled.Email
32 | import androidx.compose.material.icons.filled.Search
33 | import androidx.compose.runtime.Composable
34 | import androidx.compose.runtime.getValue
35 | import androidx.compose.runtime.mutableStateOf
36 | import androidx.compose.runtime.remember
37 | import androidx.compose.runtime.setValue
38 | import androidx.compose.ui.Alignment
39 | import androidx.compose.ui.Modifier
40 | import androidx.compose.ui.draw.clip
41 | import androidx.compose.ui.graphics.Color
42 | import androidx.compose.ui.res.painterResource
43 | import androidx.compose.ui.text.font.FontWeight
44 | import androidx.compose.ui.text.style.TextAlign
45 | import androidx.compose.ui.unit.dp
46 | import androidx.compose.ui.unit.sp
47 | import com.canopas.campose.showcase.ui.theme.JetTapTargetTheme
48 | import com.canopas.campose.showcase.ui.theme.ThemeColor
49 | import com.canopas.lib.showcase.IntroShowcase
50 | import com.canopas.lib.showcase.IntroShowcaseScope
51 | import com.canopas.lib.showcase.component.IntroShowcaseState
52 | import com.canopas.lib.showcase.component.ShowcaseStyle
53 | import com.canopas.lib.showcase.component.rememberIntroShowcaseState
54 |
55 | class MainActivity : ComponentActivity() {
56 | override fun onCreate(savedInstanceState: Bundle?) {
57 | super.onCreate(savedInstanceState)
58 |
59 | setContent {
60 | JetTapTargetTheme {
61 | // A surface container using the 'background' color from the theme
62 | Surface(
63 | modifier = Modifier
64 | .fillMaxSize(),
65 | color = MaterialTheme.colors.background
66 | ) {
67 | ShowcaseSample()
68 | }
69 | }
70 | }
71 | }
72 | }
73 |
74 | @Composable
75 | fun ShowcaseSample() {
76 | var showAppIntro by remember {
77 | mutableStateOf(true)
78 | }
79 |
80 | val introShowcaseState = rememberIntroShowcaseState()
81 |
82 | IntroShowcase(
83 | showIntroShowCase = showAppIntro,
84 | dismissOnClickOutside = false,
85 | onShowCaseCompleted = {
86 | //App Intro finished!!
87 | showAppIntro = false
88 | },
89 | state = introShowcaseState,
90 | ) {
91 | Scaffold(
92 | modifier = Modifier.fillMaxSize(),
93 | topBar = {
94 | TopAppBar(
95 | title = { },
96 | backgroundColor = Color.Transparent,
97 | elevation = 0.dp,
98 | navigationIcon = {
99 | BackButton(introShowcaseState)
100 | },
101 | actions = {
102 | IconButton(
103 | onClick = {},
104 | modifier = Modifier.introShowCaseTarget(
105 | index = 0,
106 | style = ShowcaseStyle.Default.copy(
107 | backgroundColor = Color(0xFF9AD0EC), // specify color of background
108 | backgroundAlpha = 0.98f, // specify transparency of background
109 | targetCircleColor = Color.White // specify color of target circle
110 | ),
111 | content = {
112 | Column {
113 | Image(
114 | painterResource(id = R.drawable.search_example),
115 | contentDescription = null,
116 | modifier = Modifier.size(100.dp)
117 | )
118 |
119 | Text(
120 | text = "Search anything!!",
121 | color = Color.Black,
122 | fontSize = 24.sp,
123 | fontWeight = FontWeight.Bold
124 | )
125 | Text(
126 | text = "You can search anything by clicking here.",
127 | color = Color.Black,
128 | fontSize = 16.sp
129 | )
130 | }
131 | }
132 | )
133 | ) {
134 | Icon(Icons.Filled.Search, contentDescription = "Search")
135 | }
136 | }
137 | )
138 | },
139 | floatingActionButton = {
140 | FloatingMailButton()
141 | }
142 | ) {
143 | Content(Modifier.padding(it))
144 | }
145 | }
146 | }
147 |
148 |
149 | @Composable
150 | fun IntroShowcaseScope.FloatingMailButton() {
151 | FloatingActionButton(
152 | onClick = {},
153 | modifier = Modifier.introShowCaseTarget(
154 | index = 1,
155 | style = ShowcaseStyle.Default.copy(
156 | backgroundColor = Color(0xFF1C0A00), // specify color of background
157 | backgroundAlpha = 0.98f, // specify transparency of background
158 | targetCircleColor = Color.White // specify color of target circle
159 | ),
160 | // specify the content to show to introduce app feature
161 | content = {
162 | Column {
163 | Text(
164 | text = "Check emails",
165 | color = Color.White,
166 | fontSize = 24.sp,
167 | fontWeight = FontWeight.Bold
168 | )
169 | Text(
170 | text = "Click here to check/send emails",
171 | color = Color.White,
172 | fontSize = 16.sp
173 | )
174 | Spacer(modifier = Modifier.height(10.dp))
175 | Icon(
176 | painterResource(id = R.drawable.right_arrow),
177 | contentDescription = null,
178 | modifier = Modifier
179 | .size(80.dp)
180 | .align(Alignment.End),
181 | tint = Color.White
182 | )
183 | }
184 | }
185 | ),
186 | backgroundColor = ThemeColor,
187 | contentColor = Color.White,
188 | elevation = FloatingActionButtonDefaults.elevation(6.dp)
189 | ) {
190 | Icon(
191 | Icons.Filled.Email,
192 | contentDescription = "Email"
193 | )
194 | }
195 |
196 | }
197 |
198 | @Composable
199 | fun IntroShowcaseScope.BackButton(introShowcaseState: IntroShowcaseState) {
200 | IconButton(
201 | onClick = {},
202 | modifier = Modifier.introShowCaseTarget(
203 | index = 4,
204 | style = ShowcaseStyle.Default.copy(
205 | backgroundColor = Color(0xFF7C99AC), // specify color of background
206 | backgroundAlpha = 0.98f, // specify transparency of background
207 | targetCircleColor = Color.White // specify color of target circle
208 | ),
209 | content = {
210 | Row(verticalAlignment = Alignment.CenterVertically) {
211 | Image(
212 | painterResource(id = R.drawable.go_back),
213 | contentDescription = null,
214 | modifier = Modifier
215 | .size(100.dp)
216 | .padding(top = 10.dp)
217 | )
218 | Column {
219 | Text(
220 | text = "Go back!!",
221 | color = Color.White,
222 | fontSize = 24.sp,
223 | fontWeight = FontWeight.Bold
224 | )
225 | Text(
226 | text = "You can go back by clicking here.",
227 | color = Color.White,
228 | fontSize = 16.sp
229 | )
230 |
231 | Button(
232 | onClick = {
233 | // Used to restart the intro showcase
234 | introShowcaseState.reset()
235 | },
236 | ) {
237 | Text(text = "Restart Intro")
238 | }
239 | }
240 | }
241 | },
242 | )
243 | ) {
244 | Icon(Icons.Filled.ArrowBack, contentDescription = "Search")
245 | }
246 | }
247 |
248 | @Composable
249 | fun IntroShowcaseScope.Content(modifier: Modifier) {
250 | Box(modifier = modifier.fillMaxSize()) {
251 | Box(modifier = Modifier.fillMaxHeight(0.3f)) {
252 |
253 | Column(
254 | Modifier
255 | .align(Alignment.BottomStart)
256 | .fillMaxWidth()
257 | .padding(16.dp)
258 | .height(90.dp),
259 | verticalArrangement = Arrangement.Center,
260 | horizontalAlignment = Alignment.CenterHorizontally
261 | ) {
262 |
263 | Text(
264 | text = "Intro Showcase view", fontWeight = FontWeight.Bold,
265 | fontSize = 24.sp, color = ThemeColor
266 | )
267 | Text(
268 | text = "This is an example of Intro Showcase view",
269 | fontSize = 20.sp, color = Color.Black, textAlign = TextAlign.Center
270 | )
271 |
272 | }
273 |
274 | Image(
275 | painter = painterResource(id = R.drawable.ic_unknown_profile),
276 | contentDescription = null,
277 | modifier = Modifier
278 | .align(Alignment.TopCenter)
279 | .clip(CircleShape)
280 | .introShowCaseTarget(
281 | index = 2, // specify index to show feature in order
282 | // ShowcaseStyle is optional
283 | style = ShowcaseStyle.Default.copy(
284 | backgroundColor = Color(0xFFFFCC80), // specify color of background
285 | backgroundAlpha = 0.98f, // specify transparency of background
286 | targetCircleColor = Color.White // specify color of target circle
287 | ),
288 | content = {
289 | Column(
290 | horizontalAlignment = Alignment.CenterHorizontally,
291 | modifier = Modifier
292 | .fillMaxWidth()
293 | .padding(top = 20.dp)
294 | ) {
295 | Text(
296 | text = "User profile",
297 | color = Color.White,
298 | fontSize = 24.sp,
299 | fontWeight = FontWeight.Bold
300 | )
301 | Text(
302 | text = "Click here to update your profile",
303 | color = Color.White,
304 | fontSize = 16.sp
305 | )
306 | }
307 | }
308 | )
309 | )
310 | }
311 |
312 | Button(
313 | onClick = {},
314 | modifier = Modifier
315 | .align(Alignment.BottomStart)
316 | .padding(start = 16.dp, bottom = 16.dp)
317 | .introShowCaseTarget(
318 | index = 3,
319 | content = {
320 | Column {
321 | Text(
322 | text = "Follow me",
323 | color = Color.White,
324 | fontSize = 24.sp,
325 | fontWeight = FontWeight.Bold
326 | )
327 | Text(
328 | text = "Click here to follow",
329 | color = Color.White,
330 | fontSize = 16.sp
331 | )
332 | }
333 | }
334 | )
335 | ) {
336 | Text(text = "Follow")
337 | }
338 | }
339 |
340 | }
341 |
342 |
--------------------------------------------------------------------------------
/app/src/main/java/com/canopas/campose/showcase/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.campose.showcase.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Teal200 = Color(0xFF03DAC5)
6 | val WhiteSecondary = Color(0xFFF5F5F5)
7 | val ThemeColor = Color(0xFFFB709A)
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/canopas/campose/showcase/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.campose.showcase.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/canopas/campose/showcase/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.campose.showcase.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = ThemeColor,
11 | primaryVariant = ThemeColor,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = ThemeColor,
17 | primaryVariant = ThemeColor,
18 | secondary = Teal200,
19 | background = WhiteSecondary,
20 | surface = WhiteSecondary,
21 | /* Other default colors to override
22 | background = Color.White,
23 | surface = Color.White,
24 | onPrimary = Color.White,
25 | onSecondary = Color.Black,
26 | onBackground = Color.Black,
27 | onSurface = Color.Black,
28 | */
29 | )
30 |
31 | @Composable
32 | fun JetTapTargetTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
33 | val colors = if (darkTheme) {
34 | DarkColorPalette
35 | } else {
36 | LightColorPalette
37 | }
38 |
39 | MaterialTheme(
40 | colors = colors,
41 | typography = Typography,
42 | shapes = Shapes,
43 | content = content
44 | )
45 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/canopas/campose/showcase/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.campose.showcase.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_unknown_profile.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/go_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/drawable/go_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/drawable/right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/search_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/drawable/search_example.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 | #F5F5F5
11 | #FFFF7373
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Intro Showcase
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/test/java/com/canopas/campose/showcase/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.campose.showcase
2 |
3 | import org.junit.Assert.assertEquals
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * See [testing documentation](http://d.android.com/tools/testing).
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | assertEquals(4, 2 + 2)
15 | }
16 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | compose_version = '1.1.0-beta04'
4 | compose_bom_version = "2023.10.01"
5 | compose_compiler_version = "1.5.3"
6 | }
7 |
8 | }// Top-level build file where you can add configuration options common to all sub-projects/modules.
9 | plugins {
10 | id 'com.android.application' version '8.1.1' apply false
11 | id 'com.android.library' version '8.1.1' apply false
12 | id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
13 | id 'io.github.gradle-nexus.publish-plugin' version "1.3.0"
14 | }
15 |
16 | apply from: "${rootDir}/scripts/publish-root.gradle"
17 |
18 | task clean(type: Delete) {
19 | delete rootProject.buildDir
20 | }
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
2 | show_downloads: true
3 |
--------------------------------------------------------------------------------
/docs/assets/4- intro showcase.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/docs/assets/4- intro showcase.jpg
--------------------------------------------------------------------------------
/docs/assets/intro2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/docs/assets/intro2.gif
--------------------------------------------------------------------------------
/docs/assets/intro3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/docs/assets/intro3.gif
--------------------------------------------------------------------------------
/docs/assets/main_intro.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/docs/assets/main_intro.gif
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | # Intro Showcase View
2 | []( https://android-arsenal.com/details/1/8387 )
3 |
4 |
5 |
6 |
7 |
8 |
9 | An android library to highlight different features of the app built using Jetpack Compose.
10 |
11 | The library is inspired by the [TapTargetView](https://github.com/KeepSafe/TapTargetView) that is useful for legacy views.
12 |
13 |
14 |
15 |
16 | ## Configuration
17 |
18 | Available on [Maven Central](https://search.maven.org/artifact/com.canopas.intro-showcase-view/introshowcaseview).
19 |
20 | Add the dependency
21 | ```gradle
22 | implementation 'com.canopas.intro-showcase-view:introshowcaseview:'
23 | ```
24 |
25 | ## How to use ?
26 | ```kotlin
27 | @Composable
28 | fun ShowcaseSample() {
29 | var showAppIntro by remember {
30 | mutableStateOf(true)
31 | }
32 |
33 | IntroShowcase(
34 | showIntroShowCase = showAppIntro,
35 | dismissOnClickOutside = false,
36 | onShowCaseCompleted = {
37 | //App Intro finished!!
38 | showAppIntro = false
39 | },
40 | ) {
41 | FloatingActionButton(
42 | onClick = {},
43 | modifier = Modifier.introShowCaseTarget(
44 | index = 0,
45 | style = ShowcaseStyle.Default.copy(
46 | backgroundColor = Color(0xFF1C0A00), // specify color of background
47 | backgroundAlpha = 0.98f, // specify transparency of background
48 | targetCircleColor = Color.White // specify color of target circle
49 | ),
50 | // specify the content to show to introduce app feature
51 | content = {
52 | Column {
53 | Text(
54 | text = "Check emails",
55 | color = Color.White,
56 | fontSize = 24.sp,
57 | fontWeight = FontWeight.Bold
58 | )
59 | Text(
60 | text = "Click here to check/send emails",
61 | color = Color.White,
62 | fontSize = 16.sp
63 | )
64 | Spacer(modifier = Modifier.height(10.dp))
65 | Icon(
66 | painterResource(id = R.drawable.right_arrow),
67 | contentDescription = null,
68 | modifier = Modifier
69 | .size(80.dp)
70 | .align(Alignment.End),
71 | tint = Color.White
72 | )
73 | }
74 | }
75 | ),
76 | backgroundColor = ThemeColor,
77 | contentColor = Color.White,
78 | elevation = FloatingActionButtonDefaults.elevation(6.dp)
79 | ) {
80 | Icon(
81 | Icons.Filled.Email,
82 | contentDescription = "Email"
83 | )
84 | }
85 | }
86 | }
87 | ```
88 |
89 |
90 | # Demo
91 | [Sample](https://github.com/canopas/compose-intro-showcase/tree/master/app) app demonstrates how simple the usage of the library actually is.
92 |
93 | # Interested in library implementation?
94 | Checkout the [Article](https://blog.canopas.com/intro-showcase-view-in-jetpack-compose-ac044cd3bf28)
95 |
96 | # Bugs and Feedback
97 | For bugs, questions and discussions please use the [Github Issues](https://github.com/canopas/compose-intro-showcase/issues).
98 |
99 | # Credits
100 |
101 | Intro showcaseview is owned and maintained by the [Canopas team](https://canopas.com/). You can follow them on X at [@canopassoftware](https://x.com/canopassoftware) for project updates and releases.
102 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Dec 14 16:33:00 IST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/scripts/publish-module.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'signing'
3 |
4 | tasks.register('androidSourcesJar', Jar) {
5 | archiveClassifier.set('sources')
6 | if (project.plugins.findPlugin("com.android.library")) {
7 | from android.sourceSets.main.java.srcDirs
8 | } else {
9 | from sourceSets.main.java.srcDirs
10 | }
11 | }
12 |
13 |
14 | artifacts {
15 | archives androidSourcesJar
16 | }
17 | group = PUBLISH_GROUP_ID
18 | version = rootProject.ext["publish_version"]
19 |
20 | afterEvaluate {
21 | publishing {
22 | publications {
23 | release(MavenPublication) {
24 | tasks.named("generateMetadataFileForReleasePublication").configure { dependsOn("androidSourcesJar") }
25 |
26 | // The coordinates of the library, being set from variables that
27 | // we'll set up later
28 | groupId PUBLISH_GROUP_ID
29 | artifactId PUBLISH_ARTIFACT_ID
30 | version rootProject.ext["publish_version"]
31 |
32 | /// Two artifacts, the `aar` (or `jar`) and the sources
33 | if (project.plugins.findPlugin("com.android.library")) {
34 | from components.release
35 | } else {
36 | artifact("$buildDir/libs/${project.getName()}-${version}.jar")
37 | }
38 |
39 | // Mostly self-explanatory metadata
40 | pom {
41 | name = PUBLISH_ARTIFACT_ID
42 | description = 'Highlight different features of the app using Jetpack Compose'
43 | url = 'https://github.com/canopas/Intro-showcase-view'
44 | licenses {
45 | license {
46 | name = 'License'
47 | url = 'https://github.com/canopas/Intro-showcase-view/blob/master/License'
48 | }
49 | }
50 | developers {
51 | developer {
52 | id = 'cp-radhika-s'
53 | name = 'Radhika canopas'
54 | email = 'radhika.s@canopas.com'
55 | }
56 | // Add all other devs here...
57 | }
58 |
59 | // Version control info - if you're using GitHub, follow the
60 | // format as seen here
61 | scm {
62 | connection = 'scm:git:github.com/canopas/Intro-showcase-view.git'
63 | developerConnection = 'scm:git:ssh://github.com/canopas/Intro-showcase-view.git'
64 | url = 'https://github.com/canopas/Intro-showcase-view.git'
65 | }
66 | }
67 | }
68 | }
69 | }
70 | }
71 | signing {
72 | useInMemoryPgpKeys(
73 | rootProject.ext["signing.keyId"],
74 | rootProject.ext["signing.key"],
75 | rootProject.ext["signing.password"],
76 | )
77 |
78 | sign publishing.publications
79 | }
--------------------------------------------------------------------------------
/scripts/publish-root.gradle:
--------------------------------------------------------------------------------
1 | // Create variables with empty default values
2 | ext["ossrhUsername"] = ''
3 | ext["ossrhPassword"] = ''
4 | ext["sonatypeStagingProfileId"] = ''
5 | ext["signing.keyId"] = ''
6 | ext["signing.password"] = ''
7 | ext["signing.key"] = ''
8 | ext["snapshot"] = ''
9 | ext["publish_version"] = ''
10 |
11 | File secretPropsFile = project.rootProject.file('local.properties')
12 |
13 | if (secretPropsFile.exists()) {
14 |
15 | // Read local.properties file first if it exists
16 |
17 | Properties p = new Properties()
18 |
19 | new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
20 |
21 | p.each { name, value -> ext[name] = value }
22 |
23 | } else {
24 | // Use system environment variables
25 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
26 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
27 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
28 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
29 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
30 | ext["signing.key"] = System.getenv('SIGNING_KEY')
31 | ext["snapshot"] = System.getenv('SNAPSHOT')
32 | ext["publish_version"] = System.getenv('PUBLISH_VERSION')
33 | }
34 |
35 | // Set up Sonatype repository
36 | nexusPublishing {
37 | repositories {
38 | sonatype {
39 | stagingProfileId = sonatypeStagingProfileId
40 | username = ossrhUsername
41 | password = ossrhPassword
42 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
43 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "JetTapTarget"
16 | include ':app'
17 | include ':showcase'
18 |
--------------------------------------------------------------------------------
/showcase/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | .idea
--------------------------------------------------------------------------------
/showcase/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'org.jetbrains.kotlin.android'
4 | }
5 |
6 | ext {
7 | PUBLISH_GROUP_ID = 'com.canopas.intro-showcase-view'
8 | PUBLISH_ARTIFACT_ID = 'introshowcaseview'
9 | }
10 |
11 | apply from: "${rootDir}/scripts/publish-module.gradle"
12 |
13 | android {
14 | namespace = "com.canopas.lib.showcase"
15 |
16 | compileSdk 34
17 |
18 | defaultConfig {
19 | minSdk 21
20 | targetSdk 34
21 |
22 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
23 | consumerProguardFiles "consumer-rules.pro"
24 | }
25 |
26 | buildTypes {
27 | release {
28 | minifyEnabled false
29 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
30 | }
31 | }
32 |
33 | compileOptions {
34 | sourceCompatibility JavaVersion.VERSION_17
35 | targetCompatibility JavaVersion.VERSION_17
36 | }
37 | kotlinOptions {
38 | jvmTarget = '17'
39 | }
40 | buildFeatures {
41 | compose true
42 | }
43 | composeOptions {
44 | kotlinCompilerExtensionVersion compose_compiler_version
45 | }
46 | publishing {
47 | singleVariant("release") {
48 | withSourcesJar()
49 | }
50 | }
51 | }
52 |
53 | dependencies {
54 |
55 | implementation platform("androidx.compose:compose-bom:$compose_bom_version")
56 |
57 | implementation 'androidx.core:core-ktx:1.12.0'
58 | implementation 'androidx.appcompat:appcompat:1.6.1'
59 | implementation 'com.google.android.material:material:1.11.0'
60 | implementation 'androidx.compose.ui:ui:'
61 | testImplementation 'junit:junit:4.13.2'
62 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
63 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
64 |
65 | implementation "androidx.compose.ui:ui"
66 | implementation "androidx.compose.material:material"
67 | implementation "androidx.compose.ui:ui-tooling-preview"
68 | implementation "androidx.compose.material:material-icons-extended"
69 | }
70 |
--------------------------------------------------------------------------------
/showcase/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/canopas/compose-intro-showcase/a520a4733d7a85ebb1a74a88a1acf5d9e9f6b0cc/showcase/consumer-rules.pro
--------------------------------------------------------------------------------
/showcase/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/showcase/src/androidTest/java/com/canopas/lib/showcase/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.lib.showcase
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | /**
10 | * Instrumented test, which will execute on an Android device.
11 | *
12 | * See [testing documentation](http://d.android.com/tools/testing).
13 | */
14 | @RunWith(AndroidJUnit4::class)
15 | class ExampleInstrumentedTest {
16 | @Test
17 | fun useAppContext() {
18 | // Context of the app under test.
19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
20 | assertEquals("com.canopas.campose.showcase.test", appContext.packageName)
21 | }
22 | }
--------------------------------------------------------------------------------
/showcase/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/showcase/src/main/java/com/canopas/lib/showcase/IntroShowcase.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.lib.showcase
2 |
3 | import androidx.compose.foundation.layout.BoxScope
4 | import androidx.compose.runtime.Composable
5 | import androidx.compose.runtime.remember
6 | import androidx.compose.ui.Modifier
7 | import com.canopas.lib.showcase.component.IntroShowcaseState
8 | import com.canopas.lib.showcase.component.ShowcasePopup
9 | import com.canopas.lib.showcase.component.ShowcaseStyle
10 | import com.canopas.lib.showcase.component.introShowcaseTarget
11 | import com.canopas.lib.showcase.component.rememberIntroShowcaseState
12 |
13 | @Composable
14 | fun IntroShowcase(
15 | showIntroShowCase: Boolean,
16 | onShowCaseCompleted: () -> Unit,
17 | state: IntroShowcaseState = rememberIntroShowcaseState(),
18 | dismissOnClickOutside: Boolean = false,
19 | content: @Composable IntroShowcaseScope.() -> Unit,
20 | ) {
21 | val scope = remember(state) {
22 | IntroShowcaseScope(state)
23 | }
24 |
25 | scope.content()
26 |
27 | if (showIntroShowCase) {
28 | ShowcasePopup(
29 | state = state,
30 | dismissOnClickOutside = dismissOnClickOutside,
31 | onShowCaseCompleted = onShowCaseCompleted,
32 | )
33 | }
34 | }
35 |
36 |
37 | class IntroShowcaseScope(
38 | private val state: IntroShowcaseState,
39 | ) {
40 |
41 | /**
42 | * Modifier that marks Compose UI element as a target for [IntroShowcase]
43 | */
44 | fun Modifier.introShowCaseTarget(
45 | index: Int,
46 | style: ShowcaseStyle = ShowcaseStyle.Default,
47 | content: @Composable BoxScope.() -> Unit,
48 | ): Modifier = introShowcaseTarget(
49 | state = state,
50 | index = index,
51 | style = style,
52 | content = content,
53 | )
54 | }
55 |
--------------------------------------------------------------------------------
/showcase/src/main/java/com/canopas/lib/showcase/component/IntroShowcaseState.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.lib.showcase.component
2 |
3 | import androidx.compose.foundation.layout.BoxScope
4 | import androidx.compose.runtime.Composable
5 | import androidx.compose.runtime.getValue
6 | import androidx.compose.runtime.mutableIntStateOf
7 | import androidx.compose.runtime.mutableStateMapOf
8 | import androidx.compose.runtime.remember
9 | import androidx.compose.runtime.setValue
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.layout.onGloballyPositioned
12 |
13 | /**
14 | * Creates a [IntroShowcaseState] that is remembered across compositions.
15 | *
16 | * Changes to the provided values for [initialIndex] will **not** result in the state being
17 | * recreated or changed in any way if it has already
18 | * been created.
19 | *
20 | * @param initialIndex the initial value for [IntroShowcaseState.currentTargetIndex]
21 | */
22 | @Composable
23 | fun rememberIntroShowcaseState(
24 | initialIndex: Int = 0,
25 | ): IntroShowcaseState {
26 | return remember {
27 | IntroShowcaseState(
28 | initialIndex = initialIndex,
29 | )
30 | }
31 | }
32 |
33 | /**
34 | * Modifier that marks Compose UI element as a target for [IntroShowCaseTarget]
35 | */
36 | internal fun Modifier.introShowcaseTarget(
37 | state: IntroShowcaseState,
38 | index: Int,
39 | style: ShowcaseStyle = ShowcaseStyle.Default,
40 | content: @Composable BoxScope.() -> Unit,
41 | ): Modifier = onGloballyPositioned { coordinates ->
42 | state.targets[index] = IntroShowcaseTargets(
43 | index = index,
44 | coordinates = coordinates,
45 | style = style,
46 | content = content
47 | )
48 | }
49 |
50 | /**
51 | * State class for managing the state of the IntroShowcase. Tracks the current target index and
52 | * associated targets.
53 | */
54 | class IntroShowcaseState internal constructor(
55 | initialIndex: Int,
56 | ) {
57 |
58 | internal var targets = mutableStateMapOf()
59 |
60 | var currentTargetIndex by mutableIntStateOf(initialIndex)
61 | internal set
62 |
63 | val currentTarget: IntroShowcaseTargets?
64 | get() = targets[currentTargetIndex]
65 |
66 | /**
67 | * Resets the state to its initial values, effectively restarting the showcase.
68 | */
69 | fun reset() {
70 | currentTargetIndex = 0
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/showcase/src/main/java/com/canopas/lib/showcase/component/ShowcaseComposeView.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.lib.showcase.component
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.graphics.PixelFormat
6 | import android.view.View
7 | import android.view.WindowManager
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.runtime.CompositionContext
10 | import androidx.compose.runtime.DisposableEffect
11 | import androidx.compose.runtime.getValue
12 | import androidx.compose.runtime.mutableStateOf
13 | import androidx.compose.runtime.remember
14 | import androidx.compose.runtime.rememberCompositionContext
15 | import androidx.compose.runtime.rememberUpdatedState
16 | import androidx.compose.runtime.saveable.rememberSaveable
17 | import androidx.compose.runtime.setValue
18 | import androidx.compose.ui.R
19 | import androidx.compose.ui.platform.AbstractComposeView
20 | import androidx.compose.ui.platform.LocalView
21 | import androidx.lifecycle.findViewTreeLifecycleOwner
22 | import androidx.lifecycle.findViewTreeViewModelStoreOwner
23 | import androidx.lifecycle.setViewTreeLifecycleOwner
24 | import androidx.lifecycle.setViewTreeViewModelStoreOwner
25 | import androidx.savedstate.findViewTreeSavedStateRegistryOwner
26 | import androidx.savedstate.setViewTreeSavedStateRegistryOwner
27 | import java.util.UUID
28 |
29 | @Composable
30 | fun ShowcaseWindow(content: @Composable () -> Unit) {
31 | val view = LocalView.current
32 | val parentComposition = rememberCompositionContext()
33 | val currentContent by rememberUpdatedState(content)
34 | val id = rememberSaveable { UUID.randomUUID() }
35 |
36 | val composeView = remember {
37 | ShowcaseComposeView(
38 | view,
39 | id
40 | ).apply {
41 | setContent(parentComposition) {
42 | currentContent()
43 | }
44 | }
45 | }
46 |
47 | DisposableEffect(composeView) {
48 | composeView.show()
49 | onDispose { composeView.dismiss() }
50 | }
51 | }
52 |
53 |
54 | @SuppressLint("ViewConstructor")
55 | class ShowcaseComposeView(
56 | private val composeView: View,
57 | uniqueId: UUID
58 | ) : AbstractComposeView(composeView.context) {
59 |
60 | private val windowManager =
61 | composeView.context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
62 |
63 | private val params = createLayoutParams()
64 |
65 | override var shouldCreateCompositionOnAttachedToWindow: Boolean = false
66 | private set
67 |
68 | init {
69 | id = android.R.id.content
70 | setViewTreeLifecycleOwner(composeView.findViewTreeLifecycleOwner())
71 | setViewTreeViewModelStoreOwner(composeView.findViewTreeViewModelStoreOwner())
72 | setViewTreeSavedStateRegistryOwner(composeView.findViewTreeSavedStateRegistryOwner())
73 | setTag(R.id.compose_view_saveable_id_tag, "Popup:$uniqueId")
74 | }
75 |
76 | private var content: @Composable () -> Unit by mutableStateOf({})
77 |
78 | @Composable
79 | override fun Content() {
80 | content()
81 | }
82 |
83 | fun setContent(parent: CompositionContext, content: @Composable () -> Unit) {
84 | setParentCompositionContext(parent)
85 | this.content = content
86 | shouldCreateCompositionOnAttachedToWindow = true
87 | }
88 |
89 | private fun createLayoutParams(): WindowManager.LayoutParams =
90 | WindowManager.LayoutParams().apply {
91 | type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL
92 | token = composeView.applicationWindowToken
93 | width = WindowManager.LayoutParams.MATCH_PARENT
94 | height = WindowManager.LayoutParams.MATCH_PARENT
95 | format = PixelFormat.TRANSLUCENT
96 | flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
97 | }
98 |
99 | fun show() {
100 | windowManager.addView(this, params)
101 | }
102 |
103 | fun dismiss() {
104 | disposeComposition()
105 | setViewTreeLifecycleOwner(null)
106 | windowManager.removeViewImmediate(this)
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/showcase/src/main/java/com/canopas/lib/showcase/component/ShowcaseContent.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.lib.showcase.component
2 |
3 | import androidx.compose.animation.core.Animatable
4 | import androidx.compose.animation.core.FastOutLinearInEasing
5 | import androidx.compose.animation.core.FastOutSlowInEasing
6 | import androidx.compose.animation.core.RepeatMode
7 | import androidx.compose.animation.core.infiniteRepeatable
8 | import androidx.compose.animation.core.tween
9 | import androidx.compose.foundation.Canvas
10 | import androidx.compose.foundation.clickable
11 | import androidx.compose.foundation.gestures.detectTapGestures
12 | import androidx.compose.foundation.interaction.MutableInteractionSource
13 | import androidx.compose.foundation.layout.Box
14 | import androidx.compose.foundation.layout.BoxScope
15 | import androidx.compose.foundation.layout.fillMaxSize
16 | import androidx.compose.foundation.layout.offset
17 | import androidx.compose.foundation.layout.padding
18 | import androidx.compose.runtime.Composable
19 | import androidx.compose.runtime.LaunchedEffect
20 | import androidx.compose.runtime.Stable
21 | import androidx.compose.runtime.getValue
22 | import androidx.compose.runtime.mutableFloatStateOf
23 | import androidx.compose.runtime.mutableStateOf
24 | import androidx.compose.runtime.remember
25 | import androidx.compose.runtime.setValue
26 | import androidx.compose.ui.Modifier
27 | import androidx.compose.ui.draw.alpha
28 | import androidx.compose.ui.geometry.Offset
29 | import androidx.compose.ui.geometry.Rect
30 | import androidx.compose.ui.graphics.BlendMode
31 | import androidx.compose.ui.graphics.Color
32 | import androidx.compose.ui.graphics.graphicsLayer
33 | import androidx.compose.ui.input.pointer.pointerInput
34 | import androidx.compose.ui.layout.LayoutCoordinates
35 | import androidx.compose.ui.layout.boundsInWindow
36 | import androidx.compose.ui.layout.onGloballyPositioned
37 | import androidx.compose.ui.platform.LocalDensity
38 | import androidx.compose.ui.unit.dp
39 | import kotlinx.coroutines.delay
40 | import kotlinx.coroutines.launch
41 | import kotlin.math.absoluteValue
42 | import kotlin.math.max
43 | import kotlin.math.min
44 | import kotlin.math.pow
45 | import kotlin.math.sqrt
46 |
47 | @Composable
48 | fun ShowcasePopup(
49 | state: IntroShowcaseState,
50 | dismissOnClickOutside: Boolean,
51 | onShowCaseCompleted: () -> Unit,
52 | ) {
53 | state.currentTarget?.let {
54 | if (it.coordinates.isAttached) {
55 | ShowcaseWindow {
56 | ShowcaseContent(
57 | target = it,
58 | dismissOnClickOutside = dismissOnClickOutside
59 | ) {
60 | state.currentTargetIndex++
61 | if (state.currentTarget == null) {
62 | onShowCaseCompleted()
63 | }
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
70 | @Composable
71 | internal fun ShowcaseContent(
72 | target: IntroShowcaseTargets,
73 | dismissOnClickOutside: Boolean,
74 | onShowcaseCompleted: () -> Unit
75 | ) {
76 |
77 | val targetCords = target.coordinates
78 | val targetRect = targetCords.boundsInWindow()
79 |
80 | var dismissShowcaseRequest by remember(target) { mutableStateOf(false) }
81 |
82 | val maxDimension =
83 | max(targetCords.size.width.absoluteValue, targetCords.size.height.absoluteValue)
84 | val targetRadius = maxDimension / 2f + 40f
85 |
86 | val animationSpec = infiniteRepeatable(
87 | animation = tween(2000, easing = FastOutLinearInEasing),
88 | repeatMode = RepeatMode.Restart,
89 | )
90 |
91 | var outerOffset by remember(target) {
92 | mutableStateOf(Offset(0f, 0f))
93 | }
94 |
95 | var outerRadius by remember(target) {
96 | mutableFloatStateOf(0f)
97 | }
98 |
99 | val outerAnimatable = remember { Animatable(0.6f) }
100 | val outerAlphaAnimatable = remember(target) { Animatable(0f) }
101 |
102 | val animatables = remember(target) {
103 | listOf(
104 | Animatable(0f),
105 | Animatable(0f)
106 | )
107 | }
108 |
109 | LaunchedEffect(target) {
110 | outerAnimatable.snapTo(0.6f)
111 |
112 | outerAnimatable.animateTo(
113 | targetValue = 1f,
114 | animationSpec = tween(
115 | durationMillis = 500,
116 | easing = FastOutSlowInEasing,
117 | ),
118 | )
119 | }
120 |
121 | LaunchedEffect(target) {
122 | outerAlphaAnimatable.animateTo(
123 | targetValue = target.style.backgroundAlpha,
124 | animationSpec = tween(
125 | durationMillis = 500,
126 | easing = FastOutSlowInEasing,
127 | ),
128 | )
129 | }
130 |
131 | LaunchedEffect(dismissShowcaseRequest) {
132 | if (dismissShowcaseRequest) {
133 | launch {
134 | outerAlphaAnimatable.animateTo(
135 | 0f,
136 | animationSpec = tween(
137 | durationMillis = 200
138 | )
139 | )
140 | }
141 | launch {
142 | outerAnimatable.animateTo(
143 | targetValue = 0.6f,
144 | animationSpec = tween(
145 | durationMillis = 350,
146 | easing = FastOutSlowInEasing,
147 | )
148 | )
149 | }
150 | delay(350)
151 | onShowcaseCompleted()
152 | }
153 | }
154 |
155 | animatables.forEachIndexed { index, animatable ->
156 | LaunchedEffect(animatable) {
157 | delay(index * 1000L)
158 | animatable.animateTo(
159 | targetValue = 1f, animationSpec = animationSpec
160 | )
161 | }
162 | }
163 |
164 | val dys = animatables.map { it.value }
165 |
166 | Box(
167 | modifier = Modifier
168 | .alpha(outerAlphaAnimatable.value)
169 | ) {
170 | Canvas(
171 | modifier = Modifier
172 | .fillMaxSize()
173 | .pointerInput(target) {
174 | detectTapGestures { tapOffeset ->
175 | if (targetRect.contains(tapOffeset)) {
176 | dismissShowcaseRequest = true
177 | }
178 | }
179 | }
180 | .let {
181 | if (dismissOnClickOutside) {
182 | it.clickable(
183 | interactionSource = remember { MutableInteractionSource() },
184 | indication = null
185 | ) { dismissShowcaseRequest = true }
186 | } else it
187 | }
188 | .graphicsLayer(alpha = 0.99f)
189 | ) {
190 | drawCircle(
191 | color = target.style.backgroundColor,
192 | center = outerOffset,
193 | radius = outerRadius * outerAnimatable.value,
194 | alpha = target.style.backgroundAlpha
195 | )
196 |
197 | dys.forEach { dy ->
198 | drawCircle(
199 | color = target.style.targetCircleColor,
200 | radius = maxDimension * dy * 2f,
201 | center = targetRect.center,
202 | alpha = 1 - dy
203 | )
204 | }
205 |
206 | drawCircle(
207 | color = target.style.targetCircleColor,
208 | radius = targetRadius,
209 | center = targetRect.center,
210 | blendMode = BlendMode.Xor
211 | )
212 | }
213 |
214 | ShowCaseText(target, targetRect, targetRadius) { textCoords ->
215 | val contentRect = textCoords.boundsInWindow()
216 | val outerRect = getOuterRect(contentRect, targetRect)
217 | outerOffset = outerRect.center
218 | outerRadius = getOuterRadius(outerRect) + targetRadius
219 | }
220 | }
221 | }
222 |
223 |
224 | @Composable
225 | private fun ShowCaseText(
226 | currentTarget: IntroShowcaseTargets,
227 | boundsInParent: Rect,
228 | targetRadius: Float,
229 | updateContentCoordinates: (LayoutCoordinates) -> Unit
230 | ) {
231 |
232 | var contentOffsetY by remember(currentTarget) { mutableFloatStateOf(0f) }
233 |
234 | Box(
235 | content = currentTarget.content,
236 | modifier = Modifier
237 | .offset(y = with(LocalDensity.current) {
238 | contentOffsetY.toDp()
239 | })
240 | .onGloballyPositioned {
241 | updateContentCoordinates(it)
242 | val contentHeight = it.size.height
243 |
244 | val possibleTop =
245 | boundsInParent.center.y - targetRadius - contentHeight
246 |
247 | contentOffsetY = if (possibleTop > 0) {
248 | possibleTop
249 | } else {
250 | boundsInParent.center.y + targetRadius
251 | }
252 | }
253 | .padding(16.dp)
254 | )
255 |
256 | }
257 |
258 | private fun getOuterRect(contentRect: Rect, targetRect: Rect): Rect {
259 |
260 | val topLeftX = min(contentRect.topLeft.x, targetRect.topLeft.x)
261 | val topLeftY = min(contentRect.topLeft.y, targetRect.topLeft.y)
262 | val bottomRightX = max(contentRect.bottomRight.x, targetRect.bottomRight.x)
263 | val bottomRightY = max(contentRect.bottomRight.y, targetRect.bottomRight.y)
264 |
265 | return Rect(topLeftX, topLeftY, bottomRightX, bottomRightY)
266 | }
267 |
268 | private fun getOuterRadius(outerRect: Rect): Float {
269 | val d = sqrt(
270 | outerRect.height.toDouble().pow(2.0)
271 | + outerRect.width.toDouble().pow(2.0)
272 | ).toFloat()
273 |
274 | return (d / 2f)
275 | }
276 |
277 | data class IntroShowcaseTargets(
278 | val index: Int,
279 | val coordinates: LayoutCoordinates,
280 | val style: ShowcaseStyle = ShowcaseStyle.Default,
281 | val content: @Composable BoxScope.() -> Unit
282 | )
283 |
284 | class ShowcaseStyle(
285 | val backgroundColor: Color = Color.Black,
286 | /*@FloatRange(from = 0.0, to = 1.0)*/
287 | val backgroundAlpha: Float = DEFAULT_BACKGROUND_RADIUS,
288 | val targetCircleColor: Color = Color.White
289 | ) {
290 |
291 | fun copy(
292 | backgroundColor: Color = this.backgroundColor,
293 | /*@FloatRange(from = 0.0, to = 1.0)*/
294 | backgroundAlpha: Float = this.backgroundAlpha,
295 | targetCircleColor: Color = this.targetCircleColor
296 | ): ShowcaseStyle {
297 |
298 | return ShowcaseStyle(
299 | backgroundColor = backgroundColor,
300 | backgroundAlpha = backgroundAlpha,
301 | targetCircleColor = targetCircleColor
302 | )
303 | }
304 |
305 | companion object {
306 | private const val DEFAULT_BACKGROUND_RADIUS = 0.9f
307 |
308 | /**
309 | * Constant for default text style.
310 | */
311 | @Stable
312 | val Default = ShowcaseStyle()
313 | }
314 | }
--------------------------------------------------------------------------------
/showcase/src/test/java/com/canopas/campos/showcase/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.canopas.lib.showcase
2 |
3 | import org.junit.Assert.assertEquals
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * See [testing documentation](http://d.android.com/tools/testing).
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | assertEquals(4, 2 + 2)
15 | }
16 | }
--------------------------------------------------------------------------------