|
|
@ -1,14 +1,12 @@
|
|
|
|
package com.iqball.app.page
|
|
|
|
package com.iqball.app.page
|
|
|
|
|
|
|
|
|
|
|
|
import com.iqball.app.model.Tactic
|
|
|
|
|
|
|
|
import com.iqball.app.model.Team
|
|
|
|
|
|
|
|
import androidx.compose.foundation.BorderStroke
|
|
|
|
import androidx.compose.foundation.BorderStroke
|
|
|
|
import androidx.compose.foundation.Canvas
|
|
|
|
import androidx.compose.foundation.Canvas
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
import androidx.compose.foundation.border
|
|
|
|
import androidx.compose.foundation.border
|
|
|
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
@ -22,7 +20,6 @@ import androidx.compose.foundation.lazy.staggeredgrid.items
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
|
import androidx.core.graphics.toColorInt
|
|
|
|
|
|
|
|
import androidx.compose.material3.CenterAlignedTopAppBar
|
|
|
|
import androidx.compose.material3.CenterAlignedTopAppBar
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
@ -31,24 +28,28 @@ import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.TopAppBarDefaults
|
|
|
|
import androidx.compose.material3.TopAppBarDefaults
|
|
|
|
import androidx.compose.material3.TopAppBarDefaults.pinnedScrollBehavior
|
|
|
|
import androidx.compose.material3.TopAppBarDefaults.pinnedScrollBehavior
|
|
|
|
import androidx.compose.material3.rememberTopAppBarState
|
|
|
|
import androidx.compose.material3.rememberTopAppBarState
|
|
|
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.MutableState
|
|
|
|
import androidx.compose.runtime.MutableState
|
|
|
|
import androidx.compose.runtime.mutableIntStateOf
|
|
|
|
import androidx.compose.runtime.mutableIntStateOf
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
|
|
|
import androidx.compose.ui.text.style.TextOverflow
|
|
|
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.draw.shadow
|
|
|
|
import androidx.compose.ui.draw.shadow
|
|
|
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
import androidx.compose.ui.graphics.RectangleShape
|
|
|
|
import androidx.compose.ui.graphics.RectangleShape
|
|
|
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|
|
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
|
|
|
|
|
import androidx.compose.ui.text.style.TextOverflow
|
|
|
|
import androidx.compose.ui.unit.TextUnit
|
|
|
|
import androidx.compose.ui.unit.TextUnit
|
|
|
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
|
|
|
import androidx.core.graphics.toColorInt
|
|
|
|
|
|
|
|
import androidx.navigation.NavController
|
|
|
|
import arrow.core.Either
|
|
|
|
import arrow.core.Either
|
|
|
|
import coil.compose.AsyncImage
|
|
|
|
import coil.compose.AsyncImage
|
|
|
|
import com.iqball.app.net.service.AuthService
|
|
|
|
import com.iqball.app.model.Tactic
|
|
|
|
|
|
|
|
import com.iqball.app.model.Team
|
|
|
|
import com.iqball.app.net.service.IQBallService
|
|
|
|
import com.iqball.app.net.service.IQBallService
|
|
|
|
import com.iqball.app.net.service.UserService
|
|
|
|
import com.iqball.app.net.service.UserService
|
|
|
|
import com.iqball.app.session.Authentication
|
|
|
|
import com.iqball.app.session.Authentication
|
|
|
@ -60,15 +61,17 @@ import java.time.format.DateTimeFormatter
|
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun HomePage(service: IQBallService, auth: Authentication) {
|
|
|
|
fun HomePage(service: IQBallService,
|
|
|
|
|
|
|
|
auth: Authentication,
|
|
|
|
|
|
|
|
navController: NavController) {
|
|
|
|
val tactics: List<Tactic>
|
|
|
|
val tactics: List<Tactic>
|
|
|
|
val teams: List<Team>
|
|
|
|
val teams: List<Team>
|
|
|
|
var invalid = false
|
|
|
|
var invalid = false
|
|
|
|
|
|
|
|
|
|
|
|
val data = getDataFromApi(service, auth)
|
|
|
|
val data = getDataFromApi(service, auth)
|
|
|
|
if (data == null) {
|
|
|
|
if (data == null) {
|
|
|
|
tactics = listOf<Tactic>()
|
|
|
|
tactics = listOf()
|
|
|
|
teams = listOf<Team>()
|
|
|
|
teams = listOf()
|
|
|
|
invalid = true
|
|
|
|
invalid = true
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -96,7 +99,7 @@ fun HomePage(service: IQBallService, auth: Authentication) {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
) { innerPadding ->
|
|
|
|
) { innerPadding ->
|
|
|
|
Body(innerPadding, tactics, teams, invalid)
|
|
|
|
Body(innerPadding, tactics, teams, invalid, navController)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -105,7 +108,8 @@ private fun Body(
|
|
|
|
padding: PaddingValues,
|
|
|
|
padding: PaddingValues,
|
|
|
|
tactics: List<Tactic>,
|
|
|
|
tactics: List<Tactic>,
|
|
|
|
teams: List<Team>,
|
|
|
|
teams: List<Team>,
|
|
|
|
invalid: Boolean
|
|
|
|
invalid: Boolean,
|
|
|
|
|
|
|
|
navController: NavController
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
@ -115,7 +119,9 @@ private fun Body(
|
|
|
|
val tabs = listOf<Pair<String, @Composable () -> Unit>>(
|
|
|
|
val tabs = listOf<Pair<String, @Composable () -> Unit>>(
|
|
|
|
Pair("Espace personnel") {
|
|
|
|
Pair("Espace personnel") {
|
|
|
|
ListComponentCard(tactics) { tactic ->
|
|
|
|
ListComponentCard(tactics) { tactic ->
|
|
|
|
TacticCard(tactic = tactic)
|
|
|
|
TacticCard(tactic = tactic, onClick = {
|
|
|
|
|
|
|
|
navController.navigate("view/${tactic.id}")
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Pair("Mes équipes") {
|
|
|
|
Pair("Mes équipes") {
|
|
|
@ -130,7 +136,6 @@ private fun Body(
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextCentered(
|
|
|
|
TextCentered(
|
|
|
|
text = "Erreur : Aucune connexion internet. Veillez activer votre connexion internet puis relancer l'application",
|
|
|
|
text = "Erreur : Aucune connexion internet. Veillez activer votre connexion internet puis relancer l'application",
|
|
|
|
fontSize = 20.sp
|
|
|
|
fontSize = 20.sp
|
|
|
@ -197,7 +202,7 @@ private fun <C> ListComponentCard(items: List<C>, componentCard: @Composable (C)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
private fun TacticCard(tactic: Tactic) {
|
|
|
|
private fun TacticCard(tactic: Tactic, onClick: () -> Unit) {
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.padding(5.dp)
|
|
|
|
.padding(5.dp)
|
|
|
@ -210,6 +215,7 @@ private fun TacticCard(tactic: Tactic) {
|
|
|
|
color = Color.White
|
|
|
|
color = Color.White
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.padding(15.dp)
|
|
|
|
.padding(15.dp)
|
|
|
|
|
|
|
|
.clickable { onClick() }
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Row {
|
|
|
|
Row {
|
|
|
|
TextCentered(text = tactic.name, fontSize = 16.sp)
|
|
|
|
TextCentered(text = tactic.name, fontSize = 16.sp)
|
|
|
|