Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aesthetics improvements #424

Merged
merged 6 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jerboa.ui.components.common

import android.annotation.SuppressLint
import android.app.Activity
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
Expand All @@ -19,6 +20,7 @@ import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand All @@ -27,6 +29,7 @@ import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
Expand Down Expand Up @@ -87,6 +90,17 @@ fun BottomAppBarAll(
val totalUnreads = unreadCounts?.let { unreadCountTotal(it) }

if (showBottomNav == true) {
val window = (LocalContext.current as Activity).window
val colorScheme = MaterialTheme.colorScheme

DisposableEffect(Unit) {
window.navigationBarColor = colorScheme.surfaceColorAtElevation(3.dp).toArgb()

onDispose {
window.navigationBarColor = colorScheme.background.toArgb()
}
}

BottomAppBar {
NavigationBarItem(
icon = {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/jerboa/ui/components/login/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack
Expand All @@ -22,6 +23,7 @@ import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.jerboa.DEFAULT_LEMMY_INSTANCES
Expand Down Expand Up @@ -124,6 +126,7 @@ fun LoginForm(
trailingIcon = {
TrailingIcon(expanded = expanded)
},
keyboardOptions = KeyboardOptions(autoCorrect = false, keyboardType = KeyboardType.Uri),
)
ExposedDropdownMenu(
expanded = expanded,
Expand Down Expand Up @@ -158,6 +161,7 @@ fun LoginForm(
Button(
enabled = isValid && !loading,
onClick = { onClickLogin(form, instance) },
modifier = Modifier.padding(top = 10.dp),
) {
if (loading) {
CircularProgressIndicator()
Expand Down
22 changes: 15 additions & 7 deletions app/src/main/java/com/jerboa/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.unit.sp
Expand Down Expand Up @@ -75,14 +75,22 @@ fun JerboaTheme(

val view = LocalView.current

if (isSystemInDarkTheme()) {
SideEffect {
val window = (view.context as Activity).window
val insets = WindowCompat.getInsetsController(window, view)
insets.isAppearanceLightStatusBars = false
}
val window = (view.context as Activity).window
val insets = WindowCompat.getInsetsController(window, view)

val isLight = when (themeMode) {
ThemeMode.Black, ThemeMode.Dark -> false
ThemeMode.System, ThemeMode.SystemBlack -> !isSystemInDarkTheme()
else -> true
}

window.statusBarColor = colors.background.toArgb()
// The navigation bar color is also set on BottomAppBarAll
window.navigationBarColor = colors.background.toArgb()

insets.isAppearanceLightStatusBars = isLight
insets.isAppearanceLightNavigationBars = isLight

MaterialTheme(
colorScheme = colors,
typography = typography,
Expand Down