Git Product home page Git Product logo

jetpack-compose-samples's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.