O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Dasturiy injinering fakulteti
Axborot Texnologiyalarining Dasturiy Ta’minoti kafedrasi
Dasturiy injiniringga kirish
Amaliy ish №2
Topshirdi: Ustaboyev Abbosbek
Qabul qildi: Jabborova N.
Toshkent 2022
Mavzu: Ishlab chiqilgan prototip kodini GitHubga joylashtirish
Biz ishlab chiqqan loyiha, prototip kodi:
Dastlab Prototip uchun model yaratib olamiz:
package mobiler.abbosbek.androidtutorial.model
data class TutorialModel(
val image: Int?,
val title: String,
val id: Int
)
Keyin esa DataProvider nomli object yaratib olamiz :
object DataProvider {
val jetpackComposeData = listOf(
TutorialModel(R.drawable.widget,"Android Widgets",0),
TutorialModel(R.drawable.image,"Image Tutorial",1),
TutorialModel(R.drawable.alert,"Alert Dialog",2),
TutorialModel(R.drawable.list,"List Tutorial",3),
TutorialModel(R.drawable.calendar,"Date Tutorial",4),
TutorialModel(R.drawable.clock,"Time Tutorial",5),
TutorialModel(R.drawable.menu,"Menu Tutorial",6),
TutorialModel(R.drawable.intent,"Intent Tutorial",7),
TutorialModel(R.drawable.user,"Profile Page",8),
TutorialModel(R.drawable.login,"Register Page",9),
TutorialModel(R.drawable.smartphone,"UI Design",10)
)
}
Endi esa Asosiy prototip kodini yozamiz :
import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowRight
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import mobiler.abbosbek.androidtutorial.model.DataProvider
import mobiler.abbosbek.androidtutorial.model.TutorialModel
import mobiler.abbosbek.androidtutorial.ui.theme.AndroidTutorialTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AndroidTutorialTheme(darkTheme = false) {
Scaffold(topBar = {
TopAppBar(title={
Text(
text = "Jetpack Compose Tutorial",
fontWeight = FontWeight.Bold,
fontSize = 20.sp,
fontStyle = FontStyle.Normal,
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth()
)
Do'stlaringiz bilan baham: |