empty activity test

This commit is contained in:
Danil Markov 2023-10-08 13:05:13 +04:00
parent da76a33878
commit 4902705f9c
19 changed files with 397 additions and 34 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

View File

@ -1,10 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;last_opened_file_path&quot;: &quot;C:/Users/Danil/Desktop/5 семестр/ПМУ/labs&quot;
<component name="AndroidLayouts">
<shared>
<config />
</shared>
</component>
<component name="AutoImportSettings">
<option name="autoReloadType" value="NONE" />
</component>
<component name="ChangeListManager">
<list default="true" id="7c94e195-a540-483e-9a1c-11797aeb1741" name="Changes" comment="empty activity test">
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/Basket/Basket.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/List_of_Services/ListOfServices.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/Navbar/NavBar.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/Navbar/NavController.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/Navbar/NavItem.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/Profile/Profile.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/UIComponents/Button.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/UIComponents/SearchBar.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/res/drawable/icon_basket.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/res/drawable/icon_list_of_services.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/res/drawable/icon_profile.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/build.gradle.kts" beforeDir="false" afterPath="$PROJECT_DIR$/app/build.gradle.kts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/MainActivity.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/App.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/ui/theme/Color.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/ui/theme/Color.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/ui/theme/Theme.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/example/myapplication/ui/theme/Theme.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="device_and_snapshot_combo_box_target[C:\Users\Danil\.android\avd\Pixel_3a_API_34_extension_level_7_x86_64.avd]" />
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
<ProjectState />
</projectState>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="resourceFile" />
<option value="Kotlin Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="main" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2W7FGorxnfmDBVh7paZL1FPxAKQ" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"cidr.known.project.marker": "true",
"com.android.tools.idea.devicemanager.tab": "Physical",
"last_opened_file_path": "C:/Users/Danil/Downloads/test",
"settings.editor.selected.configurable": "trusted.hosts"
}
}</component>
}]]></component>
<component name="RecentsManager">
<key name="android.template.-1413981578">
<recent name="com.example.myapplication.Navbar" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\Danil\Desktop\MDP\labs\app\src\main\java\com\example\myapplication\UIComponents" />
</key>
</component>
<component name="RunManager">
<configuration name="app" type="AndroidRunConfigurationType" factoryName="Android App">
<module name="My_Application.app.main" />
@ -73,4 +151,38 @@
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="7c94e195-a540-483e-9a1c-11797aeb1741" name="Changes" comment="" />
<created>1696075618936</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1696075618936</updated>
</task>
<task id="LOCAL-00001" summary="empty activity test">
<created>1696075970008</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1696075970008</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="empty activity test" />
<option name="LAST_COMMIT_MESSAGE" value="empty activity test" />
</component>
</project>

View File

@ -5,12 +5,12 @@ plugins {
android {
namespace = "com.example.myapplication"
compileSdk = 33
compileSdk = 34
defaultConfig {
applicationId = "com.example.myapplication"
minSdk = 29
targetSdk = 33
targetSdk = 34
versionCode = 1
versionName = "1.0"
@ -59,11 +59,16 @@ dependencies {
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
//
implementation("androidx.compose.material:material:1.5.2")
implementation("androidx.navigation:navigation-compose:2.7.3")
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")
}

View File

@ -13,7 +13,7 @@
android:theme="@style/Theme.MyApplication"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".App"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.MyApplication">

View File

@ -3,44 +3,26 @@ package com.example.myapplication
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.*
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.myapplication.ui.theme.MyApplicationTheme
import com.example.myapplication.Navbar.NavBar
import com.example.myapplication.ui.theme.AppTheme
class MainActivity : ComponentActivity() {
class App : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
AppTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Greeting("Android")
NavBar();
}
}
}
}
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
MyApplicationTheme {
Greeting("Android")
}
}

View File

@ -0,0 +1,8 @@
package com.example.myapplication.Basket
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
@Composable
fun Basket(navController : NavHostController,userId : Long){
}

View File

@ -0,0 +1,8 @@
package com.example.myapplication.List_of_Services
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
@Composable
fun ListOfServices(){
}

View File

@ -0,0 +1,82 @@
package com.example.myapplication.Navbar
import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ControlledComposition
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.example.myapplication.ui.theme.BlueNavbar
@OptIn(ExperimentalMaterial3Api::class)
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
fun NavBar(){
val navController = rememberNavController()
val items = listOf(
NavItem.Basket,
NavItem.ListOfServices,
NavItem.Profile
)
Scaffold(bottomBar = {
BottomNavigation(
backgroundColor = BlueNavbar
){
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
items.forEach { screen ->
BottomNavigationItem(
icon = { ContextCompat.getDrawable(LocalContext.current, screen.icon)},
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {
navController.navigate(screen.route){
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
}
)
}
}
}){paddingValues ->
Column(modifier = Modifier
.fillMaxSize()
.padding(bottom = paddingValues.calculateBottomPadding())
.verticalScroll(rememberScrollState())) {
}
NavController(navController = navController)
}
}
@Composable
@Preview
fun NavigatePreview(){
NavBar()
}

View File

@ -0,0 +1,46 @@
package com.example.myapplication.Navbar
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.example.myapplication.Basket.Basket
import com.example.myapplication.List_of_Services.ListOfServices
import com.example.myapplication.Profile.Profile
@Composable
fun NavController(navController : NavHostController){
NavHost(
navController = navController,
startDestination = "list_of_services"
){
composable(
"list_of_services"
){
ListOfServices()
}
composable(
"basket/{userId}"
){
backStackEntry ->
backStackEntry.arguments?.getString("userId")?.let {
Basket(
navController,
it.toLong()
)
}
}
composable(
"profile/{userId}"
){
backStackEntry ->
backStackEntry.arguments?.getString("userId")?.let {
Profile(
navController,
it.toLong()
)
}
}
}
}

View File

@ -0,0 +1,24 @@
package com.example.myapplication.Navbar
import androidx.annotation.DrawableRes
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import com.example.myapplication.R
sealed class NavItem(
val route: String,
@DrawableRes val icon: Int
){
object ListOfServices : NavItem(
"list_of_services",
R.drawable.icon_list_of_services
)
object Basket : NavItem(
"basket",
R.drawable.icon_basket
)
object Profile : NavItem(
"profile",
R.drawable.icon_profile
)
}

View File

@ -0,0 +1,6 @@
package com.example.myapplication.Profile
import androidx.navigation.NavHostController
fun Profile(navController: NavHostController, userId : Long){
}

View File

@ -0,0 +1,8 @@
package com.example.myapplication.UIComponents
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
@Composable
fun Button(color: Color, text: String){
}

View File

@ -0,0 +1,39 @@
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.ui.res.stringResource
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.example.myapplication.R
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SearchBar(
modifier: Modifier = Modifier
) {
TextField(
value = "",
onValueChange = {},
leadingIcon = {
Icon(
imageVector = Icons.Default.Search,
contentDescription = null
)
},
placeholder = {
Text(stringResource(R.string.placeholder_search))
},
modifier = modifier
.fillMaxWidth()
.heightIn(min = 56.dp)
)
}

View File

@ -8,4 +8,12 @@ val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val Pink40 = Color(0xFF7D5260)
val BlueMain = Color(0xFFB3E5FC)
val RedBtn = Color(0xFF960000)
val GreenBtn = Color(0xFF009688)
val TextPrimary = Color(0xFF212121)
val TextSecondary = Color(0xFF757575)
val White = Color(0xFFFFFFFF)
val BlueNavbar = Color(0x6603A9F4)

View File

@ -38,7 +38,7 @@ private val LightColorScheme = lightColorScheme(
)
@Composable
fun MyApplicationTheme(
fun AppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="41dp"
android:height="50dp"
android:viewportWidth="41"
android:viewportHeight="50">
<path
android:pathData="M35.372,10H30.319C30.319,4.475 25.796,0 20.213,0C14.629,0 10.106,4.475 10.106,10H5.053C2.274,10 0,12.25 0,15V45C0,47.75 2.274,50 5.053,50H35.372C38.152,50 40.425,47.75 40.425,45V15C40.425,12.25 38.152,10 35.372,10ZM20.213,5C22.992,5 25.266,7.25 25.266,10H15.16C15.16,7.25 17.434,5 20.213,5ZM35.372,45H5.053V15H10.106V20C10.106,21.375 11.243,22.5 12.633,22.5C14.023,22.5 15.16,21.375 15.16,20V15H25.266V20C25.266,21.375 26.403,22.5 27.793,22.5C29.182,22.5 30.319,21.375 30.319,20V15H35.372V45Z"
android:fillColor="#009688"/>
</vector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="55dp"
android:height="44dp"
android:viewportWidth="55"
android:viewportHeight="44">
<path
android:strokeWidth="1"
android:pathData="M33.024,30.721L32.74,30.438L32.401,30.653C30.58,31.815 28.418,32.5 26.097,32.5C19.554,32.5 14.25,27.197 14.25,20.625C14.25,14.054 19.554,8.75 26.125,8.75C32.696,8.75 38,14.054 38,20.625C38,22.944 37.316,25.08 36.152,26.931L35.939,27.27L36.222,27.552L42.577,33.881L39.38,37.078L33.024,30.721ZM49.5,39H50V38.5V5.5V5H49.5H5.5H5V5.5V38.5V39H5.5H49.5ZM33.5,20.625C33.5,16.554 30.196,13.25 26.125,13.25C22.054,13.25 18.75,16.554 18.75,20.625C18.75,24.696 22.054,28 26.125,28C30.196,28 33.5,24.696 33.5,20.625ZM5.5,0.5H49.5C52.249,0.5 54.5,2.751 54.5,5.5V38.5C54.5,41.249 52.249,43.5 49.5,43.5H5.5C2.751,43.5 0.5,41.249 0.5,38.5V5.5C0.5,2.751 2.751,0.5 5.5,0.5Z"
android:fillColor="#009688"
android:strokeColor="#009688"/>
</vector>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="50dp"
android:viewportWidth="50"
android:viewportHeight="50">
<path
android:pathData="M25,0C11.2,0 0,11.2 0,25C0,38.8 11.2,50 25,50C38.8,50 50,38.8 50,25C50,11.2 38.8,0 25,0ZM13.375,41.25C16.65,38.9 20.65,37.5 25,37.5C29.35,37.5 33.35,38.9 36.625,41.25C33.35,43.6 29.35,45 25,45C20.65,45 16.65,43.6 13.375,41.25ZM40.35,37.8C36.125,34.5 30.8,32.5 25,32.5C19.2,32.5 13.875,34.5 9.65,37.8C6.75,34.325 5,29.875 5,25C5,13.95 13.95,5 25,5C36.05,5 45,13.95 45,25C45,29.875 43.25,34.325 40.35,37.8Z"
android:fillColor="#009688"/>
<path
android:pathData="M25,10C20.175,10 16.25,13.925 16.25,18.75C16.25,23.575 20.175,27.5 25,27.5C29.825,27.5 33.75,23.575 33.75,18.75C33.75,13.925 29.825,10 25,10ZM25,22.5C22.925,22.5 21.25,20.825 21.25,18.75C21.25,16.675 22.925,15 25,15C27.075,15 28.75,16.675 28.75,18.75C28.75,20.825 27.075,22.5 25,22.5Z"
android:fillColor="#009688"/>
</vector>

View File

@ -1,3 +1,5 @@
<resources>
<string name="app_name">My Application</string>
<string name="app_name">PetMed</string>
<string name="not_auth_error">Please login</string>
<string name="placeholder_search">Search…</string>
</resources>