mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 06:55:42 +03:00
Refactor - use Icons
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
acbda6f887
commit
9526825da7
3 changed files with 47 additions and 64 deletions
|
@ -15,7 +15,6 @@ import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.Image
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
@ -34,6 +33,7 @@ import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.List
|
||||||
import androidx.compose.material.icons.filled.Search
|
import androidx.compose.material.icons.filled.Search
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
@ -81,9 +81,9 @@ class ContactsActivityCompose : BaseActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||||
contactsViewModel = ViewModelProvider(this, viewModelFactory)[ContactsViewModel::class.java]
|
contactsViewModel = ViewModelProvider(this, viewModelFactory)[ContactsViewModel::class.java]
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
val colorScheme = viewThemeUtils.getColorScheme(this)
|
val colorScheme = viewThemeUtils.getColorScheme(this)
|
||||||
|
val uiState = contactsViewModel.contactsViewState.collectAsState()
|
||||||
MaterialTheme(
|
MaterialTheme(
|
||||||
colorScheme = colorScheme
|
colorScheme = colorScheme
|
||||||
) {
|
) {
|
||||||
|
@ -97,7 +97,6 @@ class ContactsActivityCompose : BaseActivity() {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
content = {
|
content = {
|
||||||
val uiState = contactsViewModel.contactsViewState.collectAsState()
|
|
||||||
Column(Modifier.padding(it)) {
|
Column(Modifier.padding(it)) {
|
||||||
ConversationCreationOptions(context = context)
|
ConversationCreationOptions(context = context)
|
||||||
ContactsList(
|
ContactsList(
|
||||||
|
@ -242,8 +241,10 @@ fun ContactItemRow(contact: AutocompleteUser, contactsViewModel: ContactsViewMod
|
||||||
fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel) {
|
fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel) {
|
||||||
val searchQuery by contactsViewModel.searchQuery.collectAsState()
|
val searchQuery by contactsViewModel.searchQuery.collectAsState()
|
||||||
val searchState = contactsViewModel.searchState.collectAsState()
|
val searchState = contactsViewModel.searchState.collectAsState()
|
||||||
|
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text(text = title) },
|
title = { Text(text = title) },
|
||||||
|
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = {
|
IconButton(onClick = {
|
||||||
(context as? Activity)?.finish()
|
(context as? Activity)?.finish()
|
||||||
|
@ -278,14 +279,13 @@ fun ConversationCreationOptions(context: Context) {
|
||||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 8.dp),
|
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Image(
|
Icon(
|
||||||
|
painter = painterResource(id = R.drawable.baseline_chat_bubble_outline_24),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(40.dp)
|
.width(40.dp)
|
||||||
.height(40.dp)
|
.height(40.dp)
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
painter = painterResource(R.drawable.baseline_chat_bubble_outline_24),
|
contentDescription = null
|
||||||
contentDescription = stringResource(R.string.new_conversation_creation_icon)
|
|
||||||
// colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
|
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
@ -294,7 +294,6 @@ fun ConversationCreationOptions(context: Context) {
|
||||||
text = stringResource(R.string.nc_create_new_conversation),
|
text = stringResource(R.string.nc_create_new_conversation),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
fontSize = 16.sp
|
fontSize = 16.sp
|
||||||
// color = MaterialTheme.colorScheme.onSurface
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row(
|
Row(
|
||||||
|
@ -306,14 +305,13 @@ fun ConversationCreationOptions(context: Context) {
|
||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Image(
|
Icon(
|
||||||
|
Icons.AutoMirrored.Filled.List,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(40.dp)
|
.width(40.dp)
|
||||||
.height(40.dp)
|
.height(40.dp)
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
painter = painterResource(R.drawable.baseline_format_list_bulleted_24),
|
contentDescription = null
|
||||||
contentDescription = stringResource(R.string.join_open_conversations_icon)
|
|
||||||
// colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
|
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
|
@ -16,7 +16,6 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.Surface
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextField
|
import androidx.compose.material3.TextField
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -31,45 +30,36 @@ import com.nextcloud.talk.R
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewModel: ContactsViewModel) {
|
fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewModel: ContactsViewModel) {
|
||||||
Surface(
|
val keyboardController = LocalSoftwareKeyboardController.current
|
||||||
|
TextField(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(60.dp)
|
.height(60.dp),
|
||||||
|
value = text,
|
||||||
|
onValueChange = { onTextChange(it) },
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.nc_search)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
) {
|
textStyle = TextStyle(
|
||||||
val keyboardController = LocalSoftwareKeyboardController.current
|
fontSize = 16.sp
|
||||||
TextField(
|
),
|
||||||
modifier = Modifier
|
singleLine = true,
|
||||||
.fillMaxWidth(),
|
leadingIcon = {
|
||||||
// .background(MaterialTheme.colorScheme.surface),
|
IconButton(
|
||||||
value = text,
|
onClick = {
|
||||||
onValueChange = { onTextChange(it) },
|
onTextChange("")
|
||||||
placeholder = {
|
contactsViewModel.updateSearchState(false)
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.nc_search)
|
|
||||||
// color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
textStyle = TextStyle(
|
|
||||||
// color = MaterialTheme.colorScheme.onSurface,
|
|
||||||
fontSize = 16.sp
|
|
||||||
),
|
|
||||||
singleLine = true,
|
|
||||||
leadingIcon = {
|
|
||||||
IconButton(
|
|
||||||
onClick = {
|
|
||||||
onTextChange("")
|
|
||||||
contactsViewModel.updateSearchState(false)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.AutoMirrored.Default.ArrowBack,
|
|
||||||
contentDescription = stringResource(R.string.back_button)
|
|
||||||
// tint = MaterialTheme.colorScheme.onSurface
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.AutoMirrored.Default.ArrowBack,
|
||||||
|
contentDescription = stringResource(R.string.back_button)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
trailingIcon = {
|
trailingIcon = {
|
||||||
if (text.isNotEmpty()) {
|
if (text.isNotEmpty()) {
|
||||||
|
@ -91,19 +81,15 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
|
||||||
imeAction = ImeAction.Search
|
imeAction = ImeAction.Search
|
||||||
),
|
),
|
||||||
|
|
||||||
keyboardActions = KeyboardActions(
|
keyboardActions = KeyboardActions(
|
||||||
onSearch = {
|
onSearch = {
|
||||||
if (text.trim().isNotEmpty()) {
|
if (text.trim().isNotEmpty()) {
|
||||||
keyboardController?.hide()
|
keyboardController?.hide()
|
||||||
} else {
|
} else {
|
||||||
return@KeyboardActions
|
return@KeyboardActions
|
||||||
}
|
|
||||||
}
|
}
|
||||||
),
|
}
|
||||||
maxLines = 1
|
),
|
||||||
// colors = TextFieldDefaults.colors(
|
maxLines = 1
|
||||||
// cursorColor = Color.Blue
|
)
|
||||||
// )
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,4 @@
|
||||||
|
|
||||||
package com.nextcloud.talk.contacts.apiService
|
package com.nextcloud.talk.contacts.apiService
|
||||||
|
|
||||||
object FakeItem {
|
object FakeItem
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue