Skip to content

Commit e783deb

Browse files
authored
Merge pull request #25 from Fandroid745/dev
Fix cursor color in AddEditNoteScreen and other minor improvements
2 parents 56a0eb7 + 241ca71 commit e783deb

5 files changed

Lines changed: 125 additions & 107 deletions

File tree

README.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,16 @@ Contributions are welcome! Your help in making OpenNotes better is appreciated.
3838
Please open an issue before submitting a pull request that adds a new feature, so it can be discussed first.
3939
All changes should be committed to the dev branch, not master.
4040

41-
## License
4241

43-
This project is licensed under the terms of the **GNU General Public License v3.0**.
42+
---
43+
44+
4445

45-
```text
46-
OpenNotes - A note-taking app
47-
Copyright (C) 2025 Open Notes
4846

49-
This program is free software: you can redistribute it and/or modify
50-
it under the terms of the GNU General Public License as published by
51-
the Free Software Foundation, either version 3 of the License, or
52-
(at your option) any later version.
47+
## Inspiration
48+
49+
- [EasyNotes](https://github.com/Kin69/EasyNotes?tab=readme-ov-file)
50+
51+
---
5352

54-
This program is distributed in the hope that it will be useful,
55-
but WITHOUT ANY WARRANTY; without even the implied warranty of
56-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57-
GNU General Public License for more details.
5853

59-
You should have received a copy of the GNU General Public License
60-
along with this program. If not, see <https://www.gnu.org/licenses/>.
61-
```

app/src/main/java/com/opennotes/feature_node/presentation/MainActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class MainActivity : FragmentActivity() {
148148
}
149149
}
150150
} else {
151-
// Blank surface shown until auth completes
152151
Surface(color = MaterialTheme.colorScheme.background) {}
153152
}
154153
}

app/src/main/java/com/opennotes/feature_node/presentation/add_edit_note/AddEditNoteScreen.kt

