Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,536 changes: 3,789 additions & 3,747 deletions application/core/resources/config/ktlint/baseline.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@
<string name="download_model">Download model</string>
<string name="choose_your_model">Write your AI model</string>
<string name="use_offline">Use in offline mode</string>
<string name="ai_explanation">[Tab - accept; Esc - remove]</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,5 @@
<string name="download_model">Baixar modelo</string>
<string name="choose_your_model">Escolhe seu modelo de IA</string>
<string name="use_offline">User offline</string>
<string name="ai_explanation">[Tab - aceitar; Esc - remover]</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@
<string name="download_model">Download model</string>
<string name="choose_your_model">Write your AI model</string>
<string name="use_offline">Use in offline mode</string>
<string name="ai_explanation">[Tab - accept; Esc - remove]</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import writeopia.application.core.resources.generated.resources.access_ollama_si
import writeopia.application.core.resources.generated.resources.account
import writeopia.application.core.resources.generated.resources.action_points
import writeopia.application.core.resources.generated.resources.actions
import writeopia.application.core.resources.generated.resources.ai_explanation
import writeopia.application.core.resources.generated.resources.are_you_sure
import writeopia.application.core.resources.generated.resources.arrangement
import writeopia.application.core.resources.generated.resources.ask_ai
Expand Down Expand Up @@ -403,4 +404,7 @@ object WrStrings {

@Composable
fun useOffline() = stringResource(Res.string.use_offline)

@Composable
fun aiExplanation() = stringResource(Res.string.ai_explanation)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.text.font.FontFamily
import io.writeopia.editor.configuration.ui.DrawConfigFactory
import io.writeopia.editor.features.editor.viewmodel.NoteEditorViewModel
import io.writeopia.model.Font
import io.writeopia.resources.WrStrings
import io.writeopia.ui.WriteopiaEditor
import io.writeopia.ui.drawer.factory.DrawersFactory
import io.writeopia.ui.model.DrawStory
Expand Down Expand Up @@ -70,6 +71,7 @@ internal fun TextEditor(
defaultBorder = clipShape,
onHeaderClick = noteEditorViewModel::onHeaderClick,
editable = isEditable,
aiExplanation = WrStrings.aiExplanation(),
isDarkTheme = isDarkTheme,
groupsBackgroundColor = Color.Transparent,
drawConfig = DrawConfigFactory.getDrawConfig(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,21 @@ class WriteopiaManager(

return if (suggestionsResult is ResultData.Complete) {
val suggestions = suggestionsResult.data
suggestions.map { suggestion ->
StoryStep(text = suggestion, type = storyType)
}.fold(storyState()) { state, story ->
addAtPosition(
state,
story.copy(
ephemeral = true,
tags = story.tags + TagInfo(Tag.AI_SUGGESTION)
),
position
)
}.copy(lastEdit = LastEdit.Whole)
suggestions.mapIndexed { i, suggestion ->
val tags = if (i == 0) {
setOf(TagInfo(Tag.AI_SUGGESTION), TagInfo(Tag.FIRST_AI_SUGGESTION))
} else {
setOf(TagInfo(Tag.AI_SUGGESTION))
}
StoryStep(text = suggestion, type = storyType, tags = tags)
}.reversed()
.fold(storyState()) { state, story ->
addAtPosition(
state,
story.copy(ephemeral = true),
position
)
}.copy(lastEdit = LastEdit.Whole)
} else {
storyState()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ enum class Tag(val label: String) {
HIGH_LIGHT_BLOCK("HIGH_LIGHT_BLOCK"),
HIDDEN_HX("HIGH_LIGHT_BLOCK"),
COLLAPSED("COLLAPSED"),
AI_SUGGESTION("AI_SUGGESTION");
AI_SUGGESTION("AI_SUGGESTION"),
FIRST_AI_SUGGESTION("FIRST_AI_SUGGESTION");

fun isTitle() =
when (this) {
Expand All @@ -23,17 +24,17 @@ enum class Tag(val label: String) {
}

fun hasPosition() = when (this) {
H1, H2, H3, H4, HIDDEN_HX, COLLAPSED, AI_SUGGESTION -> false
H1, H2, H3, H4, HIDDEN_HX, COLLAPSED, AI_SUGGESTION, FIRST_AI_SUGGESTION -> false
HIGH_LIGHT_BLOCK -> true
}

fun isErasable() = when (this) {
H1, H2, H3, H4, HIDDEN_HX, COLLAPSED, AI_SUGGESTION -> false
H1, H2, H3, H4, HIDDEN_HX, COLLAPSED, AI_SUGGESTION, FIRST_AI_SUGGESTION -> false
HIGH_LIGHT_BLOCK -> true
}

fun mustCarryOver() = when (this) {
H1, H2, H3, H4, HIDDEN_HX, COLLAPSED, AI_SUGGESTION -> false
H1, H2, H3, H4, HIDDEN_HX, COLLAPSED, AI_SUGGESTION, FIRST_AI_SUGGESTION -> false
HIGH_LIGHT_BLOCK -> true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ object DefaultDrawersAndroid : DrawersFactory {
manager: WriteopiaStateManager,
defaultBorder: Shape,
editable: Boolean,
aiExplanation: String,
isDarkTheme: Boolean,
groupsBackgroundColor: Color,
onHeaderClick: () -> Unit,
Expand All @@ -42,7 +43,7 @@ object DefaultDrawersAndroid : DrawersFactory {
val commonDrawers = CommonDrawers.create(
manager,
marginAtBottom = 500.dp,
defaultBorder,
aiExplanation = aiExplanation,
editable,
onHeaderClick,
lineBreakByContent = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ fun CheckItemDrawerStepPreview() {
TextDrawer(
selectionState = MutableStateFlow(false),
onSelectionLister = {},
isDarkTheme = true
isDarkTheme = true,
aiExplanation = ""
)
}
).Step(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ fun headerDrawer(
emptyErase = EmptyErase.DISABLED,
textStyle = { drawConfig.titleStyle(fontFamily) },
selectionState = selectionState,
onSelectionLister = {}
onSelectionLister = {},
aiExplanation = ""
)
},
headerClick = headerClick,
Expand All @@ -222,7 +223,8 @@ private fun HeaderDrawerStepPreview() {
)
},
selectionState = MutableStateFlow(false),
onSelectionLister = {}
onSelectionLister = {},
aiExplanation = ""
)
},
headerClick = {},
Expand All @@ -247,7 +249,8 @@ private fun HeaderDrawerStepPreviewNoColor() {
)
},
selectionState = MutableStateFlow(false),
onSelectionLister = {}
onSelectionLister = {},
aiExplanation = ""
)
},
headerClick = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ private fun SwipeMessageDrawerPreview() {
TextDrawer(
selectionState = MutableStateFlow(false),
onSelectionLister = {},
isDarkTheme = true
isDarkTheme = true,
aiExplanation = ""
)
},
).Step(
Expand Down
Loading