Feature: design for home screen
This commit is contained in:
parent
f4b684e093
commit
368f530be1
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
41
.idea/inspectionProfiles/Project_Default.xml
Normal file
41
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
|
@ -0,0 +1,73 @@
|
||||
package com.example.android_programming.HomeScreen
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
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.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.example.android_programming.R
|
||||
|
||||
@Composable
|
||||
fun CardSneaker(item: SneakerItem) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.padding(20.dp)
|
||||
.clip(RoundedCornerShape(10.dp))
|
||||
.background(Color.LightGray)
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = item.imageId),
|
||||
contentDescription = "image",
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.padding(43.dp, 5.dp, 43.dp)
|
||||
.size(70.dp)
|
||||
)
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
){
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
Text(text = item.name)
|
||||
Text(text = item.price.toString(), color = Color.Red)
|
||||
}
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Button(
|
||||
onClick = { /*TODO*/ },
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
) {
|
||||
Text(text = "+", fontSize = 16.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun CardSneakerPreview(){
|
||||
CardSneaker(SneakerItem(R.drawable.sneaker, "Jordan", 159.99))
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.example.android_programming.HomeScreen
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
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.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.example.android_programming.R
|
||||
|
||||
@Composable
|
||||
fun HomeScreen() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.White)
|
||||
) {
|
||||
Row {
|
||||
// Поле для поиска
|
||||
SearchField(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(20.dp)
|
||||
.clip(RoundedCornerShape(10.dp))
|
||||
) { searchText ->
|
||||
// Обработка введенного текста поиска
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
LazyRow(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(0.dp, 0.dp, 0.dp, 5.dp),
|
||||
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
){
|
||||
itemsIndexed(
|
||||
listOf(
|
||||
ItemFilterByBrand(R.drawable.jordan),
|
||||
ItemFilterByBrand(R.drawable.jordan),
|
||||
ItemFilterByBrand(R.drawable.jordan),
|
||||
ItemFilterByBrand(R.drawable.jordan)
|
||||
)
|
||||
){ _, item->
|
||||
ItemRow(item = item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
) {
|
||||
val list = listOf(
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
SneakerItem(R.drawable.sneaker, "Jordan", 159.99),
|
||||
)
|
||||
|
||||
// Определите количество столбцов
|
||||
val numColumns = 2
|
||||
|
||||
// Разделите список на группы по numColumns элементов
|
||||
val chunkedList = list.chunked(numColumns)
|
||||
|
||||
itemsIndexed(chunkedList) { _, chunkedListItem ->
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
for (item in chunkedListItem) {
|
||||
// Создайте карточку для каждого элемента
|
||||
CardSneaker(item = item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun HomeScreenPreview(){
|
||||
HomeScreen()
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.example.android_programming.HomeScreen
|
||||
|
||||
data class ItemFilterByBrand(
|
||||
val imageId: Int,
|
||||
)
|
@ -0,0 +1,44 @@
|
||||
package com.example.android_programming.HomeScreen
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.example.android_programming.R
|
||||
|
||||
@Composable
|
||||
fun ItemRow(item: ItemFilterByBrand) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(10.dp))
|
||||
.background(Color.LightGray)
|
||||
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = item.imageId),
|
||||
contentDescription = "image",
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.padding(13.dp, 3.dp, 13.dp, 3.dp)
|
||||
.size(30.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun PreviewItemRow(){
|
||||
ItemRow(item = ItemFilterByBrand(R.drawable.jordan))
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.example.android_programming.HomeScreen;
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.runtime.Composable;
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun SearchField(
|
||||
modifier: Modifier = Modifier,
|
||||
onSearch: (String) -> Unit
|
||||
) {
|
||||
var searchText by remember { mutableStateOf("") }
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.background(Color.LightGray)
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
content = {
|
||||
BasicTextField(
|
||||
value = searchText,
|
||||
onValueChange = {
|
||||
searchText = it
|
||||
onSearch(it)
|
||||
},
|
||||
textStyle = TextStyle(color = Color.Black),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
)
|
||||
|
||||
SearchIcon(
|
||||
imageVector = Icons.Default.Search,
|
||||
contentDescription = "Search Icon",
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SearchIcon(
|
||||
imageVector: ImageVector,
|
||||
contentDescription: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Icon(
|
||||
imageVector = imageVector,
|
||||
contentDescription = contentDescription,
|
||||
modifier = modifier
|
||||
.size(24.dp)
|
||||
.padding(4.dp)
|
||||
)
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.example.android_programming.HomeScreen
|
||||
|
||||
data class SneakerItem(
|
||||
val imageId: Int,
|
||||
val name: String,
|
||||
val price: Double
|
||||
)
|
@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import com.example.android_programming.Screens.HomeScreen
|
||||
import com.example.android_programming.HomeScreen.HomeScreen
|
||||
import com.example.android_programming.Screens.LikeScreen
|
||||
import com.example.android_programming.Screens.OrderScreen
|
||||
import com.example.android_programming.Screens.ProfileScreen
|
||||
|
@ -1,37 +0,0 @@
|
||||
package com.example.android_programming.Screens
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
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.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
||||
@Composable
|
||||
fun HomeScreen() {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(Color.White),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = "Home",
|
||||
fontSize = MaterialTheme.typography.h3.fontSize,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.Black
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun HomeScreenPreview(){
|
||||
HomeScreen()
|
||||
}
|
BIN
app/src/main/res/drawable/jordan.png
Normal file
BIN
app/src/main/res/drawable/jordan.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 693 B |
BIN
app/src/main/res/drawable/sneaker.png
Normal file
BIN
app/src/main/res/drawable/sneaker.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
Loading…
Reference in New Issue
Block a user