-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from Tiebe/messages
Messages
- Loading branch information
Showing
29 changed files
with
2,383 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
...e/otarium/logic/root/home/children/messages/children/composing/MessageComposeComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
package nl.tiebe.otarium.logic.root.home.children.messages.children.composing | ||
|
||
import com.arkivanov.decompose.value.MutableValue | ||
import com.arkivanov.decompose.value.Value | ||
import dev.tiebe.magisterapi.response.profileinfo.Contact | ||
import nl.tiebe.otarium.logic.root.home.children.messages.MessagesComponent | ||
import nl.tiebe.otarium.ui.utils.ContactChip | ||
import nl.tiebe.otarium.ui.utils.chips.ChipTextFieldState | ||
|
||
interface MessageComposeComponent { | ||
val parentComponent: MessagesComponent | ||
|
||
val contactList: Value<List<Contact>> | ||
|
||
val toList: Value<List<String>> | ||
val ccList: Value<List<String>> | ||
val bccList: Value<List<String>> | ||
val toList: ChipTextFieldState<ContactChip> | ||
val ccList: ChipTextFieldState<ContactChip> | ||
val bccList: ChipTextFieldState<ContactChip> | ||
|
||
val subject: Value<String> | ||
val body: Value<String> | ||
val subject: MutableValue<String> | ||
val body: MutableValue<String> | ||
|
||
fun back() = parentComponent::back | ||
|
||
fun send() | ||
suspend fun send() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 52 additions & 21 deletions
73
...src/commonMain/kotlin/nl/tiebe/otarium/ui/home/messages/composing/MessageComposeScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,92 @@ | ||
package nl.tiebe.otarium.ui.home.messages.composing | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material3.OutlinedTextField | ||
import androidx.compose.material3.Text | ||
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.ChipTextFieldState | ||
|
||
@Composable | ||
fun MessageComposeScreen(component: MessageComposeComponent) { | ||
Column(Modifier.fillMaxSize()) { | ||
ToInputField(component) | ||
Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState())) { | ||
ToInputField(component, component.toList, "To") | ||
ToInputField(component, component.ccList, "CC") | ||
ToInputField(component, component.bccList, "BCC") | ||
|
||
SubjectInputField(component) | ||
|
||
/* CcInputField(component) | ||
BccInputField(component) | ||
BodyInputField(component) | ||
SendButton(component)*/ | ||
BodyInputField(component) | ||
} | ||
} | ||
|
||
|
||
@Composable | ||
fun ToInputField(component: MessageComposeComponent) { | ||
var toText by remember { mutableStateOf("") } | ||
|
||
Box(Modifier.padding(start= 16.dp, end = 16.dp, top = 24.dp)) { | ||
fun ToInputField(component: MessageComposeComponent, state: ChipTextFieldState<ContactChip>, label: String) { | ||
Box(Modifier.padding(start= 16.dp, end = 16.dp)) { | ||
var query by remember { mutableStateOf("") } | ||
|
||
AutoCompleteTextView( | ||
query = query, | ||
onQueryChanged = { query = it }, | ||
predictions = component.contactList.subscribeAsState().value.map { it }, //todo | ||
queryLabel = "Test" | ||
predictions = component.contactList.subscribeAsState().value.filter { contact -> | ||
if (query.isEmpty() || state.chips.any { it.contact == contact }) return@filter false | ||
getName(contact).contains(query, ignoreCase = true) | ||
}.sortedBy { getName(it) }, | ||
queryLabel = label, | ||
itemContent = { Text(getName(it)) }, | ||
onItemClick = { clickedItem -> | ||
if (state.chips.any { it.contact == clickedItem }) return@AutoCompleteTextView | ||
state.addChip(ContactChip(clickedItem)) | ||
query = "" | ||
}, | ||
state = state | ||
) | ||
} | ||
|
||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
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 | ||
} | ||
|
||
@Composable | ||
fun SubjectInputField(component: MessageComposeComponent) { | ||
var subjectText by remember { mutableStateOf("") } | ||
|
||
Box(Modifier.padding(start= 16.dp, end = 16.dp, top = 24.dp)) { | ||
Box(Modifier.padding(start = 16.dp, end = 16.dp)) { | ||
OutlinedTextField( | ||
value = subjectText, | ||
onValueChange = { subjectText = it }, | ||
value = component.subject.subscribeAsState().value, | ||
onValueChange = { component.subject.value = it }, | ||
modifier = Modifier.fillMaxWidth(), | ||
label = { Text("Subject") }, | ||
singleLine = true, | ||
|
||
singleLine = true | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun BodyInputField(component: MessageComposeComponent) { | ||
Box(Modifier.padding(start = 16.dp, end = 16.dp)) { | ||
OutlinedTextField( | ||
value = component.body.subscribeAsState().value, | ||
onValueChange = { component.body.value = it }, | ||
modifier = Modifier.fillMaxWidth(), | ||
label = { Text("Body") }, | ||
singleLine = false, | ||
) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.