Created
October 22, 2023 18:58
-
-
Save ikhlaqmalik13/264210f65dd79c0d00af8b1cf20a86a7 to your computer and use it in GitHub Desktop.
JetpackCompose - Class 1
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
package com.urbanmatrix.android.launchpad.test | |
import android.util.Log | |
import androidx.compose.foundation.clickable | |
import androidx.compose.foundation.layout.Arrangement | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.Row | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.fillMaxWidth | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.material.Icon | |
import androidx.compose.material.Scaffold | |
import androidx.compose.material.Text | |
import androidx.compose.material.TopAppBar | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.res.painterResource | |
import androidx.compose.ui.text.TextStyle | |
import androidx.compose.ui.text.font.FontFamily | |
import androidx.compose.ui.text.font.FontWeight | |
import androidx.compose.ui.tooling.preview.Preview | |
import androidx.compose.ui.unit.dp | |
import androidx.compose.ui.unit.sp | |
import com.urbanmatrix.android.launchpad.R | |
@Preview | |
@Composable | |
fun MyComposable() { | |
Scaffold( | |
modifier = Modifier.fillMaxSize(), | |
topBar = { | |
MyToolBar() | |
}, | |
bottomBar = { | |
MyTextView(" botom Ikhlaq ag") | |
} | |
) { paddingValues -> | |
Column(modifier = Modifier.padding(paddingValues)) { | |
Row( | |
modifier = Modifier.fillMaxWidth(), | |
horizontalArrangement = Arrangement.spacedBy(20.dp) | |
) { | |
MyTextView("Ikhlaq ag") | |
MyTextView("Ikhlaq ag") | |
MyTextView("Ikhlaq ag") | |
} | |
Row(modifier = Modifier.padding(paddingValues)) { | |
MyTextView("Ikhlaq ag") | |
MyTextView("Ikhlaq ag") | |
} | |
Row(modifier = Modifier.padding(paddingValues)) { | |
MyTextView("Ikhlaq ag") | |
MyTextView("Ikhlaq ag") | |
} | |
} | |
} | |
} | |
@Composable | |
fun MyToolBar() { | |
TopAppBar( | |
modifier = Modifier, | |
backgroundColor = Color.Black, | |
contentColor = Color.White, | |
elevation = 3.dp | |
) { | |
Row( | |
modifier = Modifier.fillMaxWidth(), | |
verticalAlignment = Alignment.CenterVertically, | |
horizontalArrangement = Arrangement.SpaceBetween | |
) { | |
MyTextView("Instagram") | |
Row() { | |
Icon(modifier = Modifier.padding(start = 6.dp, end= 6.dp), painter = painterResource(R.drawable.ic_drone_24dp), contentDescription = null) | |
Icon(modifier = Modifier.padding(start = 6.dp), painter = painterResource(R.drawable.ic_info_24dp), contentDescription = null) | |
} | |
} | |
} | |
} | |
@Preview | |
@Composable | |
fun MyTextView(text: String = "Hello world") { | |
Text( | |
modifier = Modifier | |
.padding(start = 10.dp, end = 10.dp) | |
.clickable { | |
Log.d("", "") | |
}, | |
text = text, | |
style = TextStyle( | |
fontSize = 16.sp, | |
fontFamily = FontFamily.Cursive, | |
fontWeight = FontWeight.Bold | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment