Last active
February 3, 2022 08:50
-
-
Save cp-radhika-s/db313e2f453fd028e9d98baf32bd4637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ShowcaseSample() { | |
val targets = remember { | |
mutableStateMapOf<String, ShowcaseProperty>() | |
} | |
Box { | |
Scaffold( | |
modifier = Modifier.fillMaxSize(), | |
topBar = { | |
TopAppBar( | |
title = { }, | |
backgroundColor = Color.Transparent, | |
elevation = 0.dp, | |
navigationIcon = { | |
IconButton(onClick = {}, | |
modifier = Modifier.onGloballyPositioned { coordinates -> | |
targets["back"] = ShowcaseProperty( | |
4, coordinates, | |
"Go back!!", "You can go back by clicking here." | |
) | |
}) { | |
Icon(Icons.Filled.ArrowBack, contentDescription = "Search") | |
} | |
}, | |
actions = { | |
IconButton( | |
onClick = {}, | |
modifier = Modifier.onGloballyPositioned { coordinates -> | |
targets["search"] = ShowcaseProperty( | |
3, coordinates, | |
"Search anything!!", "You can search anything by clicking here." | |
) | |
}, | |
) { | |
Icon(Icons.Filled.Search, contentDescription = "Search") | |
} | |
} | |
) | |
}, | |
floatingActionButton = { | |
FloatingActionButton( | |
onClick = {}, | |
modifier = Modifier.onGloballyPositioned { coordinates -> | |
targets["email"] = ShowcaseProperty( | |
1, coordinates, | |
"Check emails", "Click here to check/send emails" | |
) | |
}, | |
backgroundColor = ThemeColor, | |
contentColor = Color.White, | |
elevation = FloatingActionButtonDefaults.elevation(6.dp) | |
) { | |
Icon( | |
Icons.Filled.Email, | |
contentDescription = "Email" | |
) | |
} | |
} | |
) { | |
Box(modifier = Modifier.fillMaxSize()) { | |
Box(modifier = Modifier.fillMaxHeight(0.3f)) { | |
Column( | |
Modifier | |
.align(Alignment.BottomStart) | |
.fillMaxWidth() | |
.padding(16.dp) | |
.height(90.dp), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
Text( | |
text = "Intro Showcase view", fontWeight = FontWeight.Bold, | |
fontSize = 24.sp, color = ThemeColor | |
) | |
Text( | |
text = "This is an example of Intro Showcase view", | |
fontSize = 20.sp, color = Color.Black, textAlign = TextAlign.Center | |
) | |
} | |
Image( | |
painter = painterResource(id = R.drawable.ic_unknown_profile), | |
contentDescription = null, | |
modifier = Modifier | |
.align(Alignment.TopCenter) | |
.clip(CircleShape) | |
.onGloballyPositioned { coordinates -> | |
targets["profile"] = ShowcaseProperty( | |
0, coordinates, | |
"User profile", "Click here to update your profile" | |
) | |
} | |
) | |
} | |
Button( | |
onClick = {}, | |
modifier = Modifier | |
.align(Alignment.BottomStart) | |
.padding(start = 16.dp, bottom = 16.dp) | |
.onGloballyPositioned { coordinates -> | |
targets["follow"] = ShowcaseProperty( | |
2, coordinates, | |
"Follow me", "Click here to follow" | |
) | |
} | |
) { | |
Text(text = "Follow") | |
} | |
} | |
} | |
IntroShowCase(targets) { | |
targets.clear() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment