Statusbar seamless (#289)

* wip status bar

* header fix
This commit is contained in:
callebtc
2025-08-23 02:36:36 +02:00
committed by GitHub
parent f13f3063c9
commit 16c55a4105
4 changed files with 62 additions and 21 deletions
@@ -1,12 +1,15 @@
package com.bitchat.android
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedCallback
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.core.view.WindowCompat
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
@@ -65,6 +68,12 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Enable edge-to-edge display for modern Android look
enableEdgeToEdge()
// Make status bar transparent and content can extend behind it
WindowCompat.setDecorFitsSystemWindows(window, false)
// Initialize permission management
permissionManager = PermissionManager(this)
// Initialize core mesh service first
@@ -70,18 +70,26 @@ fun ChatScreen(viewModel: ChatViewModel) {
}
// Use WindowInsets to handle keyboard properly
Box(modifier = Modifier.fillMaxSize()) {
Box(
modifier = Modifier
.fillMaxSize()
.background(colorScheme.background) // Extend background to fill entire screen including status bar
) {
val headerHeight = 42.dp
// Main content area that responds to keyboard/window insets
Column(
modifier = Modifier
.fillMaxSize()
.background(colorScheme.background)
.windowInsetsPadding(WindowInsets.ime) // This handles keyboard insets
.windowInsetsPadding(WindowInsets.navigationBars) // Add bottom padding when keyboard is not expanded
) {
// Header spacer - creates space for the floating header
Spacer(modifier = Modifier.height(headerHeight))
// Header spacer - creates exact space for the floating header (status bar + compact header)
Spacer(
modifier = Modifier
.windowInsetsPadding(WindowInsets.statusBars)
.height(headerHeight)
)
// Messages area - takes up available space, will compress when keyboard appears
MessagesList(
@@ -180,6 +188,16 @@ fun ChatScreen(viewModel: ChatViewModel) {
onLocationChannelsClick = { showLocationChannelsSheet = true }
)
// Divider under header - positioned after status bar + header height
HorizontalDivider(
modifier = Modifier
.fillMaxWidth()
.windowInsetsPadding(WindowInsets.statusBars)
.offset(y = headerHeight)
.zIndex(1f),
color = colorScheme.outline.copy(alpha = 0.3f)
)
val alpha by animateFloatAsState(
targetValue = if (showSidebar) 0.5f else 0f,
animationSpec = tween(
@@ -267,8 +285,7 @@ private fun ChatInputSection(
) {
Surface(
modifier = Modifier.fillMaxWidth(),
color = colorScheme.background,
shadowElevation = 8.dp
color = colorScheme.background
) {
Column {
HorizontalDivider(color = colorScheme.outline.copy(alpha = 0.3f))
@@ -324,11 +341,9 @@ private fun ChatFloatingHeader(
Surface(
modifier = Modifier
.fillMaxWidth()
.height(headerHeight)
.zIndex(1f)
.windowInsetsPadding(WindowInsets.statusBars), // Only respond to status bar
color = colorScheme.background.copy(alpha = 0.95f),
shadowElevation = 8.dp
.windowInsetsPadding(WindowInsets.statusBars), // Extend into status bar area
color = colorScheme.background // Solid background color extending into status bar
) {
TopAppBar(
title = {
@@ -351,18 +366,10 @@ private fun ChatFloatingHeader(
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = Color.Transparent
)
),
modifier = Modifier.height(headerHeight) // Ensure compact header height
)
}
// Divider under header
HorizontalDivider(
modifier = Modifier
.fillMaxWidth()
.offset(y = headerHeight)
.zIndex(1f),
color = colorScheme.outline.copy(alpha = 0.3f)
)
}
@Composable
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Dark theme -->
<style name="Theme.BitchatAndroid" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Enable edge-to-edge content -->
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">false</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
<!-- Ensure smooth transitions -->
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowContentTransitions">true</item>
</style>
</resources>
+10 -1
View File
@@ -2,6 +2,15 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme -->
<style name="Theme.BitchatAndroid" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<!-- Enable edge-to-edge content -->
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
<!-- Ensure smooth transitions -->
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowContentTransitions">true</item>
</style>
</resources>