Skip to content

Commit

Permalink
Quick commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiebe committed Apr 14, 2024
1 parent f931637 commit 2ad5da3
Show file tree
Hide file tree
Showing 13 changed files with 2,002 additions and 52 deletions.
2 changes: 1 addition & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ android {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

}

@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
Expand Down Expand Up @@ -78,7 +79,6 @@ kotlin {
implementation(libs.color.math)

implementation(libs.skiko)

}
}
androidMain {
Expand Down
2 changes: 1 addition & 1 deletion shared/shared.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'shared'
spec.version = '4.1.0'
spec.version = '4.1.1'
spec.homepage = 'https://otarium.groosman.nl'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
import dev.tiebe.magisterapi.response.profileinfo.Contact
import nl.tiebe.otarium.logic.root.home.children.messages.children.composing.MessageComposeComponent
import nl.tiebe.otarium.ui.utils.AutoCompleteTextView
import nl.tiebe.otarium.ui.utils.ContactChip
import nl.tiebe.otarium.ui.utils.chips.rememberChipTextFieldState

@Composable
fun MessageComposeScreen(component: MessageComposeComponent) {
Expand All @@ -27,21 +30,39 @@ fun MessageComposeScreen(component: MessageComposeComponent) {

@Composable
fun ToInputField(component: MessageComposeComponent) {
var toText by remember { mutableStateOf("") }

Box(Modifier.padding(start= 16.dp, end = 16.dp, top = 24.dp)) {
var query by remember { mutableStateOf("") }
val state = rememberChipTextFieldState(emptyList<ContactChip>())

AutoCompleteTextView(
query = query,
onQueryChanged = { query = it },
predictions = component.contactList.subscribeAsState().value.map { it }, //todo
queryLabel = "Test"
predictions = component.contactList.subscribeAsState().value.filter {
if (query.isEmpty()) return@filter true
getName(it).contains(query, ignoreCase = true)
},
queryLabel = "To",
itemContent = { Text(getName(it)) },
onItemClick = {
state.addChip(ContactChip(it))
query = ""
},
state = state
)
}

}

fun getName(contact: Contact): String {
var searchTerm =
"${contact.roepnaam ?: contact.voorletters} ${contact.tussenvoegsel?.plus(" ") ?: ""}${contact.achternaam}"
if (contact.klas != null) {
searchTerm += " (${contact.klas})"
}

return searchTerm
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SubjectInputField(component: MessageComposeComponent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import dev.tiebe.magisterapi.response.profileinfo.Contact
import nl.tiebe.otarium.ui.home.messages.composing.getName
import nl.tiebe.otarium.ui.utils.chips.Chip
import nl.tiebe.otarium.ui.utils.chips.ChipTextFieldState
import nl.tiebe.otarium.ui.utils.chips.OutlinedChipTextField

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -29,9 +29,9 @@ fun <T> AutoCompleteTextView(
onQueryChanged: (String) -> Unit = {},
predictions: List<T>,
onDoneActionClick: () -> Unit = {},
onClearClick: () -> Unit = {},
onItemClick: (T) -> Unit = {},
itemContent: @Composable (T) -> Unit = {}
itemContent: @Composable (T) -> Unit = {},
state: ChipTextFieldState<ContactChip>
) {
val lazyListState = rememberLazyListState()
LazyColumn(
Expand All @@ -47,13 +47,11 @@ fun <T> AutoCompleteTextView(
onDoneActionClick = {
onDoneActionClick()
},
onClearClick = {
onClearClick()
}
state = state
)
}

if (predictions.count() > 0) {
if (predictions.isNotEmpty()) {
items(predictions) { prediction ->
Row(
Modifier
Expand All @@ -70,6 +68,8 @@ fun <T> AutoCompleteTextView(
}
}

class ContactChip(public val contact: Contact) : Chip(getName(contact))


@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -78,41 +78,16 @@ fun QuerySearch(
query: String,
label: String,
onDoneActionClick: () -> Unit = {},
onClearClick: () -> Unit = {},
onQueryChanged: (String) -> Unit
onQueryChanged: (String) -> Unit,
state: ChipTextFieldState<ContactChip>
) {


var showClearButton by remember { mutableStateOf(false) }


OutlinedTextField(
OutlinedChipTextField(
state = state,
modifier = modifier
.fillMaxWidth()
.onFocusChanged { focusState ->
showClearButton = (focusState.isFocused)
},
.fillMaxWidth(),
value = query,
onValueChange = onQueryChanged,
onSubmit = { null },
label = { Text(text = label) },
textStyle = MaterialTheme.typography.labelSmall,
singleLine = true,
trailingIcon = {
if (showClearButton) {
IconButton(onClick = { onClearClick() }) {
Icon(imageVector = Icons.Filled.Close, contentDescription = "Clear")
}
}

},
keyboardActions = KeyboardActions(onDone = {
onDoneActionClick()
}),
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done,
keyboardType = KeyboardType.Text
)
)


}
Loading

0 comments on commit 2ad5da3

Please sign in to comment.