From 3536cfc011ffcdb050897f40ab7406c9f7580c9d Mon Sep 17 00:00:00 2001 From: T8RIN Date: Sun, 27 Mar 2022 21:22:05 +0300 Subject: [PATCH] new animations added and colors of goals corrected --- .../java/ru/tech/firenote/MainActivity.kt | 6 ++ .../firenote/ui/composable/app/FirenoteApp.kt | 2 + .../ui/composable/navigation/Navigation.kt | 2 + ...vider.kt => LocalLazyListStateProvider.kt} | 0 .../screen/creation/CreationContainer.kt | 4 + .../screen/creation/NoteCreationScreen.kt | 10 ++- .../screen/navigation/NoteListScreen.kt | 8 +- .../ui/composable/single/bar/AppBarActions.kt | 89 ++++++++++++++++++- .../single/scaffold/FirenoteScaffold.kt | 8 +- .../java/ru/tech/firenote/ui/theme/Color.kt | 11 ++- app/src/main/res/values-ru-rRU/strings.xml | 4 + app/src/main/res/values/strings.xml | 6 +- 12 files changed, 135 insertions(+), 15 deletions(-) rename app/src/main/java/ru/tech/firenote/ui/composable/provider/{LocalVerticalScrollStateProvider.kt => LocalLazyListStateProvider.kt} (100%) diff --git a/app/src/main/java/ru/tech/firenote/MainActivity.kt b/app/src/main/java/ru/tech/firenote/MainActivity.kt index 351b0c9..892bccf 100644 --- a/app/src/main/java/ru/tech/firenote/MainActivity.kt +++ b/app/src/main/java/ru/tech/firenote/MainActivity.kt @@ -3,6 +3,9 @@ package ru.tech.firenote import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.core.view.WindowCompat import androidx.navigation.compose.rememberNavController import dagger.hilt.android.AndroidEntryPoint @@ -11,7 +14,10 @@ import ru.tech.firenote.ui.composable.utils.WindowSize import ru.tech.firenote.ui.composable.utils.rememberWindowSizeClass +@ExperimentalFoundationApi @AndroidEntryPoint +@ExperimentalMaterial3Api +@ExperimentalAnimationApi class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/app/FirenoteApp.kt b/app/src/main/java/ru/tech/firenote/ui/composable/app/FirenoteApp.kt index 3c0c605..42560d9 100644 --- a/app/src/main/java/ru/tech/firenote/ui/composable/app/FirenoteApp.kt +++ b/app/src/main/java/ru/tech/firenote/ui/composable/app/FirenoteApp.kt @@ -5,6 +5,7 @@ import android.content.pm.ActivityInfo import androidx.activity.ComponentActivity import androidx.activity.compose.BackHandler import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Row import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons @@ -34,6 +35,7 @@ import ru.tech.firenote.ui.composable.utils.WindowSize import ru.tech.firenote.ui.theme.FirenoteTheme import ru.tech.firenote.viewModel.main.MainViewModel +@ExperimentalFoundationApi @SuppressLint("SourceLockedOrientationActivity") @ExperimentalMaterial3Api @ExperimentalAnimationApi diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/navigation/Navigation.kt b/app/src/main/java/ru/tech/firenote/ui/composable/navigation/Navigation.kt index 2eb805e..e085a31 100644 --- a/app/src/main/java/ru/tech/firenote/ui/composable/navigation/Navigation.kt +++ b/app/src/main/java/ru/tech/firenote/ui/composable/navigation/Navigation.kt @@ -1,5 +1,6 @@ package ru.tech.firenote.ui.composable.navigation +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable @@ -13,6 +14,7 @@ import ru.tech.firenote.ui.composable.screen.navigation.ProfileScreen import ru.tech.firenote.ui.route.Screen import ru.tech.firenote.viewModel.main.MainViewModel +@ExperimentalFoundationApi @Composable fun Navigation( navController: NavHostController, diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/provider/LocalVerticalScrollStateProvider.kt b/app/src/main/java/ru/tech/firenote/ui/composable/provider/LocalLazyListStateProvider.kt similarity index 100% rename from app/src/main/java/ru/tech/firenote/ui/composable/provider/LocalVerticalScrollStateProvider.kt rename to app/src/main/java/ru/tech/firenote/ui/composable/provider/LocalLazyListStateProvider.kt diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/CreationContainer.kt b/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/CreationContainer.kt index 1f87359..9295685 100644 --- a/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/CreationContainer.kt +++ b/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/CreationContainer.kt @@ -2,6 +2,7 @@ package ru.tech.firenote.ui.composable.screen.creation import androidx.activity.compose.BackHandler import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.layout.Box @@ -12,6 +13,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.twotone.FactCheck import androidx.compose.material.icons.twotone.StickyNote2 import androidx.compose.material3.Divider +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.mutableStateOf @@ -23,6 +25,8 @@ import ru.tech.firenote.R import ru.tech.firenote.ui.composable.single.placeholder.Placeholder import ru.tech.firenote.viewModel.main.MainViewModel +@ExperimentalMaterial3Api +@ExperimentalAnimationApi @Composable fun CreationContainer(viewModel: MainViewModel, splitScreen: Boolean) { Box(Modifier.fillMaxSize()) { diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/NoteCreationScreen.kt b/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/NoteCreationScreen.kt index 9cf8130..2a91b97 100644 --- a/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/NoteCreationScreen.kt +++ b/app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/NoteCreationScreen.kt @@ -1,7 +1,7 @@ package ru.tech.firenote.ui.composable.screen.creation import androidx.activity.compose.BackHandler -import androidx.compose.animation.Animatable +import androidx.compose.animation.* import androidx.compose.animation.core.MutableTransitionState import androidx.compose.animation.core.tween import androidx.compose.foundation.* @@ -38,6 +38,7 @@ import ru.tech.firenote.ui.theme.noteColors import ru.tech.firenote.utils.GlobalUtils.blend import ru.tech.firenote.viewModel.creation.NoteCreationViewModel +@ExperimentalAnimationApi @ExperimentalMaterial3Api @Composable fun NoteCreationScreen( @@ -145,7 +146,11 @@ fun NoteCreationScreen( ) ) { item { - if (editionMode) { + AnimatedVisibility( + editionMode, + enter = fadeIn() + slideInHorizontally(), + exit = fadeOut() + slideOutHorizontally() + ) { LazyRow( modifier = Modifier.fillMaxSize(), horizontalArrangement = Arrangement.SpaceEvenly, @@ -203,6 +208,7 @@ fun NoteCreationScreen( } } } + EditText( textFieldState = viewModel.noteContent, topPadding = 20.dp, diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/screen/navigation/NoteListScreen.kt b/app/src/main/java/ru/tech/firenote/ui/composable/screen/navigation/NoteListScreen.kt index 1d7b939..bf7da2e 100644 --- a/app/src/main/java/ru/tech/firenote/ui/composable/screen/navigation/NoteListScreen.kt +++ b/app/src/main/java/ru/tech/firenote/ui/composable/screen/navigation/NoteListScreen.kt @@ -71,15 +71,15 @@ fun NoteListScreen( val repoList = state.data as List var data = if (isDescendingFilter.value) { when (filterType.value) { + 0 -> repoList.sortedBy { it.title } 1 -> repoList.sortedBy { (it.color ?: 0).priority } - 2 -> repoList.sortedBy { it.timestamp } - else -> repoList.sortedBy { it.title } + else -> repoList.sortedBy { it.timestamp } } } else { when (filterType.value) { + 0 -> repoList.sortedByDescending { it.title } 1 -> repoList.sortedByDescending { (it.color ?: 0).priority } - 2 -> repoList.sortedByDescending { it.timestamp } - else -> repoList.sortedByDescending { it.title } + else -> repoList.sortedByDescending { it.timestamp } } } diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/single/bar/AppBarActions.kt b/app/src/main/java/ru/tech/firenote/ui/composable/single/bar/AppBarActions.kt index a0214d7..f77e0bf 100644 --- a/app/src/main/java/ru/tech/firenote/ui/composable/single/bar/AppBarActions.kt +++ b/app/src/main/java/ru/tech/firenote/ui/composable/single/bar/AppBarActions.kt @@ -10,11 +10,10 @@ import androidx.compose.material.icons.filled.Palette import androidx.compose.material.icons.filled.TextSnippet import androidx.compose.material.icons.outlined.* import androidx.compose.material3.* -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember +import androidx.compose.runtime.* import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -206,3 +205,87 @@ fun ProfileActions(onClick: () -> Unit) { backHandler = {} ) } + +@Composable +fun FileAttachActions(onItemSelected: (Attachments) -> Unit) { + + var showFilter by remember { mutableStateOf(false) } + + IconButton(onClick = { + showFilter = true + }) { + Icon(Icons.Outlined.AttachFile, null, tint = Color.Black) + } + + DropdownMenu( + expanded = showFilter, + onDismissRequest = { showFilter = false } + ) { + DropdownMenuItem( + onClick = { + showFilter = false + onItemSelected(Attachments.IMAGE) + }, + text = { Text(stringResource(R.string.image)) }, + leadingIcon = { Icon(Icons.Outlined.Image, null) } + ) + DropdownMenuItem( + onClick = { + showFilter = false + onItemSelected(Attachments.DOCUMENT) + }, + text = { Text(stringResource(R.string.document)) }, + leadingIcon = { Icon(Icons.Outlined.TextSnippet, null) } + ) + DropdownMenuItem( + onClick = { + showFilter = false + onItemSelected(Attachments.AUDIO) + }, + text = { Text(stringResource(R.string.Audio)) }, + leadingIcon = { Icon(Icons.Outlined.MusicNote, null) } + ) + DropdownMenuItem( + onClick = { + showFilter = false + onItemSelected(Attachments.FILE) + }, + text = { Text(stringResource(R.string.File)) }, + leadingIcon = { Icon(Icons.Outlined.InsertDriveFile, null) } + ) + } + +// val contentLauncher = rememberLauncherForActivityResult( +// ActivityResultContracts.GetContent() +// ) { uri: Uri? -> +// uri?.let { viewModel.addAttachment(uri) } +// } +// +// val documentLauncher = rememberLauncherForActivityResult( +// ActivityResultContracts.OpenDocument() +// ) { uri: Uri? -> +// uri?.let { viewModel.addAttachment(uri) } +// } +// +// FileAttachActions(onItemSelected = { +// when (it) { +// Attachments.IMAGE -> contentLauncher.launch("image/*") +// Attachments.DOCUMENT -> documentLauncher.launch(arrayOf( +// "docx", "doc", "ppt", "pptx", "xls", "xlsx", "pdf" +// ).toMimeType()) +// Attachments.AUDIO -> contentLauncher.launch("audio/*") +// else -> contentLauncher.launch("*/*") +// } +// }) + + + // fun Array.toMimeType() : Array { + // return this.map { + // MimeTypeMap.getSingleton().getMimeTypeFromExtension(it) ?: "" + // }.toTypedArray() + // } +} + +enum class Attachments { + IMAGE, DOCUMENT, AUDIO, FILE +} diff --git a/app/src/main/java/ru/tech/firenote/ui/composable/single/scaffold/FirenoteScaffold.kt b/app/src/main/java/ru/tech/firenote/ui/composable/single/scaffold/FirenoteScaffold.kt index 356f32d..2211048 100644 --- a/app/src/main/java/ru/tech/firenote/ui/composable/single/scaffold/FirenoteScaffold.kt +++ b/app/src/main/java/ru/tech/firenote/ui/composable/single/scaffold/FirenoteScaffold.kt @@ -2,8 +2,10 @@ package ru.tech.firenote.ui.composable.single.scaffold import android.content.Context import androidx.compose.animation.* +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.* import androidx.compose.material.icons.rounded.ArrowBack @@ -17,6 +19,7 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController import ru.tech.firenote.R import ru.tech.firenote.ui.composable.navigation.Navigation @@ -30,6 +33,7 @@ import ru.tech.firenote.ui.route.Screen import ru.tech.firenote.utils.GlobalUtils.isOnline import ru.tech.firenote.viewModel.main.MainViewModel +@ExperimentalFoundationApi @ExperimentalAnimationApi @ExperimentalMaterial3Api @Composable @@ -113,7 +117,9 @@ fun FirenoteScaffold( exit = fadeOut() + scaleOut() ) { Text( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 15.dp), text = if (viewModel.selectedItem.value == 2) viewModel.profileTitle.value else stringResource(viewModel.title.value), maxLines = 1, diff --git a/app/src/main/java/ru/tech/firenote/ui/theme/Color.kt b/app/src/main/java/ru/tech/firenote/ui/theme/Color.kt index aecd6bf..1d5aee6 100644 --- a/app/src/main/java/ru/tech/firenote/ui/theme/Color.kt +++ b/app/src/main/java/ru/tech/firenote/ui/theme/Color.kt @@ -16,8 +16,9 @@ val NoteWhite = Color(0xFFFFE2EB) val NoteBrown = Color(0xFFBD7857) val NoteGray = Color(0xFFA5969B) -val GoalGreen = Color(0xFF92CC77) -val GoalCarrot = Color(0xFFBBA05A) +val GoalGreen = Color(0xFF86C768) +val GoalYellow = Color(0xFFD8D76A) +val GoalCarrot = Color(0xFFD89D53) val GoalRed = Color(0xFFD57171) val md_theme_light_primary = Color(0xFF984065) @@ -94,6 +95,7 @@ val noteColors = val goalColors = listOf( GoalGreen, + GoalYellow, GoalCarrot, GoalRed ) @@ -133,6 +135,7 @@ val Int.position val Int.priorityGoal get() = when (this) { GoalGreen.toArgb() -> 0 - GoalCarrot.toArgb() -> 1 - else -> 2 + GoalYellow.toArgb() -> 1 + GoalCarrot.toArgb() -> 2 + else -> 3 } \ No newline at end of file diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index f8fb621..2087402 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -76,4 +76,8 @@ "Никнейм изменен на " Успешно выбрано изображение Тип заметки + Изображение + Документ + Музыка + Файл \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6ea5237..52ba6e9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -74,6 +74,10 @@ Search here Nothing found, try to change your search query "Username changed to " - Image picked succesfully + Image picked successfully Note type + Image + Document + Audio + File \ No newline at end of file