Экран регистрации + импорт шрифта + структурирование проекта

This commit is contained in:
Данила Мочалов 2023-10-07 18:34:37 +04:00
parent 7890f2dc4f
commit 6f68f6a63a
18 changed files with 300 additions and 207 deletions

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
Shawarma

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
<bytecodeTargetLevel target="17" />
</component>
</project>

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

View File

@ -0,0 +1,32 @@
<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" />
</inspection_tool>
<inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
</profile>
</component>

6
.idea/kotlinc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.7.0" />
</component>
</project>

View File

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -3,24 +3,11 @@ package com.example.shawarma
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Surface
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex
import com.example.shawarma.screens.registration.RegistrationScreen
import com.example.shawarma.ui.theme.MyLightYellow
import com.example.shawarma.ui.theme.ShawarmaTheme
class MainActivity : ComponentActivity() {
@ -30,176 +17,11 @@ class MainActivity : ComponentActivity() {
ShawarmaTheme {
// A surface container using the 'background' color from the theme
Surface(
color = Color(255,225,120,255),
color = MyLightYellow,
modifier = Modifier.fillMaxSize()
)
{
RegistrationCard()
ShawarmaLogo()
}
}
}
}
}
@Composable
fun ShawarmaLogo(){
Column(modifier = Modifier.zIndex(1f)) {
Image(
painterResource(
id = R.drawable.shawarma1
),
contentDescription = "Logo",
modifier = Modifier
.size(256.dp, 256.dp)
.rotate(degrees = 19.25f)
.offset((-70).dp, (-5).dp),
)
Image(
painterResource(
id = R.drawable.shawarma1
),
contentDescription = "Logo",
modifier = Modifier
.size(256.dp, 256.dp)
.offset((200).dp, (100).dp)
.rotate(degrees = -136f)
)
}
}
@Composable
fun RegistrationCard(){
val login = remember { mutableStateOf(TextFieldValue("")) }
val password = remember { mutableStateOf(TextFieldValue("")) }
val passwordRepeat = remember { mutableStateOf(TextFieldValue("")) }
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.padding(top = 72.dp)
.zIndex(2f)
) {
Card(
shape = RoundedCornerShape(20.dp),
modifier = Modifier.size(275.dp, 380.dp)
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = "Регистрация",
fontSize = 20.sp,
modifier = Modifier.padding(
top = 20.dp
)
)
TextField(
value = login.value,
onValueChange = {login.value = it},
placeholder = {
Text(
text = "Логин",
fontSize = 14.sp
)
},
singleLine = true,
shape = RoundedCornerShape(20.dp),
textStyle = TextStyle(
fontSize = 14.sp,
),
colors = TextFieldDefaults.textFieldColors(
textColor = Color.Black,
disabledTextColor = Color.Transparent,
backgroundColor = Color(232,232,232,255),
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
),
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp)
,
)
TextField(
value = password.value,
onValueChange = {password.value = it},
placeholder = {
Text(
text = "Пароль",
fontSize = 14.sp,
)
},
singleLine = true,
shape = RoundedCornerShape(20.dp),
textStyle = TextStyle(
fontSize = 14.sp,
),
colors = TextFieldDefaults.textFieldColors(
textColor = Color.Black,
disabledTextColor = Color.Transparent,
backgroundColor = Color(232,232,232,255),
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
),
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp)
)
TextField(
value = passwordRepeat.value,
onValueChange = {passwordRepeat.value = it},
placeholder = {
Text(
text = "Повторите пароль",
fontSize = 14.sp,
)
},
singleLine = true,
shape = RoundedCornerShape(20.dp),
textStyle = TextStyle(
fontSize = 14.sp,
),
colors = TextFieldDefaults.textFieldColors(
textColor = Color.Black,
disabledTextColor = Color.Transparent,
backgroundColor = Color(232,232,232,255),
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
),
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp)
)
Button(
onClick = { /*TODO*/ },
colors = ButtonDefaults.buttonColors(Color(255,100,100,255), Color.White),
shape = RoundedCornerShape(20.dp),
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp)
) {
Text(text = "Зарегистрироваться")
}
Button(
onClick = { /*TODO*/ },
colors = ButtonDefaults.buttonColors(Color.White),
elevation = ButtonDefaults.elevation(0.dp)
) {
Text(
text = "У меня уже есть аккаунт!",
textDecoration = TextDecoration.Underline
)
RegistrationScreen()
}
}
}
@ -208,3 +30,4 @@ fun RegistrationCard(){

View File

@ -0,0 +1,132 @@
package com.example.shawarma.screens.registration
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.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex
import com.example.shawarma.ui.theme.JejuFamily
import com.example.shawarma.ui.theme.MyLightRed
import com.example.shawarma.widgets.MyTextField
import com.example.shawarma.widgets.ShawarmaLogo1
@Composable
fun RegistrationScreen() {
RegistrationCard()
ShawarmaLogo1()
}
@Composable
fun RegistrationCard(){
val login = remember { mutableStateOf(TextFieldValue("")) }
val password = remember { mutableStateOf(TextFieldValue("")) }
val passwordRepeat = remember { mutableStateOf(TextFieldValue("")) }
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.padding(top = 72.dp)
.zIndex(2f)
) {
Card(
shape = RoundedCornerShape(20.dp),
modifier = Modifier.size(275.dp, 380.dp)
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = "Регистрация",
fontSize = 20.sp,
modifier = Modifier.padding(
top = 20.dp
),
style = TextStyle(
fontFamily = JejuFamily
)
)
MyTextField(
text = login,
onTextChanged = {login.value = it},
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp),
placeholder = "Логин",
singleLine = true
)
MyTextField(
text = password,
onTextChanged = {password.value = it},
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp),
placeholder = "Пароль",
singleLine = true
)
MyTextField(
text = passwordRepeat,
onTextChanged = {passwordRepeat.value = it},
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp),
placeholder = "Повторите пароль",
singleLine = true
)
Button(
onClick = { /*TODO*/ },
colors = ButtonDefaults.buttonColors(MyLightRed, Color.White),
shape = RoundedCornerShape(20.dp),
modifier = Modifier
.padding(
top = (20).dp
)
.size(208.dp, (50).dp)
) {
Text(
text = "Зарегистрироваться",
style = TextStyle(
fontFamily = JejuFamily,
fontSize = 16.sp
)
)
}
Button(
onClick = { /*TODO*/ },
colors = ButtonDefaults.buttonColors(Color.White),
elevation = ButtonDefaults.elevation(0.dp)
) {
Text(
text = "У меня уже есть аккаунт!",
textDecoration = TextDecoration.Underline,
style = TextStyle(
fontFamily = JejuFamily,
fontSize = 12.sp
)
)
}
}
}
}
}

