Skip to content

Commit

Permalink
Fixed notes as markdown crash
Browse files Browse the repository at this point in the history
They are not markdown currently
  • Loading branch information
Wavesonics committed Nov 3, 2023
1 parent 3f2e85b commit c344abc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
package com.darkrockstudios.apps.hammer.common.notes

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Create
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
Expand All @@ -32,7 +19,6 @@ import com.darkrockstudios.apps.hammer.common.components.notes.BrowseNotes
import com.darkrockstudios.apps.hammer.common.compose.Ui
import com.darkrockstudios.apps.hammer.common.compose.moko.get
import com.darkrockstudios.apps.hammer.common.data.notesrepository.note.NoteContent
import com.darkrockstudios.apps.hammer.common.data.text.markdownToAnnotatedString
import com.darkrockstudios.apps.hammer.common.util.format
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
Expand Down Expand Up @@ -96,7 +82,7 @@ fun NoteItem(
) {
Row {
Text(
note.content.markdownToAnnotatedString(),
note.content,
modifier = Modifier.weight(1f),
style = MaterialTheme.typography.bodyMedium
.copy(color = MaterialTheme.colorScheme.onBackground),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
package com.darkrockstudios.apps.hammer.common.notes

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Cancel
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.AnnotatedString
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
import com.darkrockstudios.apps.hammer.MR
import com.darkrockstudios.apps.hammer.common.TextEditorDefaults
Expand All @@ -36,7 +23,6 @@ import com.darkrockstudios.apps.hammer.common.compose.SimpleConfirm
import com.darkrockstudios.apps.hammer.common.compose.Ui
import com.darkrockstudios.apps.hammer.common.compose.moko.get
import com.darkrockstudios.apps.hammer.common.compose.rememberMainDispatcher
import com.darkrockstudios.apps.hammer.common.data.text.markdownToAnnotatedString
import com.darkrockstudios.apps.hammer.common.util.format
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand All @@ -50,6 +36,9 @@ fun ViewNoteUi(component: ViewNote, modifier: Modifier, rootSnackbar: RootSnackb
val scope = rememberCoroutineScope()
val mainDispatcher = rememberMainDispatcher()
val noteText by component.noteText.subscribeAsState()
val annotatedNoteText = remember(noteText) {
AnnotatedString.Builder(noteText).toAnnotatedString()
}

Card(
modifier = modifier.padding(Ui.Padding.XL)
Expand Down Expand Up @@ -137,7 +126,7 @@ fun ViewNoteUi(component: ViewNote, modifier: Modifier, rootSnackbar: RootSnackb
}
} else {
ClickableText(
noteText.markdownToAnnotatedString(),
annotatedNoteText,
modifier = Modifier.weight(1f),
style = MaterialTheme.typography.bodyMedium
.copy(color = MaterialTheme.colorScheme.onSurface),
Expand Down

0 comments on commit c344abc

Please sign in to comment.