Skip to content

rranjithkumar100/Jetpack-Compose-Samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 

Repository files navigation

Jetpack-Compose-Samples

You can learn about jetpack compose with simple examples. Our blog - https://www.jetpackcompose.net/

Simple Text

	Text(
		text = "Text with Italic text",
		style = TextStyle(fontSize = 20.sp, fontStyle = FontStyle.Italic)
	)

image

Buttons

	@Composable
	fun ButtonWithIcon() {
		Button(onClick = {}) {
			Image(
	painterResource(id = R.drawable.ic_cart), 
	contentDescription ="Cart button icon",
	modifier = Modifier.size(20.dp))

			Text(text = "Add to cart",Modifier.padding(start = 10.dp))
		}
	}

image

Image

	@Composable
	fun CircleImageView() {
		Image(
			painter = painterResource(R.drawable.andy_rubin),
			contentDescription = "Circle Image",
			contentScale = ContentScale.Crop,            
			modifier = Modifier
				.size(128.dp)
				.clip(CircleShape) // clip to the circle shape
				.border(5.dp, Color.Gray, CircleShape)//optional
		)
	}

image

TextField

@Composable fun TextFieldWithIcons() { var text by remember { mutableStateOf(TextFieldValue("")) } return OutlinedTextField( value = text, leadingIcon = { Icon(imageVector = Icons.Default.Email, contentDescription = "emailIcon") }, //trailingIcon = { Icon(imageVector = Icons.Default.Add, contentDescription = null) }, onValueChange = { text = it }, label = { Text(text = "Email address") }, placeholder = { Text(text = "Enter your e-mail") }, ) }

image

Bottom Menu

	@Composable
	fun ScaffoldWithBottomMenu() {
		Scaffold(bottomBar = {BottomBar()}
		) {
		  //content area
		  Box(modifier = Modifier
		  .background(Color(0xff546e7a))
		  .fillMaxSize())
		}
	}

image

Animation

	@Composable
	private fun AnimateAsFloatContent() {
		var isRotated by rememberSaveable { mutableStateOf(false) }
		val rotationAngle by animateFloatAsState(
			targetValue = if (isRotated) 360F else 0f,
			animationSpec = tween(durationMillis = 2500)
		)
		Column(horizontalAlignment = Alignment.CenterHorizontally) {
			Image(
				painter = painterResource(R.drawable.fan),
				contentDescription = "fan",
				modifier = Modifier
					.rotate(rotationAngle)
					.size(150.dp)
			)

			Button(
				onClick = { isRotated = !isRotated },
				modifier = Modifier
					.padding(top = 50.dp)
					.width(200.dp)
			) {
				Text(text = "Rotate Fan")
			}
		}
	}

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages