-
Notifications
You must be signed in to change notification settings - Fork 107
[CLX-3200][Horizon] ModuleItemSequence screen notebook changes #3369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
a59d968
b5a4e0f
b5b47e2
39be5d9
0e9f426
bbcf04d
e31b63c
0111ede
c6254fd
1aca263
fb02ec0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api | |
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.material3.SnackbarHost | ||
| import androidx.compose.material3.SnackbarHostState | ||
| import androidx.compose.material3.SnackbarResult | ||
| import androidx.compose.material3.Surface | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
|
|
@@ -101,7 +100,7 @@ import com.instructure.horizon.features.moduleitemsequence.content.lti.ExternalT | |
| import com.instructure.horizon.features.moduleitemsequence.content.page.PageDetailsContentScreen | ||
| import com.instructure.horizon.features.moduleitemsequence.content.page.PageDetailsViewModel | ||
| import com.instructure.horizon.features.moduleitemsequence.progress.ProgressScreen | ||
| import com.instructure.horizon.features.notebook.NotebookBottomDialog | ||
| import com.instructure.horizon.features.notebook.navigation.NotebookRoute | ||
| import com.instructure.horizon.horizonui.foundation.HorizonColors | ||
| import com.instructure.horizon.horizonui.foundation.HorizonCornerRadius | ||
| import com.instructure.horizon.horizonui.foundation.HorizonElevation | ||
|
|
@@ -122,14 +121,12 @@ import com.instructure.horizon.horizonui.molecules.PillType | |
| import com.instructure.horizon.horizonui.molecules.Spinner | ||
| import com.instructure.horizon.horizonui.molecules.SpinnerSize | ||
| import com.instructure.horizon.horizonui.platform.LoadingStateWrapper | ||
| import com.instructure.horizon.navigation.MainNavigationRoute | ||
| import com.instructure.pandautils.compose.modifiers.conditional | ||
| import com.instructure.pandautils.utils.Const | ||
| import com.instructure.pandautils.utils.ThemePrefs | ||
| import com.instructure.pandautils.utils.ViewStyler | ||
| import com.instructure.pandautils.utils.getActivityOrNull | ||
| import com.instructure.pandautils.utils.orDefault | ||
| import kotlinx.coroutines.launch | ||
| import kotlin.math.abs | ||
|
|
||
| @Composable | ||
|
|
@@ -153,7 +150,15 @@ fun ModuleItemSequenceScreen(mainNavController: NavHostController, uiState: Modu | |
| onPreviousClick = uiState.onPreviousClick, | ||
| onAssignmentToolsClick = uiState.onAssignmentToolsClick, | ||
| onAiAssistClick = { uiState.updateShowAiAssist(true) }, | ||
| onNotebookClick = { uiState.updateShowNotebook(true) }, | ||
| onNotebookClick = { | ||
| mainNavController.navigate( | ||
| NotebookRoute.Notebook.route( | ||
| uiState.courseId.toString(), | ||
| uiState.objectTypeAndId.first, | ||
| uiState.objectTypeAndId.second | ||
| ) | ||
| ) | ||
|
Comment on lines
153
to
163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential issue: Missing validation before navigation Good refactoring to use navigation instead of a dialog! However, consider adding validation before navigating. The Consider adding a guard: onNotebookClick = {
if (uiState.courseId > 0 &&
uiState.objectTypeAndId.first.isNotEmpty() &&
uiState.objectTypeAndId.second.isNotEmpty()) {
mainNavController.navigate(
NotebookRoute.Notebook.route(
uiState.courseId.toString(),
uiState.objectTypeAndId.first,
uiState.objectTypeAndId.second
)
)
} else {
// Log error or show user feedback
}
}, |
||
| }, | ||
| notebookEnabled = uiState.notebookButtonEnabled, | ||
| aiAssistEnabled = uiState.aiAssistButtonEnabled, | ||
| hasUnreadComments = uiState.hasUnreadComments | ||
|
|
@@ -166,22 +171,6 @@ fun ModuleItemSequenceScreen(mainNavController: NavHostController, uiState: Modu | |
| onDismiss = { uiState.updateShowAiAssist(false) }, | ||
| ) | ||
| } | ||
| if (uiState.showNotebook) { | ||
| NotebookBottomDialog( | ||
| uiState.courseId, | ||
| uiState.objectTypeAndId, | ||
| { snackbarMessage, onDismiss -> | ||
| scope.launch { | ||
| if (snackbarMessage != null) { | ||
| val result = snackbarHostState.showSnackbar(snackbarMessage) | ||
| if (result == SnackbarResult.Dismissed) { | ||
| onDismiss() | ||
| } | ||
| } | ||
| } }, | ||
| { uiState.updateShowNotebook(false) } | ||
| ) | ||
| } | ||
| ModuleItemSequenceContent(uiState = uiState, mainNavController = mainNavController, onBackPressed = { | ||
| mainNavController.popBackStack() | ||
| }) | ||
|
|
@@ -646,7 +635,6 @@ private fun ModuleItemSequenceScreenPreview() { | |
| moduleItemContent = ModuleItemContent.Assignment(courseId = 1, assignmentId = 1L) | ||
| ), | ||
| updateShowAiAssist = {}, | ||
| updateShowNotebook = {}, | ||
| ) | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,10 +36,8 @@ data class ModuleItemSequenceUiState( | |
| val assignmentToolsOpened: () -> Unit = {}, | ||
| val showAiAssist: Boolean = false, | ||
| val aiAssistButtonEnabled: Boolean = false, | ||
| val showNotebook: Boolean = false, | ||
| val notebookButtonEnabled: Boolean = false, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good cleanup removing unused state properties. The removal of |
||
| val updateShowAiAssist: (Boolean) -> Unit, | ||
| val updateShowNotebook: (Boolean) -> Unit, | ||
| val objectTypeAndId: Pair<String, String> = Pair("", ""), | ||
| val updateObjectTypeAndId: (Pair<String, String>) -> Unit = {}, | ||
| val hasUnreadComments: Boolean = false, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,9 +30,6 @@ import androidx.compose.ui.draw.clip | |
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.navigation.NavHostController | ||
| import com.instructure.canvasapi2.managers.graphql.horizon.redwood.NoteHighlightedData | ||
| import com.instructure.canvasapi2.managers.graphql.horizon.redwood.NoteHighlightedDataRange | ||
| import com.instructure.canvasapi2.managers.graphql.horizon.redwood.NoteHighlightedDataTextPosition | ||
| import com.instructure.horizon.features.aiassistant.common.model.AiAssistContextSource | ||
| import com.instructure.horizon.features.notebook.common.webview.ComposeNotesHighlightingCanvasWebView | ||
| import com.instructure.horizon.features.notebook.common.webview.NotesCallback | ||
|
|
@@ -114,40 +111,21 @@ fun PageDetailsContentScreen( | |
| ) | ||
| }, | ||
| onNoteAdded = { selectedText, noteType, startContainer, startOffset, endContainer, endOffset, textSelectionStart, textSelectionEnd -> | ||
| if (noteType == null) { | ||
| mainNavController.navigate( | ||
| NotebookRoute.AddNotebook( | ||
| courseId = uiState.courseId.toString(), | ||
| objectType = "Page", | ||
| objectId = uiState.pageId.toString(), | ||
| highlightedTextStartOffset = startOffset, | ||
| highlightedTextEndOffset = endOffset, | ||
| highlightedTextStartContainer = startContainer, | ||
| highlightedTextEndContainer = endContainer, | ||
| highlightedText = selectedText, | ||
| textSelectionStart = textSelectionStart, | ||
| textSelectionEnd = textSelectionEnd, | ||
| noteType = noteType | ||
| ) | ||
| ) | ||
| } else { | ||
| uiState.addNote( | ||
| NoteHighlightedData( | ||
| selectedText = selectedText, | ||
| range = NoteHighlightedDataRange( | ||
| startOffset = startOffset, | ||
| endOffset = endOffset, | ||
| startContainer = startContainer, | ||
| endContainer = endContainer | ||
| ), | ||
| textPosition = NoteHighlightedDataTextPosition( | ||
| start = textSelectionStart, | ||
| end = textSelectionEnd | ||
| ) | ||
| ), | ||
| noteType | ||
| mainNavController.navigate( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic has been simplified by removing the conditional check for Question: What happened to the previous logic that handled quick note creation when This change forces users through an additional navigation step even when they've already selected a note type (Important/Confusing). Was this intentional? |
||
| NotebookRoute.AddNotebook( | ||
| courseId = uiState.courseId.toString(), | ||
| objectType = "Page", | ||
| objectId = uiState.pageId.toString(), | ||
| highlightedTextStartOffset = startOffset, | ||
| highlightedTextEndOffset = endOffset, | ||
| highlightedTextStartContainer = startContainer, | ||
| highlightedTextEndContainer = endContainer, | ||
| highlightedText = selectedText, | ||
| textSelectionStart = textSelectionStart, | ||
| textSelectionEnd = textSelectionEnd, | ||
| noteType = noteType | ||
| ) | ||
|
Comment on lines
113
to
127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Workflow change: Removal of quick-action note creation This refactoring removes the conditional logic that previously enabled two different note creation paths: Before:
After:
Impact: Question: Was this intentional? The quick-action workflow provided a streamlined experience for simple marking. If removed intentionally, consider:
|
||
| } | ||
| ) | ||
| } | ||
| ) | ||
| ) | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,7 +121,7 @@ fun ComposeNotesHighlightingCanvasWebView( | |
| ) | ||
| if (notes.none { intersects(it.highlightedText.textPosition.start to it.highlightedText.textPosition.end, selectedTextStart to selectedTextEnd) }){ | ||
| add( | ||
| ActionMenuItem(2, context.getString(R.string.notesActionMenuAddImportantNote)) { | ||
| ActionMenuItem(2, context.getString(R.string.notesActionMenuMarkImportantNote)) { | ||
| notesCallback.onNoteAdded( | ||
| selectedText, | ||
| NotebookType.Important.name, | ||
|
|
@@ -135,7 +135,7 @@ fun ComposeNotesHighlightingCanvasWebView( | |
| } | ||
| ) | ||
| add( | ||
| ActionMenuItem(3, context.getString(R.string.notesActionMenuAddConfusingNote)) { | ||
| ActionMenuItem(3, context.getString(R.string.notesActionMenuMarkConfusingNote)) { | ||
| notesCallback.onNoteAdded( | ||
| selectedText, | ||
| NotebookType.Confusing.name, | ||
|
|
@@ -148,20 +148,6 @@ fun ComposeNotesHighlightingCanvasWebView( | |
| ) | ||
| } | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the "Add note" option (ActionMenuItem with id=4) changes the user experience. Users can now only mark text as "Important" or "Confusing" without the ability to add a custom note with highlighted text. Question: Is this intentional? This seems like a significant feature removal. If users want to add a note with context but without marking it as important/confusing, they no longer have that option. |
||
| add( | ||
| ActionMenuItem(4, context.getString(R.string.notesActionMenuAddNote)) { | ||
| notesCallback.onNoteAdded( | ||
| selectedText, | ||
| null, | ||
| selectedTextRangeStartContainer, | ||
| selectedTextRangeStartOffset, | ||
| selectedTextRangeEndContainer, | ||
| selectedTextRangeEndOffset, | ||
| selectedTextStart, | ||
| selectedTextEnd | ||
| ) | ||
| } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This navigation change is cleaner than the previous bottom sheet approach. However, consider error handling if any of these values are invalid:
This prevents crashes if the route construction or navigation fails.