Skip to content

Commit

Permalink
Task: Update dependencies - Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
jarroyoesp committed Oct 10, 2023
1 parent c20e886 commit afac933
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ jobs:
# Allow tests to continue on other devices if they fail on one device.
fail-fast: false
matrix:
api-level: [24, 30]
api-level: [26, 30]
target: [google_apis]
arch: [x86_64]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
Expand Down Expand Up @@ -157,7 +156,7 @@ class MainActivity : AppCompatActivity() { // AppCompatActivity is needed to be
}
}

@OptIn(ExperimentalComposeUiApi::class, ExperimentalMaterialNavigationApi::class)
@OptIn(ExperimentalMaterialNavigationApi::class)
@Suppress("ReusedModifierInstance")
@Composable
fun ForlagoMainScreen(
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ android.experimental.enableSourceSetPathsMap=true
android.nonFinalResIds=true
android.nonTransitiveRClass=true
android.useAndroidX=true
kapt.include.compile.classpath=false

# Kotlin
kotlin.code.style=official
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
Expand All @@ -40,6 +39,7 @@ import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.PrimaryScrollableTabRow
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
Expand Down Expand Up @@ -73,7 +73,6 @@ import com.leinardi.forlago.library.ui.component.LocalSnackbarHostState
import com.leinardi.forlago.library.ui.component.MainNavigationBarItem
import com.leinardi.forlago.library.ui.component.PreviewFeature
import com.leinardi.forlago.library.ui.component.Scaffold
import com.leinardi.forlago.library.ui.component.ScrollableTabRow
import com.leinardi.forlago.library.ui.component.SettingsGroup
import com.leinardi.forlago.library.ui.component.SettingsMenuLink
import com.leinardi.forlago.library.ui.component.SettingsMenuSwitch
Expand Down Expand Up @@ -105,8 +104,7 @@ private fun DebugScreen(
modifier = modifier
.nestedScroll(scrollBehavior.nestedScrollConnection)
.padding(LocalMainScaffoldPadding.current.value)
.consumeWindowInsets(LocalMainScaffoldPadding.current.value)
.navigationBarsPadding(),
.consumeWindowInsets(LocalMainScaffoldPadding.current.value),
topBar = {
TopAppBar(
title = stringResource(R.string.debug_screen),
Expand Down Expand Up @@ -334,10 +332,10 @@ private fun Features(
Column(
modifier = modifier,
) {
ScrollableTabRow(
PrimaryScrollableTabRow(
selectedTabIndex = pagerState.currentPage,
indicator = { tabPositions ->
TabRowDefaults.Indicator(
TabRowDefaults.PrimaryIndicator(
Modifier.tabIndicatorOffset(tabPositions[pagerState.currentPage]),
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

package com.leinardi.forlago.library.ui.component

import androidx.compose.animation.core.AnimationSpec
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.SwipeableDefaults
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
Expand All @@ -35,12 +33,10 @@ import com.google.accompanist.navigation.material.ExperimentalMaterialNavigation
@ExperimentalMaterialNavigationApi
@Composable
fun rememberBottomSheetNavigator(
animationSpec: AnimationSpec<Float> = SwipeableDefaults.AnimationSpec,
skipHalfExpanded: Boolean = false,
): BottomSheetNavigator {
val sheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
animationSpec = animationSpec,
skipHalfExpanded = skipHalfExpanded,
)
return remember(sheetState) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package com.leinardi.forlago.library.ui.component

import androidx.annotation.FloatRange
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.luminance

/**
* Default alpha levels used by Material components.
*
* See [LocalContentAlpha].
*/
@Suppress("TopLevelComposableFunctions", "MemberNameEqualsClassName")
object ContentAlpha {
/**
* A high level of content alpha, used to represent high emphasis text such as input text in a
* selected [TextField].
*/
val high: Float
@Composable
get() = contentAlpha(
highContrastAlpha = HighContrastContentAlpha.high,
lowContrastAlpha = LowContrastContentAlpha.high,
)

/**
* A medium level of content alpha, used to represent medium emphasis text such as
* placeholder text in a [TextField].
*/
val medium: Float
@Composable
get() = contentAlpha(
highContrastAlpha = HighContrastContentAlpha.medium,
lowContrastAlpha = LowContrastContentAlpha.medium,
)

/**
* A low level of content alpha used to represent disabled components, such as text in a
* disabled [Button].
*/
val disabled: Float
@Composable
get() = contentAlpha(
highContrastAlpha = HighContrastContentAlpha.disabled,
lowContrastAlpha = LowContrastContentAlpha.disabled,
)

/**
* This default implementation uses separate alpha levels depending on the luminance of the
* incoming color, and whether the theme is light or dark. This is to ensure correct contrast
* and accessibility on all surfaces.
*
* See [HighContrastContentAlpha] and [LowContrastContentAlpha] for what the levels are
* used for, and under what circumstances.
*/
@Composable
private fun contentAlpha(
@FloatRange(from = 0.0, to = 1.0)
highContrastAlpha: Float,
@FloatRange(from = 0.0, to = 1.0)
lowContrastAlpha: Float,
): Float {
val contentColor = LocalContentColor.current
val darkTheme = isSystemInDarkTheme()
return if (darkTheme) {
if (contentColor.luminance() < 0.5) highContrastAlpha else lowContrastAlpha
} else {
if (contentColor.luminance() > 0.5) highContrastAlpha else lowContrastAlpha
}
}
}

/**
* CompositionLocal containing the preferred content alpha for a given position in the hierarchy.
* This alpha is used for text and iconography ([Text] and [Icon]) to emphasize / de-emphasize
* different parts of a component. See the Material guide on
* [Text Legibility](https://material.io/design/color/text-legibility.html) for more information on
* alpha levels used by text and iconography.
*
* See [ContentAlpha] for the default levels used by most Material components.
*
* [MaterialTheme] sets this to [ContentAlpha.high] by default, as this is the default alpha for
* body text.
*
* @sample androidx.compose.material.samples.ContentAlphaSample
*/
val LocalContentAlpha = compositionLocalOf { 1f }

/**
* Alpha levels for high luminance content in light theme, or low luminance content in dark theme.
*
* This content will typically be placed on colored surfaces, so it is important that the
* contrast here is higher to meet accessibility standards, and increase legibility.
*
* These levels are typically used for text / iconography in primary colored tabs /
* bottom navigation / etc.
*/
private object HighContrastContentAlpha {
const val high: Float = 1.00f
const val medium: Float = 0.74f
const val disabled: Float = 0.38f
}

/**
* Alpha levels for low luminance content in light theme, or high luminance content in dark theme.
*
* This content will typically be placed on grayscale surfaces, so the contrast here can be lower
* without sacrificing accessibility and legibility.
*
* These levels are typically used for body text on the main surface (white in light theme, grey
* in dark theme) and text / iconography in surface colored tabs / bottom navigation / etc.
*/
private object LowContrastContentAlpha {
const val high: Float = 0.87f
const val medium: Float = 0.60f
const val disabled: Float = 0.38f
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material.ContentAlpha
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -74,11 +72,10 @@ fun SettingsMenuLink(
}
SettingsTileTexts(title = title, subtitle = subtitle)
if (action != null) {
Divider(
VerticalDivider(
modifier = Modifier
.padding(vertical = Spacing.half)
.height(56.dp)
.width(1.dp),
.height(56.dp),
)
SettingsTileAction {
action.invoke()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.selection.toggleable
import androidx.compose.material.ContentAlpha
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package com.leinardi.forlago.library.ui.component
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.material.ContentAlpha
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.icons.filled.Share
Expand Down Expand Up @@ -82,7 +82,7 @@ fun TopAppBar(
imageVector = if (contextual) {
Icons.Default.Clear
} else {
Icons.Default.ArrowBack
Icons.AutoMirrored.Default.ArrowBack
},
contentDescription = null,
)
Expand Down

0 comments on commit afac933

Please sign in to comment.