Skip to content

Commit

Permalink
Feature: Support channel, lecture and exercise mentioning (#14)
Browse files Browse the repository at this point in the history
* Support exercise and lecture mentioning.

* Support channel mentioning. Closes #9

* Filter exercise lecture and channel references by query. Update popup ui.
  • Loading branch information
TimOrtel authored Nov 27, 2023
1 parent 396be49 commit e84664a
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ val conversationModule = module {
get(),
get(),
get(),
get(),
get()
)
}
Expand All @@ -60,6 +61,7 @@ val conversationModule = module {
get(),
get(),
get(),
get(),
get()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.paging.insertSeparators
import androidx.paging.map
import de.tum.informatics.www1.artemis.native_app.core.common.flatMapLatest
import de.tum.informatics.www1.artemis.native_app.core.data.service.network.AccountDataService
import de.tum.informatics.www1.artemis.native_app.core.data.service.network.CourseService
import de.tum.informatics.www1.artemis.native_app.core.datastore.AccountService
import de.tum.informatics.www1.artemis.native_app.core.datastore.ServerConfigurationService
import de.tum.informatics.www1.artemis.native_app.core.datastore.authToken
Expand Down Expand Up @@ -68,6 +69,7 @@ internal class MetisListViewModel(
networkStatusProvider: NetworkStatusProvider,
conversationService: ConversationService,
replyTextStorageService: ReplyTextStorageService,
courseService: CourseService,
private val coroutineContext: CoroutineContext = EmptyCoroutineContext
) : MetisContentViewModel(
initialMetisContext,
Expand All @@ -80,6 +82,7 @@ internal class MetisListViewModel(
networkStatusProvider,
conversationService,
replyTextStorageService,
courseService,
coroutineContext
) {
private val _filter = MutableStateFlow<List<MetisFilter>>(emptyList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
Expand All @@ -16,6 +18,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand All @@ -42,7 +45,9 @@ internal fun ReplyAutoCompletePopup(
onDismissRequest = onDismissRequest
) {
ReplyAutoCompletePopupBody(
modifier = Modifier.heightIn(max = maxHeight).width(targetWidth),
modifier = Modifier
.heightIn(max = maxHeight)
.width(targetWidth),
autoCompleteCategories = autoCompleteCategories,
performAutoComplete = performAutoComplete
)
Expand All @@ -63,7 +68,7 @@ private fun ReplyAutoCompletePopupBody(
)
.padding(top = 8.dp)
) {
autoCompleteCategories.forEach { category ->
autoCompleteCategories.forEachIndexed { categoryIndex, category ->
item {
AutoCompleteCategoryComposable(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -84,6 +89,16 @@ private fun ReplyAutoCompletePopupBody(
item { Divider() }
}
}

if (categoryIndex != autoCompleteCategories.lastIndex) {
item {
Column {
Divider()

Box(modifier = Modifier.height(8.dp))
}
}
}
}
}
}
Expand All @@ -96,7 +111,8 @@ private fun AutoCompleteCategoryComposable(modifier: Modifier, name: String) {
.fillMaxWidth()
.padding(horizontal = HintHorizontalPadding),
text = name,
style = MaterialTheme.typography.titleSmall
style = MaterialTheme.typography.labelLarge,
textAlign = TextAlign.Center
)
}
}
Expand Down Expand Up @@ -125,11 +141,31 @@ private fun ReplyAutoCompletePopupBodyPreview() {
autoCompleteCategories = listOf(
AutoCompleteCategory(
name = R.string.markdown_textfield_autocomplete_category_users,
items = (0 until 10).map {
items = (0 until 1).map {
AutoCompleteHint(
hint = "Hint $it",
replacementText = "",
id = it.toString() + "a"
)
}
),
AutoCompleteCategory(
name = R.string.markdown_textfield_autocomplete_category_users,
items = (0 until 1).map {
AutoCompleteHint(
hint = "Hint $it",
replacementText = "",
id = it.toString() + "b"
)
}
),
AutoCompleteCategory(
name = R.string.markdown_textfield_autocomplete_category_users,
items = (0 until 1).map {
AutoCompleteHint(
hint = "Hint $it",
replacementText = "",
id = it.toString()
id = it.toString() + "c"
)
}
)
Expand Down
Loading

0 comments on commit e84664a

Please sign in to comment.