0% found this document useful (0 votes)
13 views8 pages

Mobile App Development with JetPack Compose

This document is a submission for a mobile application development assignment. It includes the submission date, student name submitting the work, instructor name, degree program and section, and department. The submission contains code for a Jetpack Compose Android app that displays a series of images, names, and authors. It uses Compose features like Box, Column, Surface, Image, Text, Buttons and remembers the current image using a remember state.

Uploaded by

MAZHAR ABBAS
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

Mobile App Development with JetPack Compose

This document is a submission for a mobile application development assignment. It includes the submission date, student name submitting the work, instructor name, degree program and section, and department. The submission contains code for a Jetpack Compose Android app that displays a series of images, names, and authors. It uses Compose features like Box, Column, Surface, Image, Text, Buttons and remembers the current image using a remember state.

Uploaded by

MAZHAR ABBAS
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MOBILE APPLICATION

DEVELOPMENT
(ASSIGNMENT # 02.... SEMESTER SPRING- 2023)
Submission date (9 July, 2023)
Submitted By:
Mazhar Abbas
Submitted To:
Mr. Ehtisham Rasheed

Degree Program Title and Section:


BS-VI Computer Science (A)

Department of Computer Science

1|Page
UI App Using JetPack Compose
package [Link]

import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link].*
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link].*
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
//import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]

class MainActivity : ComponentActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
[Link](savedInstanceState)
setContent {
ArtSpaceTheme {
// A surface container using the 'background' color from the
theme
Surface(
modifier = [Link](),
color = [Link]
) {
ArtSpaceApp()
}
}
}
}
}

@Composable
fun ArtSpaceApp() {
var currentImage by remember { mutableStateOf(1) }

2|Page
Surface(
modifier = [Link](),
color = [Link]
) {
when(currentImage) {
1 -> {
ArtSpaceImage(
imageResource = [Link],
nameResource = [Link],
authorResource = [Link],
onNextButtonClick = { currentImage = 2 },
onPreviousButtonClick = { currentImage = 3 })
}
2 -> {
ArtSpaceImage(
imageResource = [Link],
nameResource = [Link],
authorResource = [Link],
onNextButtonClick = { currentImage = 3 },
onPreviousButtonClick = { currentImage = 1 })
}
3 -> {
ArtSpaceImage(
imageResource = [Link],
nameResource = [Link],
authorResource = [Link],
onNextButtonClick = { currentImage = 1 },
onPreviousButtonClick = { currentImage = 2 })
}

}
}
}

@Composable
fun ArtSpaceImage(
imageResource: Int,
nameResource: Int,
authorResource: Int,
onNextButtonClick: () -> Unit,
onPreviousButtonClick: () -> Unit,
modifier: Modifier = Modifier
){
Box(modifier = Modifier
.fillMaxSize()
) {
Column(
horizontalAlignment = [Link],
verticalArrangement = [Link],
modifier = [Link]()
){
Surface(
elevation = [Link],
border = BorderStroke([Link], color = [Link])
){
Image(

3|Page
painter = painterResource(imageResource),
contentDescription = null,
modifier = [Link]([Link])
)
}
Spacer(modifier = [Link]([Link]))
Surface(
elevation = [Link],
modifier = Modifier
.align([Link])
.padding([Link], [Link])
) {
Column(modifier = Modifier
.background(color = Color(red=236, green = 235, blue =
244))
// .background([Link])
) {
Text(
text = stringResource(nameResource),
modifier = Modifier
.padding([Link], [Link], [Link], [Link]),
fontSize = [Link],
color = [Link],
fontFamily = FontFamily(Font([Link]))
)
Text(
text = stringResource(authorResource),
modifier = [Link]([Link], [Link], [Link],
[Link]),
fontWeight = [Link],
fontSize = [Link],
fontFamily = FontFamily(Font([Link], weight =
[Link])))
}
}
}
Surface(
modifier = Modifier
.align([Link])
.padding([Link], [Link])
) {
Row(modifier = [Link](),
horizontalArrangement = [Link]) {
Button(
onClick = { onPreviousButtonClick() },
colors = [Link](backgroundColor =
Color(red=73, green = 93, blue = 146)),
shape = RoundedCornerShape(50),
modifier = [Link]([Link])
) {
Text(text = stringResource([Link]))
}
Button(
onClick = { onNextButtonClick() },
colors = [Link](backgroundColor =
Color(red=73, green = 93, blue = 146)),
shape = RoundedCornerShape(50),

4|Page
modifier = [Link]([Link])

){
Text(text = stringResource([Link]),
[Link]([Link],[Link]))
}
}
}
}
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
ArtSpaceTheme {
ArtSpaceApp()
}
}

5|Page
[Link]

Device Emulator

Tablet Physical Device

6|Page
7|Page
8|Page

You might also like