Skip to content

Commit 8597ce5

Browse files
committed
avoid jumping chat by some pixels when loading indicator disappears
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
1 parent 8340c53 commit 8597ce5

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import android.content.Intent
2323
import android.content.pm.PackageManager
2424
import android.content.res.AssetFileDescriptor
2525
import android.database.Cursor
26+
import android.graphics.drawable.ColorDrawable
2627
import android.graphics.drawable.Drawable
2728
import android.location.LocationManager
2829
import android.net.Uri
@@ -66,8 +67,11 @@ import androidx.cardview.widget.CardView
6667
import androidx.compose.foundation.gestures.scrollBy
6768
import androidx.compose.foundation.lazy.LazyListState
6869
import androidx.compose.foundation.lazy.rememberLazyListState
70+
import androidx.compose.foundation.background
71+
import androidx.compose.foundation.layout.Box
6972
import androidx.compose.foundation.layout.fillMaxWidth
70-
import androidx.compose.material3.HorizontalDivider
73+
import androidx.compose.foundation.layout.height
74+
import androidx.compose.ui.unit.dp
7175
import androidx.compose.material3.LinearProgressIndicator
7276
import androidx.compose.material3.MaterialTheme
7377
import androidx.compose.runtime.Composable
@@ -84,6 +88,7 @@ import androidx.compose.runtime.produceState
8488
import androidx.compose.runtime.remember
8589
import androidx.compose.runtime.rememberCoroutineScope
8690
import androidx.compose.runtime.setValue
91+
import androidx.compose.ui.graphics.Color
8792
import androidx.compose.ui.platform.ComposeView
8893
import androidx.coordinatorlayout.widget.CoordinatorLayout
8994
import androidx.core.content.ContextCompat
@@ -1816,16 +1821,24 @@ class ChatActivity :
18161821
supportActionBar?.setIcon(resources!!.getColor(R.color.transparent, null).toDrawable())
18171822
setActionBarTitle()
18181823
viewThemeUtils.material.themeToolbar(binding.chatToolbar)
1824+
val toolbarBackgroundColorInt = (binding.chatToolbar.background as? ColorDrawable)?.color
18191825
binding.searchLoadingIndicatorComposeView.setContent {
18201826
MaterialTheme(colorScheme = viewThemeUtils.getColorScheme(this@ChatActivity)) {
18211827
val isLoading by searchLoadingState
1822-
if (isLoading) {
1823-
LinearProgressIndicator(
1824-
modifier = Modifier.fillMaxWidth(),
1825-
color = MaterialTheme.colorScheme.primary
1826-
)
1827-
} else {
1828-
HorizontalDivider()
1828+
val appBarBackgroundColor = toolbarBackgroundColorInt?.let(::Color) ?: MaterialTheme.colorScheme.surface
1829+
Box(
1830+
modifier = Modifier
1831+
.fillMaxWidth()
1832+
.height(4.dp)
1833+
.background(appBarBackgroundColor)
1834+
) {
1835+
if (isLoading) {
1836+
LinearProgressIndicator(
1837+
modifier = Modifier.fillMaxWidth(),
1838+
color = MaterialTheme.colorScheme.primary,
1839+
trackColor = appBarBackgroundColor
1840+
)
1841+
}
18291842
}
18301843
}
18311844
}

0 commit comments

Comments
 (0)