View File

@ -2,7 +2,6 @@ package com.example.shawarma.ui.theme
import androidx.compose.ui.graphics.Color
val Purple200 = Color(0xFFBB86FC)
val Purple500 = Color(0xFF6200EE)
val Purple700 = Color(0xFF3700B3)
val Teal200 = Color(0xFF03DAC5)
val MyLightYellow = Color(255,225,120,255)
val MyLightRed = Color(255,100,100,255)
val MyTextFieldBackground = Color(232,232,232,255)

View File

@ -7,16 +7,10 @@ import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
private val DarkColorPalette = darkColors(
primary = Purple200,
primaryVariant = Purple700,
secondary = Teal200
)
private val LightColorPalette = lightColors(
primary = Purple500,
primaryVariant = Purple700,
secondary = Teal200
/* Other default colors to override
background = Color.White,
surface = Color.White,

View File

@ -2,9 +2,11 @@ package com.example.shawarma.ui.theme
import androidx.compose.material.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.example.shawarma.R
// Set of Material typography styles to start with
val Typography = Typography(
@ -25,4 +27,8 @@ val Typography = Typography(
fontSize = 12.sp
)
*/
)
val JejuFamily = FontFamily(
Font(R.font.jejugothic_regular, FontWeight.Normal)
)

View File

@ -0,0 +1,57 @@
package com.example.shawarma.widgets
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.Placeholder
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.shawarma.ui.theme.JejuFamily
import com.example.shawarma.ui.theme.MyTextFieldBackground
@Composable
fun MyTextField(
text: MutableState<TextFieldValue>,
onTextChanged: (TextFieldValue) -> Unit,
modifier: Modifier,
placeholder: String,
singleLine: Boolean
) {
return TextField(
value = text.value,
onValueChange = onTextChanged,
placeholder = {
Text(
text = placeholder,
fontSize = 14.sp,
style = TextStyle(
fontFamily = JejuFamily
)
)
},
singleLine = singleLine,
shape = RoundedCornerShape(20.dp),
textStyle = TextStyle(
fontSize = 14.sp,
fontFamily = JejuFamily
),
colors = TextFieldDefaults.textFieldColors(
textColor = Color.Black,
disabledTextColor = Color.Transparent,
backgroundColor = MyTextFieldBackground,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
),
modifier = modifier
)
}

View File

@ -0,0 +1,42 @@
package com.example.shawarma.widgets
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import com.example.shawarma.R
@Composable
fun ShawarmaLogo1(){
Column(modifier = Modifier
.zIndex(1f)
.fillMaxSize()) {
Image(
painterResource(
id = R.drawable.shawarma1
),
contentDescription = "Logo",
modifier = Modifier
.size(256.dp, 256.dp)
.rotate(degrees = 19.25f)
.offset((-70).dp, (-5).dp),
)
Image(
painterResource(
id = R.drawable.shawarma1
),
contentDescription = "Logo",
modifier = Modifier
.size(256.dp, 256.dp)
.offset((200).dp, (100).dp)
.rotate(degrees = -136f)
)
}
}

Binary file not shown.

View File

@ -4,7 +4,7 @@ buildscript {
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'com.android.application' version '8.1.1' apply false
id 'com.android.library' version '8.1.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}

View File

@ -20,4 +20,7 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
org.gradle.unsafe.configuration-cache=true

View File

@ -1,6 +1,6 @@
#Fri Oct 06 03:21:29 GMT+04:00 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME