Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data class
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.android_projects

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.android_projects", appContext.packageName)
}
}
27 changes: 27 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Android_projects">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Android_projects">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
25 changes: 25 additions & 0 deletions src/main/java/com/example/android_projects/InputComponent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.android_projects

import androidx.compose.foundation.layout.Row
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource

@Composable
fun Input(label: String, inputText: MutableState<String>, modifier: Modifier) {
Row(modifier = modifier) {
Text(
text = label,
modifier = modifier,
color = colorResource(R.color.purple_700)
)
TextField(
value = inputText.value,
onValueChange = {text -> inputText.value = text},
modifier = modifier
)
}
}
29 changes: 29 additions & 0 deletions src/main/java/com/example/android_projects/ListComponent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.android_projects

import Person
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource

@Composable
fun List(message: MutableState<String>, messages: MutableList<Person>, modifier: Modifier = Modifier) {
Column(modifier = modifier) {
LazyColumn(modifier = modifier.fillMaxWidth()) {
item { Row() { Text(text = "TEXT") } }
items(messages){msg -> Text(text = msg.fullName)}
}

Text(
text = message.value,
modifier = modifier,
color = colorResource(R.color.teal_700)
)
}
}
38 changes: 38 additions & 0 deletions src/main/java/com/example/android_projects/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.example.android_projects

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.android_projects.ui.theme.Android_projectsTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
Android_projectsTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
MainComponent(modifier = Modifier.padding(innerPadding))
}
}
}
}
}

@Preview(showBackground = true)
@Composable
fun test() {

Android_projectsTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
MainComponent(modifier = Modifier.padding(innerPadding))
}
}
}
36 changes: 36 additions & 0 deletions src/main/java/com/example/android_projects/MainComponent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.android_projects

import Person
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier

@Composable
fun MainComponent(modifier: Modifier = Modifier){
val buffer = remember{mutableStateOf("")}
val message = remember{mutableStateOf("")}
val messages = remember { mutableStateListOf<Person>() }
val bufferData= remember{mutableStateOf("")}
val messageData = remember{mutableStateOf("")}

Column(modifier = modifier) {
List(message = message, messages = messages, modifier = modifier)

Input(label = "ФИО", inputText = buffer, modifier = modifier)
Input(label = "Дата рождения", inputText = bufferData, modifier = modifier)
Button(
content = {Text(text = "Сохранить")},
modifier = modifier,
onClick = {
message.value = buffer.value

messageData.value = bufferData.value
messages.add(Person(buffer.value, bufferData.value))
})
}
}
1 change: 1 addition & 0 deletions src/main/java/com/example/android_projects/PersonClass.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data class Person(val fullName: String, val data: String)
11 changes: 11 additions & 0 deletions src/main/java/com/example/android_projects/ui/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.android_projects.ui.theme

import androidx.compose.ui.graphics.Color

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
58 changes: 58 additions & 0 deletions src/main/java/com/example/android_projects/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.example.android_projects.ui.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40

/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)

@Composable
fun Android_projectsTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}
34 changes: 34 additions & 0 deletions src/main/java/com/example/android_projects/ui/theme/Type.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.android_projects.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
Loading