Skip to content

Commit

Permalink
new animations added and colors of goals corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Mar 27, 2022
1 parent b69f2f6 commit 3536cfc
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 15 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/ru/tech/firenote/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -145,7 +146,11 @@ fun NoteCreationScreen(
)
) {
item {
if (editionMode) {
AnimatedVisibility(
editionMode,
enter = fadeIn() + slideInHorizontally(),
exit = fadeOut() + slideOutHorizontally()
) {
LazyRow(
modifier = Modifier.fillMaxSize(),
horizontalArrangement = Arrangement.SpaceEvenly,
Expand Down Expand Up @@ -203,6 +208,7 @@ fun NoteCreationScreen(
}
}
}

EditText(
textFieldState = viewModel.noteContent,
topPadding = 20.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ fun NoteListScreen(
val repoList = state.data as List<Note>
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 }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String>.toMimeType() : Array<String> {
// return this.map {
// MimeTypeMap.getSingleton().getMimeTypeFromExtension(it) ?: ""
// }.toTypedArray()
// }
}

enum class Attachments {
IMAGE, DOCUMENT, AUDIO, FILE
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/ru/tech/firenote/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -94,6 +95,7 @@ val noteColors =
val goalColors =
listOf(
GoalGreen,
GoalYellow,
GoalCarrot,
GoalRed
)
Expand Down Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions app/src/main/res/values-ru-rRU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@
<string name="usernameChanged">"Никнейм изменен на "</string>
<string name="imagePicked">Успешно выбрано изображение</string>
<string name="noteType">Тип заметки</string>
<string name="image">Изображение</string>
<string name="document">Документ</string>
<string name="Audio">Музыка</string>
<string name="File">Файл</string>
</resources>
6 changes: 5 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<string name="searchHere">Search here</string>
<string name="nothingFound">Nothing found, try to change your search query</string>
<string name="usernameChanged">"Username changed to "</string>
<string name="imagePicked">Image picked succesfully</string>
<string name="imagePicked">Image picked successfully</string>
<string name="noteType">Note type</string>
<string name="image">Image</string>
<string name="document">Document</string>
<string name="Audio">Audio</string>
<string name="File">File</string>
</resources>

0 comments on commit 3536cfc

Please sign in to comment.