commit 398977960a0e9abdf8b757428420624de1151f60 Author: Артём Алейкин Date: Sat Nov 25 11:04:59 2023 +0400 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..b3405b3 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +My Application \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..ae388c2 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..44ca2d9 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..0fc3113 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8978d23 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..5ede827 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,70 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "com.example.myapplication" + compileSdk = 33 + + defaultConfig { + applicationId = "com.example.myapplication" + minSdk = 24 + targetSdk = 33 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.4.3" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + + implementation("androidx.core:core-ktx:1.9.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") + implementation("androidx.activity:activity-compose:1.7.2") + implementation(platform("androidx.compose:compose-bom:2023.03.00")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.ui:ui-tooling-preview") + implementation("androidx.compose.material3:material3") + implementation("androidx.navigation:navigation-compose:2.6.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) + androidTestImplementation("androidx.compose.ui:ui-test-junit4") + debugImplementation("androidx.compose.ui:ui-tooling") + debugImplementation("androidx.compose.ui:ui-test-manifest") +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..e9283cf --- /dev/null +++ b/app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.myapplication + +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.myapplication", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e013846 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/MainActivity.kt b/app/src/main/java/com/example/myapplication/MainActivity.kt new file mode 100644 index 0000000..1e7152e --- /dev/null +++ b/app/src/main/java/com/example/myapplication/MainActivity.kt @@ -0,0 +1,96 @@ +package com.example.myapplication + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectDragGestures +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.R +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.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.graphics.ImageBitmap +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.modifier.modifierLocalMapOf +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.navigation.compose.NavHost +import androidx.navigation.NavHostController +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import com.example.myapplication.screens.Authorization +import com.example.myapplication.screens.CreateCard +import com.example.myapplication.screens.EditCard +import com.example.myapplication.ui.theme.MyApplicationTheme +import com.example.myapplication.screens.MainScreen +import com.example.myapplication.screens.Registration +import com.example.myapplication.screens.UserSettings + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + MyApplicationTheme { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + val navController = rememberNavController() + AppNavigation(navController = navController) + } + } + } + } +} + +@Composable +fun AppNavigation(navController: NavHostController){ + NavHost( + navController = navController, startDestination = "authorization" + ) { + composable("authorization") { + Authorization(navController = navController) + } + composable("mainScreen"){ + MainScreen(navController = navController) + } + composable("registration") { + Registration(navController = navController) + } + composable("createCard") { + CreateCard(navController = navController) + } + composable("userSettings") { + UserSettings(navController = navController) + } + composable("editCard") { + EditCard(navController = navController) + } + } +} diff --git a/app/src/main/java/com/example/myapplication/components/ListContent.kt b/app/src/main/java/com/example/myapplication/components/ListContent.kt new file mode 100644 index 0000000..815c10f --- /dev/null +++ b/app/src/main/java/com/example/myapplication/components/ListContent.kt @@ -0,0 +1,128 @@ +/* +package com.example.myapplication.components + +import androidx.compose.foundation.Image +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.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredHeight +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Button +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.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.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavHostController + +@Composable +fun DataListScroll(navController: NavHostController){ + val isFirstTime = remember { mutableStateOf(true) } + + LazyColumn( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .fillMaxWidth() + ){ + item { + addNewListItem(navController, "editstory") + } + items(storySingleton.getStoryList()){ item -> + DataListItem(item = item, navController = navController) + } + } +} + +@Composable +fun DataListItem(item: Story, navController: NavHostController){ + val isExpanded = remember { + mutableStateOf(false) + } + + Card( + modifier = Modifier + .fillMaxWidth() + .padding(start = 18.dp, top = 10.dp, end = 18.dp, bottom = 10.dp) + .clickable { + isExpanded.value = !isExpanded.value + }, + shape = RoundedCornerShape(15.dp), + elevation = CardDefaults.cardElevation( + defaultElevation = 8.dp + ), + colors = CardDefaults.cardColors( + containerColor = ButtonColor1 + ) + ) { + Column( + modifier = Modifier.fillMaxSize() + ) { + Row( + verticalAlignment = Alignment.Top + ){ + Image(painter = painterResource(id = item.cover), + contentDescription = item.description, + contentScale = ContentScale.Crop, + modifier = Modifier + .width(128.dp) + .height(256.dp)) + Column ( + modifier = Modifier.padding(8.dp) + ){ + Text( + text = item.title, + fontSize = 20.sp, + fontWeight = FontWeight.Bold + ) + Text(text = item.description) + } + } + AnimatedVisibility( + visible = isExpanded.value, + modifier = Modifier.fillMaxWidth() + ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.End + ){ + DataListItemButton("Изменить", ButtonColor2, Color.White, onClickAction = { navController.navigate("editstory") }) + DataListItemButton("Удалить", Color.Red, Color.White, onClickAction = { }) + } + } + } + } +} + +@Composable +fun DataListItemButton(label: String, backgroundColor: Color, textColor: Color, onClickAction: () -> Unit){ + Button( + onClick = onClickAction, + modifier = Modifier.requiredHeight(64.dp), + shape = RoundedCornerShape(10.dp), + colors = ButtonDefaults.buttonColors( + containerColor = backgroundColor + ) + ) { + Text( + text = label, + color = textColor, + fontSize = 18.sp, + ) + } +} +*/ diff --git a/app/src/main/java/com/example/myapplication/components/navBar.kt b/app/src/main/java/com/example/myapplication/components/navBar.kt new file mode 100644 index 0000000..7fb396c --- /dev/null +++ b/app/src/main/java/com/example/myapplication/components/navBar.kt @@ -0,0 +1,76 @@ +package com.example.myapplication.components + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredHeight +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.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.modifier.modifierLocalConsumer +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavHostController +import com.example.myapplication.R +import com.example.myapplication.ui.theme.SkyBlue + +@Composable +fun navBar(navController: NavHostController) { + Row( + horizontalArrangement = Arrangement.SpaceAround, + modifier = Modifier + .fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically + ) { + navItem(navController = navController, ImageId = R.drawable.home_image, "mainScreen") + navItem(navController = navController, ImageId = R.drawable.note_image, "createCard") + navItem(navController = navController, ImageId = R.drawable.profile_image, "userSettings") + } +} + +@Composable +fun navItem(navController: NavHostController, ImageId: Int, destination: String) { + Image( + painter = painterResource(id = ImageId), + contentDescription = "image", + modifier = Modifier + .height(45.dp) + .width(45.dp) + .clickable + { navController.navigate(destination) }) +} + +@Composable +fun navButton(navController: NavHostController, destination: String, label: String, backgroundColor: Color, textColor: Color) +{ + Button(onClick = { navController.navigate(destination) }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp, bottom = 8.dp, start = 50.dp, end = 50.dp), + colors = ButtonDefaults.buttonColors( containerColor = backgroundColor), + shape = RoundedCornerShape(25.dp) + ) { + Text(text = label, + fontSize = 20.sp, + color = textColor + ) + } +} diff --git a/app/src/main/java/com/example/myapplication/components/textBox.kt b/app/src/main/java/com/example/myapplication/components/textBox.kt new file mode 100644 index 0000000..d53a266 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/components/textBox.kt @@ -0,0 +1,51 @@ +package com.example.myapplication.components + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.input.PasswordVisualTransformation +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun LoginField(text: String) +{ + var message = remember{ mutableStateOf("")} + + OutlinedTextField( + value = message.value, + onValueChange = { message.value = it }, + placeholder = { Text(text) }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp, bottom = 8.dp, start = 50.dp, end = 50.dp), + shape = RoundedCornerShape(25.dp)) +} + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun PasswordField(text: String) +{ + var message = remember{ mutableStateOf("")} + + OutlinedTextField( + value = message.value, + onValueChange = { message.value = it }, + placeholder = { Text(text) }, + visualTransformation = PasswordVisualTransformation(), + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp, bottom = 8.dp, start = 50.dp, end = 50.dp), + shape = RoundedCornerShape(25.dp)) +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/screens/authorization.kt b/app/src/main/java/com/example/myapplication/screens/authorization.kt new file mode 100644 index 0000000..f7d34ad --- /dev/null +++ b/app/src/main/java/com/example/myapplication/screens/authorization.kt @@ -0,0 +1,60 @@ +package com.example.myapplication.screens + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.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.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import androidx.navigation.NavHostController +import com.example.myapplication.R +import com.example.myapplication.components.LoginField +import com.example.myapplication.components.PasswordField +import com.example.myapplication.components.navButton + +@Composable +fun Authorization(navController: NavHostController){ + Column ( + modifier = Modifier + .fillMaxSize() + .padding(bottom = 8.dp), + verticalArrangement = Arrangement.Top + ) { + Image( + painter = painterResource(id = R.drawable.intro3), + contentDescription = "login", + contentScale = ContentScale.Crop, + modifier = Modifier + .size(400.dp)) + Box (modifier = Modifier + .fillMaxWidth() + .padding(8.dp), + contentAlignment = Alignment.Center) { + Text("Продажа автомобилей", + fontWeight = FontWeight.Bold, + fontSize = 20.sp + ) + } + LoginField(text = "Логин") + PasswordField(text = "Пароль") + navButton(navController = navController, destination = "mainScreen", label = "Вход", + backgroundColor = Color.Cyan, textColor = Color.Black) + navButton(navController = navController, destination = "registration", label = "Регистрация", + backgroundColor = Color.Cyan, textColor = Color.Black) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/screens/createcard.kt b/app/src/main/java/com/example/myapplication/screens/createcard.kt new file mode 100644 index 0000000..836fb46 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/screens/createcard.kt @@ -0,0 +1,50 @@ +package com.example.myapplication.screens + +import android.view.Display.Mode +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.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.navigation.NavController +import androidx.navigation.NavHostController +import com.example.myapplication.components.LoginField +import com.example.myapplication.components.navBar +import com.example.myapplication.components.navButton +import com.example.myapplication.ui.theme.SkyBlue + +@Composable +fun CreateCard(navController: NavHostController) { + Column { + Box (modifier = Modifier.fillMaxHeight(0.9f)) { + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Button(onClick = { /*TODO*/ }) { + Text("Добавить картинку") + } + LoginField(text = "Название/Марка") + LoginField(text = "Пробег") + LoginField(text = "Расположение") + LoginField(text = "Цена") + Button(onClick = { /*TODO*/ }) { + Text("Создать объявление") + } + } + } + Column(modifier = Modifier + .fillMaxSize() + .background(SkyBlue), + verticalArrangement = Arrangement.Center) { + navBar(navController = navController) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/screens/editcard.kt b/app/src/main/java/com/example/myapplication/screens/editcard.kt new file mode 100644 index 0000000..0242dfa --- /dev/null +++ b/app/src/main/java/com/example/myapplication/screens/editcard.kt @@ -0,0 +1,50 @@ +package com.example.myapplication.screens + +import android.view.Display.Mode +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.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.navigation.NavController +import androidx.navigation.NavHostController +import com.example.myapplication.components.LoginField +import com.example.myapplication.components.navBar +import com.example.myapplication.components.navButton +import com.example.myapplication.ui.theme.SkyBlue + +@Composable +fun EditCard(navController: NavHostController) { + Column { + Box (modifier = Modifier.fillMaxHeight(0.9f)) { + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Button(onClick = { /*TODO*/ }) { + Text("Добавить картинку") + } + LoginField(text = "Название/Марка") + LoginField(text = "Пробег") + LoginField(text = "Расположение") + LoginField(text = "Цена") + Button(onClick = { /*TODO*/ }) { + Text("Изменить объявление") + } + } + } + Column(modifier = Modifier + .fillMaxSize() + .background(SkyBlue), + verticalArrangement = Arrangement.Center) { + navBar(navController = navController) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/screens/mainScreen.kt b/app/src/main/java/com/example/myapplication/screens/mainScreen.kt new file mode 100644 index 0000000..ecc4a9f --- /dev/null +++ b/app/src/main/java/com/example/myapplication/screens/mainScreen.kt @@ -0,0 +1,142 @@ +package com.example.myapplication.screens + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +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.fillMaxHeight +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.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.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.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import com.example.myapplication.components.navBar +import com.example.myapplication.ui.theme.SkyBlue + +@Composable +fun MainScreen(navController: NavHostController) { + Column { + Box(modifier = Modifier + .padding(horizontal = 10.dp) + .fillMaxHeight(0.9f)) { + Column( + modifier = Modifier.verticalScroll(rememberScrollState()) + ) { + ListItem( + name = "Ламборджини Авентадор 2010", + mileage = 4765, + location = "Россия, г. Ульяновск", + price = 5000000, + imageResourceId = com.example.myapplication.R.drawable.lambo_car1, + navController = navController + ) + ListItem( + name = "Оранжевый Москвич 1983", + mileage = 522011, + location = "Россия, г. Москва", + price = 125000, + imageResourceId = com.example.myapplication.R.drawable.moscowich_car3, + navController = navController + ) + ListItem( + name = "Феррари Лаферрари 2013", + mileage = 17698, + location = "Италия, г. Неаполь", + price = 1249990, + imageResourceId = com.example.myapplication.R.drawable.ferrari_laferrari_car2, + navController = navController + ) + ListItem( + name = "Оранжевый Москвич 1983", + mileage = 522011, + location = "Россия, г. Москва", + price = 125000, + imageResourceId = com.example.myapplication.R.drawable.moscowich_car3, + navController = navController + ) + ListItem( + name = "Феррари Лаферрари 2013", + mileage = 17698, + location = "Италия, г. Неаполь", + price = 1249990, + imageResourceId = com.example.myapplication.R.drawable.ferrari_laferrari_car2, + navController = navController + ) + } + } + Column(modifier = Modifier + .fillMaxSize() + .background(SkyBlue), + verticalArrangement = Arrangement.Center) { + navBar(navController = navController) + } + } +} + +@Composable +private fun ListItem(name: String, + mileage: Int, + location: String, + price: Int, + imageResourceId: Int, + navController: NavHostController) { + var borderColor = remember { mutableStateOf(Color.Gray) } + + Card( + modifier = Modifier + .fillMaxWidth() + .padding(10.dp) + .border(2.dp, borderColor.value, RoundedCornerShape(15.dp)) + .clickable { borderColor.value = Color.LightGray }, + shape = RoundedCornerShape(15.dp), + elevation = CardDefaults.cardElevation(defaultElevation = 5.dp), + ){ + Box() { + Row(verticalAlignment = Alignment.CenterVertically){ + Image( + painter = painterResource(id = imageResourceId), + contentDescription = "image", + contentScale = ContentScale.Crop, + modifier = Modifier.size(128.dp)) + Column ( + modifier = Modifier.padding(5.dp)) { + Text(text = name, fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Bold) + Text(text = "Пробег: " + mileage) + Text(text = "Расположение: " + location) + Text(text = "Цена: " + price) + Button(onClick = { navController.navigate("editCard") }) { + Text("Изменить") + } + Button(onClick = { }) { + Text("Удалить") + } + } + } + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/screens/registration.kt b/app/src/main/java/com/example/myapplication/screens/registration.kt new file mode 100644 index 0000000..2be06c7 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/screens/registration.kt @@ -0,0 +1,34 @@ +package com.example.myapplication.screens + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.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.layout.ModifierInfo +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import androidx.navigation.NavHostController +import com.example.myapplication.components.LoginField +import com.example.myapplication.components.PasswordField +import com.example.myapplication.components.navButton + +@Composable +fun Registration(navController: NavHostController) { + Column (modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally) { + Text(text = "Привет!", + fontSize = 20.sp, + fontWeight = FontWeight.Bold) + Text(text = "Зарегистрируйся, чтобы начать!", + fontSize = 20.sp, + fontWeight = FontWeight.Bold) + LoginField(text = "Логин") + PasswordField(text = "Пароль") + PasswordField(text = "Повторите пароль") + navButton(navController = navController, destination = "authorization", label = "Зарегистрироваться", backgroundColor = Color.Cyan, textColor = Color.Black) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/screens/user.kt b/app/src/main/java/com/example/myapplication/screens/user.kt new file mode 100644 index 0000000..1c637cb --- /dev/null +++ b/app/src/main/java/com/example/myapplication/screens/user.kt @@ -0,0 +1,56 @@ +package com.example.myapplication.screens + +import androidx.compose.foundation.Image +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.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import androidx.navigation.NavController +import androidx.navigation.NavHostController +import com.example.myapplication.R +import com.example.myapplication.components.LoginField +import com.example.myapplication.components.navBar +import com.example.myapplication.ui.theme.SkyBlue + +@Composable +fun UserSettings(navController: NavHostController) { + Column { + Box (modifier = Modifier.fillMaxHeight(0.9f)) { + Column( + modifier = Modifier.fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(id = R.drawable.user), + contentDescription = "login", + contentScale = ContentScale.Crop, + modifier = Modifier + .size(300.dp) + ) + LoginField(text = "Логин пользователя") + LoginField(text = "Пароль пользователя") + LoginField(text = "Количество объявлений пользователя") + Button(onClick = {}) { Text("Посмотреть мои объявления") } + } + } + Column(modifier = Modifier + .fillMaxSize() + .background(SkyBlue), + verticalArrangement = Arrangement.Center) { + navBar(navController = navController) + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/ui/theme/Color.kt b/app/src/main/java/com/example/myapplication/ui/theme/Color.kt new file mode 100644 index 0000000..c9dc73a --- /dev/null +++ b/app/src/main/java/com/example/myapplication/ui/theme/Color.kt @@ -0,0 +1,12 @@ +package com.example.myapplication.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) +val SkyBlue = Color(0xFF8FECF9) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/ui/theme/Theme.kt b/app/src/main/java/com/example/myapplication/ui/theme/Theme.kt new file mode 100644 index 0000000..d13243d --- /dev/null +++ b/app/src/main/java/com/example/myapplication/ui/theme/Theme.kt @@ -0,0 +1,70 @@ +package com.example.myapplication.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.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + +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 MyApplicationTheme( + 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 + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/ui/theme/Type.kt b/app/src/main/java/com/example/myapplication/ui/theme/Type.kt new file mode 100644 index 0000000..64846a0 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.example.myapplication.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/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/app/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/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..3de1a39 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + My Application + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..e48770a --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +