Compare commits
No commits in common. "a7d961393f53ad25296c46713c435aa19583b969" and "7a3c9730a282ad676c436dbbac515beb4b7130ae" have entirely different histories.
a7d961393f
...
7a3c9730a2
|
|
@ -11,7 +11,6 @@ import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
import androidx.compose.material.icons.filled.Delete
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
|
|
@ -21,7 +20,6 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
|
|
@ -43,9 +41,6 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
|
||||||
|
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
|
|
||||||
val openTagFilterDialog = remember { mutableStateOf(false) }
|
|
||||||
val selectedEntries = remember { mutableStateOf(listOf<RecipeWithTags>()) }
|
|
||||||
|
|
||||||
val isInSearch = isInSearch@{ entry: RecipeWithTags ->
|
val isInSearch = isInSearch@{ entry: RecipeWithTags ->
|
||||||
val isSearchEmpty = search.value == null || search.value!!.isEmpty()
|
val isSearchEmpty = search.value == null || search.value!!.isEmpty()
|
||||||
val hasTitle = entry.recipe.title.contains(search.value.orEmpty(), ignoreCase = true)
|
val hasTitle = entry.recipe.title.contains(search.value.orEmpty(), ignoreCase = true)
|
||||||
|
|
@ -57,7 +52,7 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
|
||||||
return@isInSearch false
|
return@isInSearch false
|
||||||
}
|
}
|
||||||
|
|
||||||
val totalFilters = filters.value.stream().filter { f -> f.checked }.count()
|
val totalFilters = filters.value.stream().filter{ f -> f.checked }.count()
|
||||||
var checkedFilters = 0
|
var checkedFilters = 0
|
||||||
|
|
||||||
for (filter in filters.value) {
|
for (filter in filters.value) {
|
||||||
|
|
@ -66,9 +61,10 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
|
||||||
.filter { tag -> tag.name.contains(filter.tag, ignoreCase = true) }
|
.filter { tag -> tag.name.contains(filter.tag, ignoreCase = true) }
|
||||||
.count() > 0
|
.count() > 0
|
||||||
|
|
||||||
if (hasTagFilters) {
|
if(hasTagFilters) {
|
||||||
checkedFilters += 1
|
checkedFilters += 1
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
checkedFilters -= 1
|
checkedFilters -= 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +78,8 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val openTagFilterDialog = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
NavHost(
|
NavHost(
|
||||||
navController = navController,
|
navController = navController,
|
||||||
startDestination = "list"
|
startDestination = "list"
|
||||||
|
|
@ -110,55 +108,24 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
|
||||||
contentDescription = "Toggle tags filtering menu"
|
contentDescription = "Toggle tags filtering menu"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Load / Delete
|
// Load
|
||||||
if (selectedEntries.value.isNotEmpty()) {
|
IconButton(
|
||||||
IconButton(
|
modifier = Modifier.weight(0.15f),
|
||||||
modifier = Modifier.weight(0.15f),
|
onClick = { ctx.sourceChooser.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)) },
|
||||||
onClick = {
|
) {
|
||||||
// TODO I feel like this could be done in batch or something...but I truly don't care atm
|
Icon(
|
||||||
for (entry in selectedEntries.value) {
|
imageVector = Icons.Default.Add,
|
||||||
view.removeRecipe(entry)
|
contentDescription = "Load recipes from filesystem"
|
||||||
ctx.db.recipeDao().delete(entry.recipe)
|
)
|
||||||
ctx.db.recipeWithTagsDao().delete(entry.recipe.title)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Delete,
|
|
||||||
tint = Color(0xFFFF0000),
|
|
||||||
contentDescription = "Load recipes from filesystem"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
IconButton(
|
|
||||||
modifier = Modifier.weight(0.15f),
|
|
||||||
onClick = { ctx.sourceChooser.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)) },
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Add,
|
|
||||||
contentDescription = "Load recipes from filesystem"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LazyColumn {
|
LazyColumn {
|
||||||
items(recipes.value) { entry ->
|
items(recipes.value) { entry ->
|
||||||
if (isInSearch(entry)) {
|
if (isInSearch(entry)) {
|
||||||
val previewUri = entry.recipe.previewImage(LocalContext.current)
|
val previewUri = entry.recipe.previewImage(LocalContext.current)
|
||||||
val isSelected = selectedEntries.value.contains(entry)
|
RecipePreview(entry, previewUri, onClick = {
|
||||||
RecipePreview(entry, previewUri, isSelected, onClick = {
|
|
||||||
view.setActive(entry)
|
view.setActive(entry)
|
||||||
navController.navigate("info")
|
navController.navigate("info")
|
||||||
}, onSelected = { flag ->
|
|
||||||
selectedEntries.value =
|
|
||||||
selectedEntries.value.toMutableList().apply {
|
|
||||||
if (flag) {
|
|
||||||
add(entry)
|
|
||||||
} else {
|
|
||||||
remove(entry)
|
|
||||||
}
|
|
||||||
}.toList()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package xyz.pixelatedw.recipe.ui.components
|
package xyz.pixelatedw.recipe.ui.components
|
||||||
|
|
||||||
import android.text.format.DateFormat
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
|
@ -37,8 +36,6 @@ import xyz.pixelatedw.recipe.MainActivity
|
||||||
import xyz.pixelatedw.recipe.data.RecipeWithTags
|
import xyz.pixelatedw.recipe.data.RecipeWithTags
|
||||||
import xyz.pixelatedw.recipe.data.RecipesView
|
import xyz.pixelatedw.recipe.data.RecipesView
|
||||||
import xyz.pixelatedw.recipe.utils.parseMarkdown
|
import xyz.pixelatedw.recipe.utils.parseMarkdown
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RecipeInfo(
|
fun RecipeInfo(
|
||||||
|
|
@ -52,11 +49,6 @@ fun RecipeInfo(
|
||||||
val openDeletionDialog = remember { mutableStateOf(false) }
|
val openDeletionDialog = remember { mutableStateOf(false) }
|
||||||
val picsCounts = remember { active.recipe.pics.size };
|
val picsCounts = remember { active.recipe.pics.size };
|
||||||
|
|
||||||
val timestamp = view.activeRecipe.collectAsState().value?.recipe?.lastModified ?: 0
|
|
||||||
val calendar = Calendar.getInstance(Locale.ENGLISH)
|
|
||||||
calendar.timeInMillis = timestamp
|
|
||||||
val lastModified = DateFormat.format("yyyy-MM-dd",calendar).toString()
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
|
|
@ -121,20 +113,29 @@ fun RecipeInfo(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Box(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxHeight()
|
.fillMaxWidth()
|
||||||
.padding(start = 16.dp)
|
.padding(end = 16.dp),
|
||||||
|
horizontalArrangement = Arrangement.End
|
||||||
) {
|
) {
|
||||||
Text(
|
Box(
|
||||||
text = "Last Modified",
|
modifier = Modifier
|
||||||
style = MaterialTheme.typography.bodySmall,
|
.fillMaxHeight()
|
||||||
)
|
.padding(start = 16.dp)
|
||||||
Text(
|
) {
|
||||||
text = lastModified,
|
Button(
|
||||||
modifier = Modifier.padding(start = 2.dp, top = 24.dp),
|
onClick = {
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
openDeletionDialog.value = true
|
||||||
)
|
},
|
||||||
|
colors = ButtonDefaults.buttonColors(containerColor = Color.Red)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Delete",
|
||||||
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@ package xyz.pixelatedw.recipe.ui.components
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.combinedClickable
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
|
@ -14,10 +12,7 @@ import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.ImageBitmap
|
import androidx.compose.ui.graphics.ImageBitmap
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
|
@ -33,14 +28,10 @@ import xyz.pixelatedw.recipe.data.Recipe
|
||||||
import xyz.pixelatedw.recipe.data.RecipeWithTags
|
import xyz.pixelatedw.recipe.data.RecipeWithTags
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RecipePreview(entry: RecipeWithTags, previewUri: Bitmap?, isSelected: Boolean, onClick: () -> Unit, onSelected: (Boolean) -> Unit) {
|
fun RecipePreview(entry: RecipeWithTags, previewUri: Bitmap?, onClick: () -> Unit) {
|
||||||
Column(modifier = Modifier
|
Column(modifier = Modifier
|
||||||
.background(color = if(isSelected) Color(0x11FF0000) else Color(0x00FFFFFF) )
|
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.combinedClickable(
|
.clickable(onClick = onClick)) {
|
||||||
onLongClick = { onSelected(!isSelected) },
|
|
||||||
onClick = onClick
|
|
||||||
)) {
|
|
||||||
Row(horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth().height(256.dp)) {
|
Row(horizontalArrangement = Arrangement.Center, modifier = Modifier.fillMaxWidth().height(256.dp)) {
|
||||||
if (previewUri != null) {
|
if (previewUri != null) {
|
||||||
Image(
|
Image(
|
||||||
|
|
|
||||||
29
example.md
29
example.md
|
|
@ -1,29 +0,0 @@
|
||||||
+++
|
|
||||||
title = "Example Recipe Name" # mandatory
|
|
||||||
tags = ["test", "recipe"] # optional
|
|
||||||
pics = ["pics/test.jpg", "pics/test2.jpg"] # optional, only reads jpgs
|
|
||||||
|
|
||||||
# Everything below here is just plain markdown,
|
|
||||||
# use whatever format or layout you feel fits your needs best
|
|
||||||
|
|
||||||
+++
|
|
||||||
|
|
||||||
- **Portions:**
|
|
||||||
- **Prep Time:**
|
|
||||||
- **Cook Time:**
|
|
||||||
|
|
||||||
## Ingredients
|
|
||||||
|
|
||||||
- Ingredient 1
|
|
||||||
|
|
||||||
- Ingredient 2
|
|
||||||
|
|
||||||
- Ingredient 3
|
|
||||||
|
|
||||||
## Steps
|
|
||||||
|
|
||||||
1. Step 1
|
|
||||||
|
|
||||||
2. Step 2
|
|
||||||
|
|
||||||
3. Step 3
|
|
||||||
Loading…
Reference in New Issue