Skip to content

Commit

Permalink
changed packages signature and made code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Mar 23, 2022
1 parent da6940f commit 8e40638
Show file tree
Hide file tree
Showing 34 changed files with 421 additions and 537 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,4 @@ dependencies {
implementation("com.google.firebase:firebase-crashlytics-ktx:18.2.9")
implementation("com.google.firebase:firebase-analytics-ktx:20.1.1")


// //DataStore
// implementation("androidx.datastore:datastore-preferences:1.0.0")
// implementation("androidx.datastore:datastore-preferences-core:1.0.0")
// //Retrofit
// implementation("com.squareup.retrofit2:retrofit:2.9.0")
// implementation("com.squareup.retrofit2:converter-gson:2.9.0")
// implementation("com.squareup.okhttp3:okhttp:4.9.3")
// implementation("com.squareup.okhttp3:logging-interceptor:4.9.2")
//
// Koin
// implementation("io.insert-koin:koin-android:3.1.5")
// implementation("io.insert-koin:koin-androidx-workmanager:3.1.5")
// implementation("io.insert-koin:koin-androidx-navigation:3.1.5")
// implementation("io.insert-koin:koin-androidx-compose:3.1.5")
//
// //WorkManager
// implementation("androidx.work:work-runtime-ktx:2.7.1")
// androidTestImplementation("androidx.work:work-testing:2.7.1")
// implementation("androidx.work:work-multiprocess:2.7.1")

}

This file was deleted.

34 changes: 17 additions & 17 deletions app/src/main/java/ru/tech/firenote/ui/composable/app/FirenoteApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ 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.single.dialog.MaterialDialog
import ru.tech.firenote.ui.composable.single.scaffold.FirenoteScaffold
import ru.tech.firenote.ui.composable.utils.WindowSize
import ru.tech.firenote.ui.theme.FirenoteTheme
import ru.tech.firenote.viewModel.MainViewModel
import ru.tech.firenote.viewModel.main.MainViewModel

@SuppressLint("SourceLockedOrientationActivity")
@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -35,14 +35,14 @@ fun FirenoteApp(
windowSize: WindowSize,
splitScreen: Boolean,
navController: NavHostController,
mainViewModel: MainViewModel = viewModel()
viewModel: MainViewModel = viewModel()
) {

val isScaffoldVisible by derivedStateOf {
!mainViewModel.showNoteCreation.currentState
|| !mainViewModel.showNoteCreation.targetState
|| !mainViewModel.showGoalCreation.currentState
|| !mainViewModel.showGoalCreation.targetState
!viewModel.showNoteCreation.currentState
|| !viewModel.showNoteCreation.targetState
|| !viewModel.showGoalCreation.currentState
|| !viewModel.showGoalCreation.targetState
}

FirenoteTheme {
Expand All @@ -55,9 +55,9 @@ fun FirenoteApp(
dismissText = R.string.close,
dismissAction = { context.finishAffinity() }
)
if (mainViewModel.searchMode.value) BackHandler {
mainViewModel.searchMode.value = false
mainViewModel.searchString.value = ""
if (viewModel.searchMode.value) BackHandler {
viewModel.searchMode.value = false
viewModel.updateSearch()
}


Expand All @@ -66,31 +66,31 @@ fun FirenoteApp(
LocalSnackbarHost provides snackbarHostState,
LocalWindowSize provides windowSize
) {
if (mainViewModel.isAuth.value) {
AuthScreen(mainViewModel.isAuth)
if (viewModel.isAuth.value) {
AuthScreen(viewModel.isAuth)
context.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
} else {
context.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
if (splitScreen) {
Row {
FirenoteScaffold(
modifier = Modifier.weight(1f),
mainViewModel = mainViewModel,
viewModel = viewModel,
navController = navController,
context = context
)
Surface(modifier = Modifier.weight(1.5f)) {
CreationContainer(mainViewModel, splitScreen)
CreationContainer(viewModel, splitScreen)
}
}
} else {
FirenoteScaffold(
modifier = Modifier.alpha(if (isScaffoldVisible) 1f else 0f),
mainViewModel = mainViewModel,
viewModel = viewModel,
navController = navController,
context = context
)
CreationContainer(mainViewModel, splitScreen)
CreationContainer(viewModel, splitScreen)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import ru.tech.firenote.ui.composable.screen.base.GoalListScreen
import ru.tech.firenote.ui.composable.screen.base.NoteListScreen
import ru.tech.firenote.ui.composable.screen.base.ProfileScreen
import ru.tech.firenote.ui.composable.screen.navigation.GoalListScreen
import ru.tech.firenote.ui.composable.screen.navigation.NoteListScreen
import ru.tech.firenote.ui.composable.screen.navigation.ProfileScreen
import ru.tech.firenote.ui.route.Screen
import ru.tech.firenote.viewModel.MainViewModel
import ru.tech.firenote.viewModel.main.MainViewModel

@Composable
fun Navigation(
navController: NavHostController,
contentPadding: PaddingValues,
mainViewModel: MainViewModel,
viewModel: MainViewModel,
) {
NavHost(
navController = navController,
Expand All @@ -26,29 +26,29 @@ fun Navigation(
) {
composable(Screen.NoteListScreen.route) {
NoteListScreen(
mainViewModel.showNoteCreation,
mainViewModel.globalNote,
mainViewModel.filterType,
mainViewModel.isDescendingFilter,
mainViewModel.searchString
viewModel.showNoteCreation,
viewModel.globalNote,
viewModel.filterType,
viewModel.isDescendingFilter,
viewModel.searchString
)
}
composable(Screen.GoalsScreen.route) {
GoalListScreen(
mainViewModel.showGoalCreation,
mainViewModel.globalGoal,
mainViewModel.filterType,
mainViewModel.isDescendingFilter,
mainViewModel.searchString
viewModel.showGoalCreation,
viewModel.globalGoal,
viewModel.filterType,
viewModel.isDescendingFilter,
viewModel.searchString
)
}
composable(Screen.ProfileScreen.route) {
ProfileScreen(
navController,
mainViewModel.selectedItem,
mainViewModel.resultLauncher,
mainViewModel.profileTitle,
mainViewModel.showUsernameDialog
viewModel.selectedItem,
viewModel.resultLauncher,
viewModel.profileTitle,
viewModel.showUsernameDialog
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ru.tech.firenote.R
import ru.tech.firenote.ui.composable.provider.LocalWindowSize
import ru.tech.firenote.ui.composable.utils.WindowSize
import ru.tech.firenote.ui.route.Screen
import ru.tech.firenote.viewModel.AuthViewModel
import ru.tech.firenote.viewModel.auth.AuthViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import androidx.compose.ui.unit.sp
import ru.tech.firenote.R
import ru.tech.firenote.ui.composable.single.text.MaterialTextField
import ru.tech.firenote.ui.route.Screen
import ru.tech.firenote.viewModel.AuthViewModel
import ru.tech.firenote.viewModel.auth.AuthViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ru.tech.firenote.R
import ru.tech.firenote.ui.composable.single.text.MaterialTextField
import ru.tech.firenote.ui.composable.single.Toast
import ru.tech.firenote.ui.composable.single.toast.Toast
import ru.tech.firenote.ui.route.Screen
import ru.tech.firenote.ui.state.UIState
import ru.tech.firenote.viewModel.AuthViewModel
import ru.tech.firenote.viewModel.auth.AuthViewModel


@OptIn(ExperimentalMaterial3Api::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ru.tech.firenote.R
import ru.tech.firenote.ui.composable.single.text.MaterialTextField
import ru.tech.firenote.ui.composable.single.Toast
import ru.tech.firenote.ui.composable.single.toast.Toast
import ru.tech.firenote.ui.route.Screen
import ru.tech.firenote.ui.state.UIState
import ru.tech.firenote.viewModel.AuthViewModel
import ru.tech.firenote.viewModel.auth.AuthViewModel


@OptIn(ExperimentalMaterial3Api::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,61 @@ 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.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.width
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
import ru.tech.firenote.ui.composable.single.placeholder.Placeholder
import ru.tech.firenote.viewModel.main.MainViewModel

@Composable
fun CreationContainer(mainViewModel: MainViewModel, splitScreen: Boolean) {
fun CreationContainer(viewModel: 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 (!viewModel.showNoteCreation.currentState) {
viewModel.clearGlobalNote()
if (splitScreen && viewModel.selectedItem.value == 0) {
Placeholder(icon = Icons.TwoTone.StickyNote2, textRes = 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))
}
if (!viewModel.showGoalCreation.currentState) {
viewModel.clearGlobalGoal()
if (splitScreen && viewModel.selectedItem.value in 1..2) {
Placeholder(icon = Icons.TwoTone.FactCheck, textRes = R.string.selectGoal)
}
}

AnimatedVisibility(
visibleState = mainViewModel.showNoteCreation,
visibleState = viewModel.showNoteCreation,
enter = fadeIn(),
exit = fadeOut()
) {
BackHandler { mainViewModel.showNoteCreation.targetState = false }
BackHandler { viewModel.showNoteCreation.targetState = false }

NoteCreationScreen(
state = mainViewModel.showNoteCreation,
globalNote = mainViewModel.globalNote
state = viewModel.showNoteCreation,
globalNote = viewModel.globalNote
)
}

AnimatedVisibility(
visibleState = mainViewModel.showGoalCreation,
visibleState = viewModel.showGoalCreation,
enter = fadeIn(),
exit = fadeOut()
) {
BackHandler { mainViewModel.showGoalCreation.targetState = false }
BackHandler { viewModel.showGoalCreation.targetState = false }

GoalCreationScreen(
state = mainViewModel.showGoalCreation,
globalGoal = mainViewModel.globalGoal
state = viewModel.showGoalCreation,
globalGoal = viewModel.globalGoal
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ import kotlinx.coroutines.launch
import ru.tech.firenote.R
import ru.tech.firenote.model.Goal
import ru.tech.firenote.model.GoalData
import ru.tech.firenote.ui.composable.single.MaterialDialog
import ru.tech.firenote.ui.composable.single.bar.EditableAppBar
import ru.tech.firenote.ui.composable.single.dialog.MaterialDialog
import ru.tech.firenote.ui.theme.goalColors
import ru.tech.firenote.utils.GlobalUtils.blend
import ru.tech.firenote.viewModel.GoalCreationViewModel
import ru.tech.firenote.viewModel.creation.GoalCreationViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import kotlinx.coroutines.launch
import ru.tech.firenote.R
import ru.tech.firenote.model.Note
import ru.tech.firenote.ui.composable.single.MaterialDialog
import ru.tech.firenote.ui.composable.single.bar.EditableAppBar
import ru.tech.firenote.ui.composable.single.dialog.MaterialDialog
import ru.tech.firenote.ui.composable.single.text.EditText
import ru.tech.firenote.ui.theme.noteColors
import ru.tech.firenote.utils.GlobalUtils.blend
import ru.tech.firenote.viewModel.NoteCreationViewModel
import ru.tech.firenote.viewModel.creation.NoteCreationViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down
Loading

0 comments on commit 8e40638

Please sign in to comment.