From 16c55a4105358d9487c53c5cc82fb7fe6ed33037 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Sat, 23 Aug 2025 02:36:36 +0200 Subject: [PATCH] Statusbar seamless (#289) * wip status bar * header fix --- .../java/com/bitchat/android/MainActivity.kt | 9 ++++ .../java/com/bitchat/android/ui/ChatScreen.kt | 47 +++++++++++-------- app/src/main/res/values-night/themes.xml | 16 +++++++ app/src/main/res/values/themes.xml | 11 ++++- 4 files changed, 62 insertions(+), 21 deletions(-) create mode 100644 app/src/main/res/values-night/themes.xml diff --git a/app/src/main/java/com/bitchat/android/MainActivity.kt b/app/src/main/java/com/bitchat/android/MainActivity.kt index c18e284b..df84b87d 100644 --- a/app/src/main/java/com/bitchat/android/MainActivity.kt +++ b/app/src/main/java/com/bitchat/android/MainActivity.kt @@ -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 diff --git a/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt b/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt index 1f121da0..76d6f17d 100644 --- a/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt +++ b/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt @@ -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 diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..c016b73b --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 8de638d1..0466e0f8 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -2,6 +2,15 @@