sprint-1 #1
144
libary/src/main/java/com/example/libary/Header.kt
Normal file
144
libary/src/main/java/com/example/libary/Header.kt
Normal file
@ -0,0 +1,144 @@
|
||||
package com.example.libary
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
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.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
|
||||
import androidx.compose.material3.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.res.painterResource
|
||||
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.example.libary.HeaderState.*
|
||||
|
||||
enum class HeaderState {
|
||||
Big,
|
||||
Small
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Header(
|
||||
modifier: Modifier = Modifier,
|
||||
state: HeaderState,
|
||||
title: String,
|
||||
onBack: () -> Unit = {},
|
||||
onRm: () -> Unit = {}
|
||||
) {
|
||||
when(state) {
|
||||
Big -> {
|
||||
Column(
|
||||
modifier = modifier
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(end = 11.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
HeaderBt(
|
||||
icon = R.drawable.back,
|
||||
onClick = onBack
|
||||
)
|
||||
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rm),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.clickable {
|
||||
onRm()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(24.dp))
|
||||
|
||||
Text(
|
||||
text = title,
|
||||
color = Color.Black,
|
||||
fontWeight = FontWeight.W800,
|
||||
fontSize = 24.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
Small -> {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 20.dp, end = 26.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
HeaderBt(
|
||||
icon = R.drawable.back,
|
||||
onClick = onBack
|
||||
)
|
||||
|
||||
Text(
|
||||
text = title,
|
||||
color = Color.Black,
|
||||
fontWeight = FontWeight.W600,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rm),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.clickable {
|
||||
onRm()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HeaderBt(
|
||||
icon: Int,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.size(32.dp)
|
||||
.background(Color(0xFFF5F5F9), AbsoluteRoundedCornerShape(8.dp))
|
||||
.clip(AbsoluteRoundedCornerShape(8.dp)),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(icon),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(6.dp).clickable {
|
||||
onClick()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun HeaderPr() {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().background(Color.White).padding(10.dp)
|
||||
) {
|
||||
Header(
|
||||
state = HeaderState.Big,
|
||||
title = "Корзина"
|
||||
)
|
||||
}
|
||||
}
|
13
libary/src/main/res/drawable/back.xml
Normal file
13
libary/src/main/res/drawable/back.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M11.5,15L6.5,10L11.5,5"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#7E7E9A"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
34
libary/src/main/res/drawable/rm.xml
Normal file
34
libary/src/main/res/drawable/rm.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M2.5,5H4.167H17.5"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#B8C1CC"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M6.667,5V3.333C6.667,2.891 6.842,2.467 7.155,2.155C7.467,1.842 7.891,1.667 8.333,1.667H11.667C12.109,1.667 12.533,1.842 12.845,2.155C13.158,2.467 13.333,2.891 13.333,3.333V5M15.833,5V16.667C15.833,17.109 15.658,17.533 15.345,17.845C15.033,18.158 14.609,18.333 14.167,18.333H5.833C5.391,18.333 4.967,18.158 4.655,17.845C4.342,17.533 4.167,17.109 4.167,16.667V5H15.833Z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#B8C1CC"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M8.333,9.167V14.167"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#B8C1CC"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M11.667,9.167V14.167"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#B8C1CC"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
Loading…
x
Reference in New Issue
Block a user