Lines changed: 114 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
2929
import androidx.compose.foundation.layout.*
3030
import androidx.compose.foundation.rememberScrollState
3131
import androidx.compose.foundation.shape.CircleShape
32+
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
33+
import androidx.compose.foundation.text.selection.TextSelectionColors
3234
import androidx.compose.foundation.verticalScroll
3335
import androidx.compose.material.icons.Icons
3436
import androidx.compose.material.icons.automirrored.filled.ArrowBack
@@ -135,7 +137,6 @@ fun AddEditNoteScreen(
135137
tint = contentColor
136138
)
137139
}
138-
139140
IconButton(onClick = { viewModel.onEvent(AddEditNoteEvent.SaveNote) }) {
140141
Icon(
141142
imageVector = Icons.Default.Done,
@@ -150,105 +151,129 @@ fun AddEditNoteScreen(
150151
)
151152
}
152153
) { paddingValues ->
153-
Column(
154-
modifier = Modifier
155-
.fillMaxSize()
156-
.background(backgroundColor)
157-
.padding(paddingValues)
158-
.imePadding()
159-
.padding(16.dp)
154+
CompositionLocalProvider(
155+
LocalContentColor provides contentColor,
156+
LocalTextSelectionColors provides TextSelectionColors(
157+
handleColor = contentColor,
158+
backgroundColor = contentColor.copy(alpha = 0.4f)
159+
)
160160
) {
161-
// Color picker
162-
Row(
161+
Column(
163162
modifier = Modifier
164-
.fillMaxWidth()
165-
.padding(vertical = 8.dp),
166-
horizontalArrangement = Arrangement.SpaceBetween
163+
.fillMaxSize()
164+
.background(backgroundColor)
165+
.padding(paddingValues)
166+
.imePadding()
167+
.padding(16.dp)
167168
) {
168-
noteColors.forEach { color ->
169-
val colorInt = remember(color) { color.toArgb() }
170-
Box(
171-
modifier = Modifier
172-
.size(50.dp)
173-
.shadow(15.dp, CircleShape)
174-
.clip(CircleShape)
175-
.background(color)
176-
.border(
177-
width = 3.dp,
178-
color = if (viewModel.noteColor.value == colorInt) Color.Black else Color.Transparent,
179-
shape = CircleShape
180-
)
181-
.clickable {
182-
scope.launch {
183-
noteBackgroundAnimatable.animateTo(
184-
targetValue = Color(colorInt),
185-
animationSpec = tween(durationMillis = 500)
186-
)
169+
170+
171+
// Color picker
172+
Row(
173+
modifier = Modifier
174+
.fillMaxWidth()
175+
.padding(vertical = 8.dp),
176+
horizontalArrangement = Arrangement.SpaceBetween
177+
) {
178+
noteColors.forEach { color ->
179+
val colorInt = remember(color) { color.toArgb() }
180+
Box(
181+
modifier = Modifier
182+
.size(50.dp)
183+
.shadow(15.dp, CircleShape)
184+
.clip(CircleShape)
185+
.background(color)
186+
.border(
187+
width = 3.dp,
188+
color = if (viewModel.noteColor.value == colorInt) Color.Black else Color.Transparent,
189+
shape = CircleShape
190+
)
191+
.clickable {
192+
scope.launch {
193+
noteBackgroundAnimatable.animateTo(
194+
targetValue = Color(colorInt),
195+
animationSpec = tween(durationMillis = 500)
196+
)
197+
}
198+
viewModel.onEvent(AddEditNoteEvent.changeColor(colorInt))
187199
}
188-
viewModel.onEvent(AddEditNoteEvent.changeColor(colorInt))
189-
}
190-
)
200+
)
201+
}
191202
}
192-
}
193203

194-
Spacer(modifier = Modifier.height(16.dp))
195204

196-
TransParentHintTextField(
197-
text = titleState.text,
198-
hint = titleState.hint,
199-
onValueChange = { viewModel.onEvent(AddEditNoteEvent.EnteredTitle(it)) },
200-
onFocusChange = { viewModel.onEvent(AddEditNoteEvent.changeTitleFocus(it)) },
201-
singleLine = true,
202-
textStyle = MaterialTheme.typography.headlineSmall.copy(color = contentColor),
203-
focusRequester = titleFocusRequester,
204-
modifier = Modifier.fillMaxWidth()
205-
)
206205

207-
Spacer(modifier = Modifier.height(16.dp))
206+
Spacer(modifier = Modifier.height(16.dp))
208207

209-
Box(
210-
modifier = Modifier
211-
.fillMaxWidth()
212-
.weight(1f)
213-
) {
214-
if (isPreviewMode) {
215-
MarkdownText(
216-
radius = 8,
217-
markdown = contentState.text.ifBlank { "No content to preview" },
218-
isPreview = false,
219-
isEnabled = true,
220-
modifier = Modifier
221-
.fillMaxSize()
222-
.padding(8.dp),
223-
onContentChange = {},
224-
settingsViewModel = null,
225-
textColor = contentColor
226-
)
227-
} else {
228-
val scrollState = rememberScrollState()
229-
Box(
230-
modifier = Modifier
231-
.fillMaxSize()
232-
.verticalScroll(scrollState)
233-
.clickable(
234-
interactionSource = interactionSource,
235-
indication = null
236-
) {
237-
contentFocusRequester.requestFocus()
238-
}
239-
) {
240-
TransParentHintTextField(
241-
text = contentState.text,
242-
hint = contentState.hint,
243-
onValueChange = { viewModel.onEvent(AddEditNoteEvent.EnteredContent(it)) },
244-
onFocusChange = { viewModel.onEvent(AddEditNoteEvent.changeContentFocus(it)) },
245-
textStyle = MaterialTheme.typography.bodyLarge.copy(color = contentColor),
246-
singleLine = false,
247-
focusRequester = contentFocusRequester,
208+
TransParentHintTextField(
209+
text = titleState.text,
210+
hint = titleState.hint,
211+
onValueChange = { viewModel.onEvent(AddEditNoteEvent.EnteredTitle(it)) },
212+
onFocusChange = { viewModel.onEvent(AddEditNoteEvent.changeTitleFocus(it)) },
213+
singleLine = true,
214+
textStyle = MaterialTheme.typography.headlineSmall.copy(color = contentColor),
215+
focusRequester = titleFocusRequester,
216+
modifier = Modifier.fillMaxWidth()
217+
)
218+
219+
Spacer(modifier = Modifier.height(16.dp))
220+
221+
Box(
222+
modifier = Modifier
223+
.fillMaxWidth()
224+
.weight(1f)
225+
) {
226+
if (isPreviewMode) {
227+
MarkdownText(
228+
radius = 8,
229+
markdown = contentState.text.ifBlank { "No content to preview" },
230+
isPreview = false,
231+
isEnabled = true,
248232
modifier = Modifier
249-
.fillMaxWidth()
250-
.wrapContentHeight(unbounded = true)
233+
.fillMaxSize()
234+
.padding(8.dp),
235+
onContentChange = {},
236+
settingsViewModel = null,
237+
textColor = contentColor
251238
)
239+
} else {
240+
val scrollState = rememberScrollState()
241+
Box(
242+
modifier = Modifier
243+
.fillMaxSize()
244+
.verticalScroll(scrollState)
245+
.clickable(
246+
interactionSource = interactionSource,
247+
indication = null
248+
) {
249+
contentFocusRequester.requestFocus()
250+
}
251+
) {
252+
TransParentHintTextField(
253+
text = contentState.text,
254+
hint = contentState.hint,
255+
onValueChange = {
256+
viewModel.onEvent(
257+
AddEditNoteEvent.EnteredContent(
258+
it
259+
)
260+
)
261+
},
262+
onFocusChange = {
263+
viewModel.onEvent(
264+
AddEditNoteEvent.changeContentFocus(
265+
it
266+
)
267+
)
268+
},
269+
textStyle = MaterialTheme.typography.bodyLarge.copy(color = contentColor),
270+
singleLine = false,
271+
focusRequester = contentFocusRequester,
272+
modifier = Modifier
273+
.fillMaxWidth()
274+
.wrapContentHeight(unbounded = true)
275+
)
276+
}
252277
}
253278
}
254279
}

app/src/main/java/com/opennotes/feature_node/presentation/add_edit_note/components/TransParentHintTextField.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import androidx.compose.ui.focus.FocusState
3333
import androidx.compose.ui.focus.focusRequester
3434
import androidx.compose.ui.focus.onFocusChanged
3535
import androidx.compose.ui.graphics.Color
36+
import androidx.compose.ui.graphics.SolidColor
3637
import androidx.compose.ui.text.TextStyle
3738
import androidx.compose.ui.unit.dp
3839

@@ -54,6 +55,7 @@ fun TransParentHintTextField(
5455
onValueChange = onValueChange,
5556
singleLine = singleLine,
5657
textStyle = textStyle,
58+
cursorBrush = SolidColor(textStyle.color),
5759
interactionSource = interactionSource,
5860
modifier = modifier
5961
.focusRequester(focusRequester)

app/src/main/java/com/opennotes/feature_node/presentation/notes/NotesScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fun NotesScreen(
6060
)
6161
},
6262
text = {
63-
Text("This action cannot be undone.")
63+
Text("Are you sure you want to delete this note?")
6464
},
6565
confirmButton = {
6666
TextButton(

0 commit comments

Comments
 (0)