parent
bd40bed949
commit
e0fb05e8d8
@ -0,0 +1,72 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
|
||||
@Composable
|
||||
fun HighlightedText(
|
||||
text: String,
|
||||
query: String,
|
||||
highlightStyle: SpanStyle,
|
||||
fontSize: TextUnit = TextUnit.Unspecified,
|
||||
fontStyle: FontStyle? = null,
|
||||
fontWeight: FontWeight? = null,
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = Color.Unspecified,
|
||||
textAlign: TextAlign? = null,
|
||||
style: TextStyle = LocalTextStyle.current
|
||||
) {
|
||||
Text(
|
||||
buildAnnotatedString {
|
||||
val startIndex = text.indexOf(query)
|
||||
val endIndex = startIndex + query.length
|
||||
if (startIndex != -1) {
|
||||
append(text.substring(0, startIndex))
|
||||
withStyle(highlightStyle) {
|
||||
append(text.substring(startIndex, endIndex))
|
||||
}
|
||||
append(text.substring(endIndex))
|
||||
} else {
|
||||
append(text)
|
||||
}
|
||||
},
|
||||
color = color,
|
||||
fontSize = fontSize,
|
||||
fontStyle = fontStyle,
|
||||
modifier = modifier,
|
||||
fontWeight = fontWeight,
|
||||
textAlign = textAlign,
|
||||
style = style
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun HighlightedTextPreview() {
|
||||
AllInTheme {
|
||||
HighlightedText(
|
||||
text = "Hello World !",
|
||||
query = "World",
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.Red
|
||||
),
|
||||
color = Color.White
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun StatBar(
|
||||
percentage: Float
|
||||
) {
|
||||
val radius100percent = if(percentage==1f) 50 else 0
|
||||
val radius0percent = if(percentage==0f) 50 else 0
|
||||
Box(
|
||||
Modifier.padding(horizontal = 9.dp)
|
||||
){
|
||||
Row(
|
||||
Modifier.align(Alignment.Center)
|
||||
){
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(20.dp)
|
||||
.fillMaxWidth(percentage)
|
||||
.clip(
|
||||
AbsoluteRoundedCornerShape(
|
||||
topLeftPercent = 50,
|
||||
bottomLeftPercent = 50,
|
||||
topRightPercent = radius100percent,
|
||||
bottomRightPercent = radius100percent
|
||||
)
|
||||
)
|
||||
.background(AllInTheme.colors.allIn_Bar1stGradient)
|
||||
|
||||
){
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterStart)
|
||||
.padding(start = 15.dp),
|
||||
text = "OUI",
|
||||
style = AllInTheme.typography.h2,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 25.sp,
|
||||
color = Color.White.copy(alpha = 0.3f),
|
||||
)
|
||||
}
|
||||
if(percentage!=0f && percentage!=1f) {
|
||||
Spacer(modifier = Modifier.width(15.dp))
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(20.dp)
|
||||
.fillMaxWidth()
|
||||
.clip(
|
||||
AbsoluteRoundedCornerShape(
|
||||
topLeftPercent = radius0percent,
|
||||
bottomLeftPercent = radius0percent,
|
||||
topRightPercent = 50,
|
||||
bottomRightPercent = 50
|
||||
)
|
||||
)
|
||||
.background(AllInTheme.colors.allIn_Bar2ndGradient)
|
||||
)
|
||||
}
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.align(Alignment.Center)
|
||||
) {
|
||||
when (percentage) {
|
||||
0f -> {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.fire_solid),
|
||||
tint = AllInTheme.colors.allIn_BarPink,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
)
|
||||
}
|
||||
1f -> {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.fire_solid),
|
||||
tint = AllInTheme.colors.allIn_BarPurple,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.size(32.dp)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
Row {
|
||||
Spacer(modifier = Modifier.fillMaxWidth(percentage))
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.bar_flame),
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.offset(x = (-9).dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun StatBar0Preview() {
|
||||
AllInTheme {
|
||||
StatBar(percentage = 0f)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun StatBar33Preview() {
|
||||
AllInTheme {
|
||||
StatBar(percentage = 0.33f)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun StatBar50Preview() {
|
||||
AllInTheme {
|
||||
StatBar(percentage = 0.5f)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun StatBar66Preview() {
|
||||
AllInTheme {
|
||||
StatBar(percentage = 0.66f)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun StatBar100Preview() {
|
||||
AllInTheme {
|
||||
StatBar(percentage = 1f)
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="448dp"
|
||||
android:height="512dp"
|
||||
android:viewportWidth="448"
|
||||
android:viewportHeight="512">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M159.3,5.4c7.8,-7.3 19.9,-7.2 27.7,0.1c27.6,25.9 53.5,53.8 77.7,84c11,-14.4 23.5,-30.1 37,-42.9c7.9,-7.4 20.1,-7.4 28,0.1c34.6,33 63.9,76.6 84.5,118c20.3,40.8 33.8,82.5 33.8,111.9C448,404.2 348.2,512 224,512C98.4,512 0,404.1 0,276.5c0,-38.4 17.8,-85.3 45.4,-131.7C73.3,97.7 112.7,48.6 159.3,5.4zM225.7,416c25.3,0 47.7,-7 68.8,-21c42.1,-29.4 53.4,-88.2 28.1,-134.4c-4.5,-9 -16,-9.6 -22.5,-2l-25.2,29.3c-6.6,7.6 -18.5,7.4 -24.7,-0.5c-16.5,-21 -46,-58.5 -62.8,-79.8c-6.3,-8 -18.3,-8.1 -24.7,-0.1c-33.8,42.5 -50.8,69.3 -50.8,99.4C112,375.4 162.6,416 225.7,416z"/>
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:type="linear"
|
||||
android:angle="45"
|
||||
android:startColor="#fff951a8"
|
||||
android:centerColor="#ffaa7ef3"
|
||||
android:endColor="#ff199fee" />
|
||||
</shape>
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!--Drawer-->
|
||||
<string name="bets">Bets</string>
|
||||
<string name="best_win">Meilleur gain</string>
|
||||
<string name="friends">Amis</string>
|
||||
<string name="create_a_bet">Créer un bet</string>
|
||||
<string name="create_a_bet_subtitle">Créez un nouveau bet et faites participer vos amis.</string>
|
||||
<string name="bet_history">Historique des bets</string>
|
||||
<string name="bet_history_subtitle">Consultez vos paris en cours et terminés.</string>
|
||||
<string name="friends_subtitle">Défiez vos porches en les ajoutant en amis.</string>
|
||||
<string name="current_bets">Bets en cours</string>
|
||||
<string name="current_bets_subtitle">Gérez vos bets et récompensez les gagnants.</string>
|
||||
<!--Main Page-->
|
||||
<string name="Popular">Populaire</string>
|
||||
<string name="Public">Public</string>
|
||||
<string name="Invitation">Invitation</string>
|
||||
<string name="Current">En cours</string>
|
||||
<string name="Finished">Terminés</string>
|
||||
<string name="Starting">Commence le</string>
|
||||
<string name="Participate">Participer</string>
|
||||
<string name="Proposed_by_x">Proposé par %1$s</string>
|
||||
<plurals name="n_players_waiting">
|
||||
<item quantity="one">%d joueur en attente</item>
|
||||
<item quantity="other">%d joueurs en attente</item>
|
||||
<item quantity="many">%d joueurs en attente</item>
|
||||
</plurals>
|
||||
<plurals name="n_players">
|
||||
<item quantity="one">%d joueur</item>
|
||||
<item quantity="other">%d joueurs</item>
|
||||
<item quantity="many">%d joueurs</item>
|
||||
</plurals>
|
||||
<plurals name="n_points_at_stake">
|
||||
<item quantity="one">%s point en jeu</item>
|
||||
<item quantity="other">%s points en jeu</item>
|
||||
<item quantity="many">%s points en jeu</item>
|
||||
</plurals>
|
||||
</resources>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.Allin" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="android:windowSplashScreenBackground">@drawable/main_gradient</item>
|
||||
</style>
|
||||
</resources>
|
@ -1,3 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
</resources>
|
@ -1,3 +1,38 @@
|
||||
<resources>
|
||||
<string name="app_name">allin</string>
|
||||
<!--Core-->
|
||||
<string name="app_name" translatable="false">Allin</string>
|
||||
<string name="float_and_unit" translatable="false">%.2g%s</string>
|
||||
<string name="int_and_unit" translatable="false">%d%s</string>
|
||||
<!--Drawer-->
|
||||
<string name="bets">Bets</string>
|
||||
<string name="best_win">Best win</string>
|
||||
<string name="friends">Friends</string>
|
||||
<string name="create_a_bet">Create a bet</string>
|
||||
<string name="create_a_bet_subtitle">Create a net bet and get your friends participating.</string>
|
||||
<string name="bet_history">Bet history</string>
|
||||
<string name="bet_history_subtitle">View your current and finished bets.</string>
|
||||
<string name="friends_subtitle">Challenge your folks by adding them as friends.</string>
|
||||
<string name="current_bets">Current bets</string>
|
||||
<string name="current_bets_subtitle">Manage your bets and reward the winners.</string>
|
||||
<!--Main Page-->
|
||||
<string name="Popular">Popular</string>
|
||||
<string name="Public">Public</string>
|
||||
<string name="Invitation">Invitation</string>
|
||||
<string name="Current">Current</string>
|
||||
<string name="Finished">Finished</string>
|
||||
<string name="Starting">Starting</string>
|
||||
<string name="Participate">Participate</string>
|
||||
<string name="Proposed_by_x">Proposed by %1$s</string>
|
||||
<plurals name="n_players_waiting">
|
||||
<item quantity="one">%d player waiting</item>
|
||||
<item quantity="other">%d players waiting</item>
|
||||
</plurals>
|
||||
<plurals name="n_players">
|
||||
<item quantity="one">%d player</item>
|
||||
<item quantity="other">%d players</item>
|
||||
</plurals>
|
||||
<plurals name="n_points_at_stake">
|
||||
<item quantity="one">%s point at stake</item>
|
||||
<item quantity="other">%s points at stake</item>
|
||||
</plurals>
|
||||
</resources>
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.Allin" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
<style name="Theme.Allin" parent="android:Theme.Material.Light.NoActionBar"/>
|
||||
</resources>
|
Loading…
Reference in new issue