diff --git a/app/src/main/java/com/example/android_projects/ClassPerson.kt b/app/src/main/java/com/example/android_projects/ClassPerson.kt new file mode 100644 index 0000000..6611249 --- /dev/null +++ b/app/src/main/java/com/example/android_projects/ClassPerson.kt @@ -0,0 +1 @@ +data class \ No newline at end of file diff --git a/src/androidTest/java/com/example/android_projects/ExampleInstrumentedTest.kt b/src/androidTest/java/com/example/android_projects/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..3145201 --- /dev/null +++ b/src/androidTest/java/com/example/android_projects/ExampleInstrumentedTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml new file mode 100644 index 0000000..b2c08c8 --- /dev/null +++ b/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/example/android_projects/InputComponent.kt b/src/main/java/com/example/android_projects/InputComponent.kt new file mode 100644 index 0000000..104042e --- /dev/null +++ b/src/main/java/com/example/android_projects/InputComponent.kt @@ -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, 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 + ) + } +} \ No newline at end of file diff --git a/src/main/java/com/example/android_projects/ListComponent.kt b/src/main/java/com/example/android_projects/ListComponent.kt new file mode 100644 index 0000000..4a732f3 --- /dev/null +++ b/src/main/java/com/example/android_projects/ListComponent.kt @@ -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, messages: MutableList, 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) + ) + } +} \ No newline at end of file diff --git a/src/main/java/com/example/android_projects/MainActivity.kt b/src/main/java/com/example/android_projects/MainActivity.kt new file mode 100644 index 0000000..8db91da --- /dev/null +++ b/src/main/java/com/example/android_projects/MainActivity.kt @@ -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)) + } + } +} \ No newline at end of file diff --git a/src/main/java/com/example/android_projects/MainComponent.kt b/src/main/java/com/example/android_projects/MainComponent.kt new file mode 100644 index 0000000..5a5ee04 --- /dev/null +++ b/src/main/java/com/example/android_projects/MainComponent.kt @@ -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() } + 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)) + }) + } +} \ No newline at end of file diff --git a/src/main/java/com/example/android_projects/PersonClass.kt b/src/main/java/com/example/android_projects/PersonClass.kt new file mode 100644 index 0000000..6face8b --- /dev/null +++ b/src/main/java/com/example/android_projects/PersonClass.kt @@ -0,0 +1 @@ +data class Person(val fullName: String, val data: String) diff --git a/src/main/java/com/example/android_projects/ui/theme/Color.kt b/src/main/java/com/example/android_projects/ui/theme/Color.kt new file mode 100644 index 0000000..c7d060d --- /dev/null +++ b/src/main/java/com/example/android_projects/ui/theme/Color.kt @@ -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) \ No newline at end of file diff --git a/src/main/java/com/example/android_projects/ui/theme/Theme.kt b/src/main/java/com/example/android_projects/ui/theme/Theme.kt new file mode 100644 index 0000000..057cfa6 --- /dev/null +++ b/src/main/java/com/example/android_projects/ui/theme/Theme.kt @@ -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 + ) +} \ No newline at end of file diff --git a/src/main/java/com/example/android_projects/ui/theme/Type.kt b/src/main/java/com/example/android_projects/ui/theme/Type.kt new file mode 100644 index 0000000..3a723d7 --- /dev/null +++ b/src/main/java/com/example/android_projects/ui/theme/Type.kt @@ -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 + ) + */ +) \ No newline at end of file diff --git a/src/main/res/drawable/ic_launcher_background.xml b/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/res/drawable/ic_launcher_foreground.xml b/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/res/mipmap-anydpi/ic_launcher.xml b/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/res/mipmap-hdpi/ic_launcher.webp b/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/src/main/res/mipmap-mdpi/ic_launcher.webp b/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/src/main/res/mipmap-xhdpi/ic_launcher.webp b/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml new file mode 100644 index 0000000..febf368 --- /dev/null +++ b/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Android_projects + \ No newline at end of file diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml new file mode 100644 index 0000000..f92c62a --- /dev/null +++ b/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +