Skip to content

Commit

Permalink
10/08/2023.
Browse files Browse the repository at this point in the history
  • Loading branch information
youndon committed Aug 10, 2023
1 parent 67cb17c commit 3cc5ac3
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 0 deletions.
3 changes: 3 additions & 0 deletions enigma-backup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
*/
!.gitignore
37 changes: 37 additions & 0 deletions ui/features/tags/src/main/java/com/example/tags/state/State.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.example.tags.state

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.example.tags.viewmodel.NoteAndTagViewModel
import com.example.tags.viewmodel.TagViewModel

internal sealed class State {

@Stable
class Tag(
private val viewModel: TagViewModel
) : State() {
val rememberAllTags
@Composable get() =
remember(
viewModel,
viewModel::getAllLTags
).collectAsStateWithLifecycle().value

}

@Stable
class NoteTag(
private val viewModel: NoteAndTagViewModel
): State() {

val rememberAllNoteTags
@Composable get() =
remember(
viewModel,
viewModel::getAllNotesAndTags
).collectAsStateWithLifecycle().value
}
}
185 changes: 185 additions & 0 deletions ui/graph/src/main/java/com/example/graph/Graph.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
package com.example.graph

import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.example.common_ui.Cons.ADD_ROUTE
import com.example.common_ui.Cons.AUDIO_DURATION
import com.example.common_ui.Cons.CAMERA_ROUTE
import com.example.common_ui.Cons.COLOR
import com.example.common_ui.Cons.DESCRIPTION
import com.example.common_ui.Cons.DRAW_ROUTE
import com.example.common_ui.Cons.EDIT_ROUTE
import com.example.common_ui.Cons.HOME_ROUTE
import com.example.common_ui.Cons.NON
import com.example.common_ui.Cons.PRIORITY
import com.example.common_ui.Cons.REMINDING
import com.example.common_ui.Cons.SETTING_ROUTE
import com.example.common_ui.Cons.TEXT_COLOR
import com.example.common_ui.Cons.TITLE
import com.example.common_ui.Cons.TRASH_ROUTE
import com.example.common_ui.Cons.UID
import com.example.graph.about_screen.AppAbout
import com.example.graph.draw_screen.DrawingNote
import com.example.graph.home_screen.NoteHome
import com.example.graph.settings_screen.Licenses
import com.example.graph.settings_screen.Settings
import com.example.graph.trash_screen.TrashScreen
import com.example.note.ui.add_screen.NoteAdd
import com.example.note.ui.edit_screen.NoteEdit
import com.example.tags.ui.Tags
import com.example.tasks.TaskList

@Composable
fun Graph(
navHostController: NavHostController
) {

NavHost(navController = navHostController, startDestination = HOME_ROUTE) {
composable(route = HOME_ROUTE) {
NoteHome(navController = navHostController)
}
composable(
route = "$ADD_ROUTE/{$UID}/{$DESCRIPTION}",
arguments = listOf(
navArgument(UID) {
type = NavType.StringType
},
navArgument(DESCRIPTION) {
nullable = true
type = NavType.StringType
}
)) {
NoteAdd(
navController = navHostController,
uid = it.arguments?.getString(UID) ?:"",
description = it.arguments?.getString(DESCRIPTION) ?: ""
)
}
composable(
route = "$EDIT_ROUTE/{$UID}/{$TITLE}/{$DESCRIPTION}/{$COLOR}/{$TEXT_COLOR}/" +
"{$PRIORITY}/{$AUDIO_DURATION}/{$REMINDING}",
arguments = listOf(
navArgument(UID) {
type = NavType.StringType
},
navArgument(TITLE) {
nullable = true
type = NavType.StringType
},
navArgument(DESCRIPTION) {
nullable = true
type = NavType.StringType
},
navArgument(COLOR) {
type = NavType.IntType
},
navArgument(TEXT_COLOR) {
type = NavType.IntType
},
navArgument(PRIORITY) {
type = NavType.StringType
},
navArgument(AUDIO_DURATION) {
type = NavType.IntType
},
navArgument(REMINDING) {
type = NavType.LongType
}
)
) {
NoteEdit(
navController = navHostController,
title = it.arguments?.getString(TITLE),
description = it.arguments?.getString(DESCRIPTION),
color = it.arguments?.getInt(COLOR) ?: 0,
textColor = it.arguments?.getInt(TEXT_COLOR) ?: 0x0000,
priority = it.arguments?.getString(PRIORITY) ?: NON,
uid = it.arguments?.getString(UID) ?: "",
audioDuration = it.arguments?.getInt(AUDIO_DURATION) ?: 0,
reminding = it.arguments?.getLong(REMINDING) ?: 0L
)
}
composable("$DRAW_ROUTE/{$TITLE}/{$DESCRIPTION}/{$COLOR}/{$TEXT_COLOR}/" +
"{$PRIORITY}/{$UID}/{$AUDIO_DURATION}/{$REMINDING}",
arguments = listOf(
navArgument(TITLE) {
type = NavType.StringType
},
navArgument(DESCRIPTION) {
type = NavType.StringType
},
navArgument(COLOR) {
type = NavType.IntType
},
navArgument(TEXT_COLOR) {
type = NavType.IntType
},
navArgument(PRIORITY) {
type = NavType.StringType
},
navArgument(UID) {
type = NavType.StringType
},
navArgument(AUDIO_DURATION) {
type = NavType.IntType
},
navArgument(REMINDING) {
type = NavType.LongType
}
)) {
DrawingNote(
navController = navHostController,
title = it.arguments?.getString(TITLE) ?: "",
description = it.arguments?.getString(DESCRIPTION) ?: "",
color = it.arguments?.getInt(COLOR),
priority = it.arguments?.getString(PRIORITY) ?: NON,
textColor = it.arguments?.getInt(TEXT_COLOR) ?: 0x00000,
uid = it.arguments?.getString(UID) ?: "",
audioDuration = it.arguments?.getInt(AUDIO_DURATION) ?: 0,
reminding = it.arguments?.getLong(REMINDING) ?: 0L
)
}
composable(route = "$CAMERA_ROUTE/{$UID}", arguments = listOf(
navArgument(UID){
type = NavType.StringType
}
)){
// LaunchCameraX(uid = it.arguments?.getString(UUID))
}

composable(TRASH_ROUTE){
TrashScreen(navController = navHostController)
}

composable(SETTING_ROUTE){
Settings(navC = navHostController)
}
composable("tagEntities/{$UID}", arguments = listOf(
navArgument(UID) {
nullable = true
type = NavType.StringType
}
)) {
Tags(
noteUid = it.arguments?.getString(UID) ?: "",
)
}
composable("todo/{$UID}", arguments = listOf(
navArgument(UID) {
type = NavType.StringType
}
)) {
TaskList(noteUid = it.arguments?.getString(UID) ?: "")
}
composable("licenses") {
Licenses()
}
composable("about") {
AppAbout(navC = navHostController)
}
}
}
46 changes: 46 additions & 0 deletions ui/graph/src/main/java/com/example/graph/intentHandler.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.example.graph

import android.content.Context
import android.content.Intent
import android.widget.Toast
import androidx.navigation.NavHostController
import com.example.graph.CONS.ADD_ROUTE
import com.example.graph.CONS.NUL
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import java.util.*

fun intentHandler(
intent: Intent,
ctx: Context,
navHC: NavHostController,
scope: CoroutineScope
) {
intent.apply {
if (action == Intent.ACTION_SEND && type == "text/plain") {
getStringExtra(Intent.EXTRA_TEXT)?.let {
scope.launch {
navHC.navigate("$ADD_ROUTE/${UUID.randomUUID()}/${codeUrl(it)}")
}
Toast.makeText(ctx, it, Toast.LENGTH_SHORT).show()
}
}
if (action == Intent.ACTION_VIEW) {
if (extras?.containsKey("new_shortcut") == true) {
getBooleanExtra("new_shortcut", false)
scope.launch {
navHC.navigate("$ADD_ROUTE/${UUID.randomUUID()}/$NUL")
}
}
if (extras?.containsKey("quick_note") == true) {
getBooleanExtra("quick_note", false)
scope.launch {
navHC.navigate("$ADD_ROUTE/${UUID.randomUUID()}/$NUL")
}
}

}
removeCategory(Intent.CATEGORY_DEFAULT)
action = null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.graph.navigation_drawer

enum class Screens {
HOME_SCREEN,
TRASH_SCREEN,
ABOUT_SCREEN,
SETTINGS_SCREEN,
FEEDBACK_SCREEN;
}

0 comments on commit 3cc5ac3

Please sign in to comment.