Provide AllIn logo from Theme + Fix nested scrolls

pull/5/head
avalin 10 months ago
parent 78b4ab2e05
commit 45883c2008

@ -10,10 +10,12 @@ import androidx.compose.ui.graphics.painter.Painter
@Immutable
data class AllInIcons(
val allCoins: @Composable () -> Painter,
val logo: @Composable () -> Painter
)
internal val LocalIcons = staticCompositionLocalOf {
AllInIcons(
allCoins = { ColorPainter(Color.Unspecified) }
allCoins = { ColorPainter(Color.Unspecified) },
logo = { ColorPainter(Color.Unspecified) }
)
}

@ -148,7 +148,8 @@ fun AllInTheme(
}
val customIcons = AllInIcons(
allCoins = { painterResource(id = R.drawable.allcoin) }
allCoins = { painterResource(id = R.drawable.allcoin) },
logo = { painterResource(id = R.drawable.allin) }
)
CompositionLocalProvider(

@ -32,7 +32,6 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
@ -154,7 +153,6 @@ fun ConfirmationAnswers(
label = ""
)
BetConfirmationBottomSheetAnswer(
text = it.response,
odds = it.odds,
@ -213,8 +211,7 @@ fun ConfirmationAnswers(
label = ""
)
val scale by animateFloatAsState(
targetValue = if (selectedAnswer == null) 1f
else if (selectedAnswer != it.response) .95f else 1.05f,
targetValue = if (selectedAnswer != null && selectedAnswer != it.response) .95f else 1f,
label = ""
)
@ -237,8 +234,7 @@ fun ConfirmationAnswers(
label = ""
)
val scale by animateFloatAsState(
targetValue = if (selectedAnswer == null) 1f
else if (selectedAnswer != it.response) .95f else 1f,
targetValue = if (selectedAnswer != null && selectedAnswer != it.response) .95f else 1f,
label = ""
)
@ -290,7 +286,7 @@ fun BetConfirmationBottomSheetContent(
}
Icon(
painter = painterResource(R.drawable.allin),
painter = AllInTheme.icons.logo(),
contentDescription = null,
tint = AllInTheme.colors.white,
modifier = Modifier

@ -19,6 +19,10 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
@ -96,7 +100,15 @@ fun QuestionTabPrivacySection(
setIsOpen = { isOpen = it }
) {
LazyColumn(
modifier = Modifier.height(440.dp)
modifier = Modifier
.height(440.dp)
.nestedScroll(object : NestedScrollConnection {
override fun onPostScroll(
consumed: Offset,
available: Offset,
source: NestedScrollSource
) = available.copy(x = 0f)
})
) {
itemsIndexed(friends, key = { _, it -> it.id }) { idx, it ->
var isSelected by remember {

@ -15,10 +15,8 @@ import androidx.compose.material3.SheetState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import fr.iut.alldev.allin.R
import fr.iut.alldev.allin.data.ext.formatToMediumDateNoYear
import fr.iut.alldev.allin.data.ext.formatToTime
import fr.iut.alldev.allin.data.model.bet.Bet
@ -94,7 +92,7 @@ fun BetResultBottomSheetContent(
}
Icon(
painter = painterResource(R.drawable.allin),
painter = AllInTheme.icons.logo(),
contentDescription = null,
tint = AllInTheme.colors.white,
modifier = Modifier

@ -2,8 +2,19 @@ package fr.iut.alldev.allin.ui.betStatus.components
import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.SheetState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@ -12,7 +23,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import fr.iut.alldev.allin.R
@ -125,6 +135,10 @@ private fun BetStatusParticipationBottomSheetContent(
AllInIntTextField(
value = stake,
setValue = setStake,
textStyle = AllInTheme.typography.h1.copy(
fontSize = 20.sp,
color = AllInTheme.themeColors.onBackground
),
placeholder = stringResource(id = R.string.bet_result_stake),
trailingIcon = AllInTheme.icons.allCoins(),
modifier = Modifier.fillMaxWidth(),

@ -28,9 +28,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
@ -125,7 +129,14 @@ class BetStatusBottomSheetBetDisplayer(
LazyColumn(
modifier = Modifier
.fillMaxHeight()
.background(AllInTheme.themeColors.background2),
.background(AllInTheme.themeColors.background2)
.nestedScroll(object : NestedScrollConnection {
override fun onPostScroll(
consumed: Offset,
available: Offset,
source: NestedScrollSource
) = available.copy(x = 0f)
}),
contentPadding = PaddingValues(horizontal = 20.dp)
) {
item {

@ -54,7 +54,6 @@ fun AllInChip(
textAlign = TextAlign.Center,
style = AllInTheme.typography.h1,
color = AllInTheme.colors.white
)
}
}

@ -14,7 +14,7 @@ fun AllInCoinCount(
modifier: Modifier = Modifier,
amount: Int,
color: Color? = null,
brush: Brush?= null,
brush: Brush? = null,
size: Int = 15,
textStyle: TextStyle = AllInTheme.typography.h1,
position: IconPosition = IconPosition.TRAILING

@ -21,7 +21,6 @@ import androidx.compose.ui.unit.sp
import fr.iut.alldev.allin.theme.AllInTheme
import racra.compose.smooth_corner_rect_library.AbsoluteSmoothCornerShape
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AllInIconChip(
text: String,

@ -13,6 +13,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.*
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
@ -28,12 +29,12 @@ import fr.iut.alldev.allin.theme.AllInTheme
import racra.compose.smooth_corner_rect_library.AbsoluteSmoothCornerShape
import java.util.Locale
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
@Composable
fun AllInTextField(
value: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = AllInTheme.typography.p1,
placeholder: String? = null,
value: String,
maxChar: Int? = null,
enabled: Boolean = true,
trailingIcon: Painter? = null,
@ -86,7 +87,7 @@ fun AllInTextField(
)
}
},
textStyle = AllInTheme.typography.p1,
textStyle = textStyle,
enabled = enabled,
keyboardOptions = KeyboardOptions(keyboardType = keyboardType, imeAction = imeAction),
keyboardActions = keyboardActions,
@ -145,8 +146,12 @@ fun AllInPasswordField(
@Composable
fun AllInFloatTextfield(
modifier: Modifier = Modifier,
value: Float?,
modifier: Modifier = Modifier,
textStyle: TextStyle = AllInTheme.typography.p1,
placeholder: String? = null,
trailingIcon: Painter? = null,
maxChar: Int? = 5,
setValue: (Float?) -> Unit
) {
val configuration = LocalConfiguration.current
@ -158,7 +163,10 @@ fun AllInFloatTextfield(
AllInTextField(
value = stringValue,
modifier = modifier,
maxChar = 5,
placeholder = placeholder,
maxChar = maxChar,
textStyle = textStyle,
trailingIcon = trailingIcon,
keyboardType = KeyboardType.Number
) {
it.verifyIsFloat(locale)?.let {
@ -176,11 +184,12 @@ fun AllInFloatTextfield(
@Composable
fun AllInIntTextField(
value: Int?,
modifier: Modifier = Modifier,
textStyle: TextStyle = AllInTheme.typography.p1,
placeholder: String? = null,
maxChar: Int? = 3,
value: Int?,
trailingIcon: Painter? = null,
maxChar: Int? = 3,
setValue: (Int?) -> Unit
) {
AllInTextField(
@ -189,6 +198,7 @@ fun AllInIntTextField(
modifier = modifier,
maxChar = maxChar,
trailingIcon = trailingIcon,
textStyle = textStyle,
keyboardType = KeyboardType.NumberPassword
) {
if (it.isEmpty()) setValue(null)

@ -48,7 +48,7 @@ fun AllInTopBar(
modifier = Modifier.fillMaxWidth()
) {
Icon(
painter = painterResource(R.drawable.allin),
painter = AllInTheme.icons.logo(),
contentDescription = null,
tint = AllInTheme.colors.white,
modifier = Modifier

@ -160,7 +160,6 @@ fun MainScreen(
}
events.firstOrNull()?.let {
it.Display(sheetState = eventBottomSheetState) {
mainViewModel.dismissedEvents += it

@ -6,9 +6,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import fr.iut.alldev.allin.R
import fr.iut.alldev.allin.theme.AllInTheme
import fr.iut.alldev.allin.ui.core.Icon
@ -21,7 +19,7 @@ fun SplashScreenContent() {
contentAlignment = Alignment.Center
) {
Icon(
painter = painterResource(R.drawable.allin),
painter = AllInTheme.icons.logo(),
contentDescription = null,
tint = AllInTheme.colors.white,
modifier = Modifier.fillMaxSize(.25f)

Loading…
Cancel
Save