Currently, you cannot visualize tactics when you click on them. There isn't the tactic's preview available because it's required the visualizer.
This pull request adds the home page.
Currently, you cannot visualize tactics when you click on them. There isn't the tactic's preview available because it's required the visualizer.
mael.daim
was assigned by yanis.dahmane-bounoua1 year ago
maxime.batista
was assigned by yanis.dahmane-bounoua1 year ago
samuel.berion
was assigned by yanis.dahmane-bounoua1 year ago
vivien.dufour
was assigned by yanis.dahmane-bounoua1 year ago
Prone use of the dark theme because it can use it if the phone's system theme is set in night mode.
Don't bother with a night mode for now and just force it to use the light theme.
Also remove the dynamicColor feature as it appears to change colors based on the user's system theme preferences
```diff
- + IQBallTheme {
+ IQBallTheme(darkTheme = false, dynamicColor = false) {
```
Prone use of the dark theme because it can use it if the phone's system theme is set in night mode.
Don't bother with a night mode for now and just force it to use the light theme.
Also remove the dynamicColor feature as it appears to change colors based on the user's system theme preferences
yanis.dahmane-bounoua marked this conversation as resolved
val tacticsTabTitle = "Espace personnel"
val teamsTabTitle = "Mes équipes"
You can also inline them but this is also OK. Just use the appropriate names if you want to be explicit on what those strings are for.
Best would be to place them in private consts
```diff
val tacticsTabTitle = "Espace personnel"
val teamsTabTitle = "Mes équipes"
```
You can also inline them but this is also OK. Just use the appropriate names if you want to be explicit on what those strings are for.
Best would be to place them in private consts
yanis.dahmane-bounoua marked this conversation as resolved
ew. a component should be (in best cases) independant from the context of its usage. There are rare case where you can break this, but here you can reduce the code length and make it more understandable :
See the tabs component as a list of tabs :
You can then remove OutlinedButton and FilledButton components, and perform the changes in Body:
@ComposablefunBody(padding:PaddingValues,tactics:List<Tactic>,teams:List<Team>,invalid:Boolean){Column(modifier=Modifier.padding(padding)){valselectedTab=remember{mutableIntStateOf(0)}valtabs=listOf<Pair<String,@Composable()->Unit>>(Pair("Espace personnel"){ListTacticCard(tactics)},Pair("Mes Equipes"){ListTeamCard(teams)})TabsSelector(tabsTitles=tabs.map{it.first},selectedIndex=selectedTab)if(!invalid){tabs[selectedTab.intValue].second()return}TextCentered(text="Erreur : Aucune connexion internet. Veillez activer votre connexion internet puis relancer l'application",fontSize=20.sp)}}
ew. a component should be (in best cases) independant from the context of its usage. There are rare case where you can break this, but here you can reduce the code length and make it more understandable :
See the tabs component as a list of tabs :
```kt
@Composable
TabsSelector(tabsTitles: List<String>, selectedIndex: MutableState<Int>) {
Row(...) {
for ((idx, tab) in tabsTitles.withIndex()) {
TabButton(
tab,
fill = idx == selectedIndex.value,
onClick = { selectedIndex.value = idx }
)
}
}
}
@Composable
fun TabButton(title: String, fill: Boolean, onClick: () -> Unit) {
val scheme = MaterialTheme.colorScheme
Button(
border = BorderStroke(
1.dp,
color = scheme.tertiary
),
colors = ButtonDefaults.buttonColors(
containerColor = if (fill) scheme.tertiary else scheme.background,
contentColor = if (fill) scheme.background else scheme.tertiary,
),
onClick = onClick) {
Text(title)
}
}
```
You can then remove `OutlinedButton` and `FilledButton` components, and perform the changes in `Body`:
```kt
@Composable
fun Body(padding: PaddingValues, tactics: List<Tactic>, teams: List<Team>, invalid: Boolean) {
Column(
modifier = Modifier
.padding(padding)
) {
val selectedTab = remember { mutableIntStateOf(0) }
val tabs = listOf<Pair<String, @Composable () -> Unit>>(
Pair("Espace personnel") {
ListTacticCard(tactics)
},
Pair("Mes Equipes") {
ListTeamCard(teams)
}
)
TabsSelector(tabsTitles = tabs.map { it.first }, selectedIndex = selectedTab)
if (!invalid) {
tabs[selectedTab.intValue].second()
return
}
TextCentered(
text = "Erreur : Aucune connexion internet. Veillez activer votre connexion internet puis relancer l'application",
fontSize = 20.sp
)
}
}
```
yanis.dahmane-bounoua marked this conversation as resolved
This pull request adds the home page.
Currently, you cannot visualize tactics when you click on them. There isn't the tactic's preview available because it's required the visualizer.
Please always mind of formatting your code (ctrl + alt + L)
IQBallTheme {
Prone use of the dark theme because it can use it if the phone's system theme is set in night mode.
Don't bother with a night mode for now and just force it to use the light theme.
Also remove the dynamicColor feature as it appears to change colors based on the user's system theme preferences
val auth = result.getOrNull()!!
Log.d("test", "test")
service.getUserData(auth.token)
}
package com.iqball.app.model;
class Team public constructor(
use a data class here as you done with
Tactic
}
@Composable
fun Body(padding: PaddingValues, tactics: List<Tactic>, teams: List<Team>, invalid: Boolean) {
}
@Composable
fun TabButtons(isTactics: Boolean, onToggle: (Boolean) -> Unit) {
modifier = Modifier
.padding(top = 10.dp, start = 2.dp, end = 2.dp)
.fillMaxWidth()
.padding(top = 10.dp, bottom = 10.dp)
) {
val tacticTitle = "Espace personnel"
val teamTitle = "Mes équipes"
You can also inline them but this is also OK. Just use the appropriate names if you want to be explicit on what those strings are for.
Best would be to place them in private consts
val tacticTitle = "Espace personnel"
val teamTitle = "Mes équipes"
val spaceButton = 5.dp
if (isTactics) {
ew. a component should be (in best cases) independant from the context of its usage. There are rare case where you can break this, but here you can reduce the code length and make it more understandable :
See the tabs component as a list of tabs :
You can then remove
OutlinedButton
andFilledButton
components, and perform the changes inBody
:}
@Composable
fun ListTacticCard(tactics: List<Tactic>) {
}
}
)
}
DRY !
Can be factorized :
}
@Composable
fun TacticCard(tactic: Tactic) {
)
.shadow(1.dp, shape = RoundedCornerShape(8.dp))
.background(
color = Color(0xFFFFFFFF)
try to place the hardcoded colors in
Colors.kt
at least (in the theme could be better)at line 195 and 200
}
@Composable
fun TeamCard(team: Team) {
}
@Composable
fun TeamColorCard(text: String, color: Color, fraction : Float = 1f) {
}
@Composable
fun FilledButton(text: String, onClick: () -> Unit) {
}
@Composable
fun OutlinedButton(text: String, onClick: () -> Unit) {
}
@Composable
fun TextCentered( modifier: Modifier = Modifier, text: String, fontSize: TextUnit = 18.sp, fontWeight: FontWeight? = null) {
)
}
fun getDataFromApi(service: IQBallService) : UserService.UserDataResponse?{
)
return tactics
}
You should remove
getStubTactic/getStubTeams
functions as you now get the data from the API.That can be usefull later for testing
That can be usefull later for testing
You should move them in a stub file at least
Remove this file
Commentaire
=======================================================
Gérer les listes à afficher avec des paires n'est pas forcément la meilleure chose à faire dans le contexte de composable.
No french !!!!!
47311389bd
to7aab2a0d08
1 year agof813d5053c
into master 1 year agoReviewers
f813d5053c
.