-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed packages and removed deprecated accompanist insets library
- Loading branch information
Showing
20 changed files
with
445 additions
and
636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
app/src/main/java/ru/tech/firenote/ui/composable/app/FirenoteApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package ru.tech.firenote.ui.composable.app | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.pm.ActivityInfo | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.BackHandler | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.ExitToApp | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.SnackbarHostState | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.* | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.alpha | ||
import androidx.lifecycle.viewmodel.compose.viewModel | ||
import androidx.navigation.NavHostController | ||
import ru.tech.firenote.R | ||
import ru.tech.firenote.ui.composable.provider.LocalSnackbarHost | ||
import ru.tech.firenote.ui.composable.provider.LocalWindowSize | ||
import ru.tech.firenote.ui.composable.screen.auth.AuthScreen | ||
import ru.tech.firenote.ui.composable.screen.creation.CreationContainer | ||
import ru.tech.firenote.ui.composable.single.FirenoteScaffold | ||
import ru.tech.firenote.ui.composable.single.MaterialDialog | ||
import ru.tech.firenote.ui.composable.utils.WindowSize | ||
import ru.tech.firenote.ui.theme.FirenoteTheme | ||
import ru.tech.firenote.viewModel.MainViewModel | ||
|
||
@SuppressLint("SourceLockedOrientationActivity") | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun FirenoteApp( | ||
context: ComponentActivity, | ||
windowSize: WindowSize, | ||
splitScreen: Boolean, | ||
navController: NavHostController, | ||
mainViewModel: MainViewModel = viewModel() | ||
) { | ||
|
||
val isScaffoldVisible by derivedStateOf { | ||
!mainViewModel.showNoteCreation.currentState | ||
|| !mainViewModel.showNoteCreation.targetState | ||
|| !mainViewModel.showGoalCreation.currentState | ||
|| !mainViewModel.showGoalCreation.targetState | ||
} | ||
|
||
FirenoteTheme { | ||
MaterialDialog( | ||
showDialog = rememberSaveable { mutableStateOf(false) }, | ||
icon = Icons.Filled.ExitToApp, | ||
title = R.string.exitApp, | ||
message = R.string.exitAppMessage, | ||
confirmText = R.string.stay, | ||
dismissText = R.string.close, | ||
dismissAction = { context.finishAffinity() } | ||
) | ||
if (mainViewModel.searchMode.value) BackHandler { | ||
mainViewModel.searchMode.value = false | ||
mainViewModel.searchString.value = "" | ||
} | ||
|
||
|
||
val snackbarHostState = remember { SnackbarHostState() } | ||
CompositionLocalProvider( | ||
LocalSnackbarHost provides snackbarHostState, | ||
LocalWindowSize provides windowSize | ||
) { | ||
if (mainViewModel.isAuth.value) { | ||
AuthScreen(mainViewModel.isAuth) | ||
context.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT | ||
} else { | ||
context.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | ||
if (splitScreen) { | ||
Row { | ||
FirenoteScaffold( | ||
modifier = Modifier.weight(1f), | ||
mainViewModel = mainViewModel, | ||
navController = navController, | ||
context = context | ||
) | ||
Surface(modifier = Modifier.weight(1.5f)) { | ||
CreationContainer(mainViewModel, splitScreen) | ||
} | ||
} | ||
} else { | ||
FirenoteScaffold( | ||
modifier = Modifier.alpha(if (isScaffoldVisible) 1f else 0f), | ||
mainViewModel = mainViewModel, | ||
navController = navController, | ||
context = context | ||
) | ||
CreationContainer(mainViewModel, splitScreen) | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
app/src/main/java/ru/tech/firenote/ui/composable/screen/creation/CreationContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package ru.tech.firenote.ui.composable.screen.creation | ||
|
||
import androidx.activity.compose.BackHandler | ||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.foundation.layout.* | ||
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.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import ru.tech.firenote.R | ||
import ru.tech.firenote.viewModel.MainViewModel | ||
|
||
@Composable | ||
fun CreationContainer(mainViewModel: MainViewModel, splitScreen: Boolean) { | ||
Box(Modifier.fillMaxSize()) { | ||
if (!mainViewModel.showNoteCreation.currentState) { | ||
mainViewModel.globalNote.value = null | ||
if (splitScreen && mainViewModel.selectedItem.value == 0) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize(), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Icon(Icons.TwoTone.StickyNote2, null, modifier = Modifier.fillMaxSize(0.3f)) | ||
Text(stringResource(R.string.selectNote)) | ||
} | ||
} | ||
} | ||
if (!mainViewModel.showGoalCreation.currentState) { | ||
mainViewModel.globalGoal.value = null | ||
if (splitScreen && mainViewModel.selectedItem.value in 1..2) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize(), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Icon(Icons.TwoTone.FactCheck, null, modifier = Modifier.fillMaxSize(0.3f)) | ||
Text(stringResource(R.string.selectGoal)) | ||
} | ||
} | ||
} | ||
|
||
AnimatedVisibility( | ||
visibleState = mainViewModel.showNoteCreation, | ||
enter = fadeIn(), | ||
exit = fadeOut() | ||
) { | ||
BackHandler { mainViewModel.showNoteCreation.targetState = false } | ||
|
||
NoteCreationScreen( | ||
state = mainViewModel.showNoteCreation, | ||
globalNote = mainViewModel.globalNote | ||
) | ||
} | ||
|
||
AnimatedVisibility( | ||
visibleState = mainViewModel.showGoalCreation, | ||
enter = fadeIn(), | ||
exit = fadeOut() | ||
) { | ||
BackHandler { mainViewModel.showGoalCreation.targetState = false } | ||
|
||
GoalCreationScreen( | ||
state = mainViewModel.showGoalCreation, | ||
globalGoal = mainViewModel.globalGoal | ||
) | ||
} | ||
|
||
if (splitScreen) { | ||
Divider( | ||
Modifier | ||
.fillMaxHeight() | ||
.width(1.dp) | ||
.align(Alignment.CenterStart) | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.