Улучшил report
This commit is contained in:
parent
a29f8803ae
commit
ba81ea4ed2
@ -7,6 +7,7 @@ data class ReportRemote(
|
||||
val dateFrom: Long,
|
||||
val dateTo: Long,
|
||||
val postCount: Int,
|
||||
val mostPostAuthor: String,
|
||||
val mostPostCount: Int
|
||||
val mostPostAuthor: UserRemote,
|
||||
val mostPostCount: Int,
|
||||
val listPostAuthor: List<StoryRemote>
|
||||
)
|
||||
|
@ -210,7 +210,7 @@ fun NavBar(navController: NavHostController) {
|
||||
composable("report"){
|
||||
topBarState.value = false
|
||||
bottomBarState.value = true
|
||||
ReportScreen()
|
||||
ReportScreen(navController = navController)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,44 @@
|
||||
package com.example.mobileapp.screens
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
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.graphics.asImageBitmap
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavHostController
|
||||
import com.example.mobileapp.api.model.toStory
|
||||
import com.example.mobileapp.api.model.toUser
|
||||
import com.example.mobileapp.components.ActiveButton
|
||||
import com.example.mobileapp.components.DatePicker
|
||||
import com.example.mobileapp.components.MailListItem
|
||||
import com.example.mobileapp.components.StoryListItem
|
||||
import com.example.mobileapp.components.addNewListItem
|
||||
import com.example.mobileapp.components.isListOf
|
||||
import com.example.mobileapp.database.entities.Mail
|
||||
import com.example.mobileapp.database.entities.Story
|
||||
import com.example.mobileapp.database.viewmodels.MobileAppViewModelProvider
|
||||
import com.example.mobileapp.database.viewmodels.ReportViewModel
|
||||
import com.example.mobileapp.ui.theme.ButtonColor2
|
||||
@ -26,8 +46,8 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
@Composable
|
||||
fun ReportScreen(
|
||||
reportViewModel: ReportViewModel = viewModel(factory = MobileAppViewModelProvider.Factory)){
|
||||
fun ReportScreen(navController: NavHostController,
|
||||
reportViewModel: ReportViewModel = viewModel(factory = MobileAppViewModelProvider.Factory)){
|
||||
val dateFormat = SimpleDateFormat("dd.MM.yyyy")
|
||||
|
||||
val dateFrom = remember { mutableStateOf(Date().time) }
|
||||
@ -79,7 +99,39 @@ fun ReportScreen(
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier
|
||||
.padding(8.dp))
|
||||
Text(text = "Наибольшее число публикаций у: ${reportViewModel.report.value?.mostPostAuthor}",
|
||||
Row(
|
||||
verticalAlignment = Alignment.Top
|
||||
){
|
||||
Image(bitmap = reportViewModel.report.value?.mostPostAuthor?.toUser()?.photo!!.asImageBitmap(),
|
||||
contentDescription = "message",
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.size(96.dp)
|
||||
.padding(8.dp)
|
||||
.clip(RoundedCornerShape(16.dp)))
|
||||
Column(
|
||||
modifier = Modifier.padding(8.dp)
|
||||
){
|
||||
Text(
|
||||
text = "${reportViewModel.report.value?.mostPostAuthor?.toUser()?.login}",
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold)
|
||||
Text(text = "Кол-во публикаций у пользователя:${reportViewModel.report.value?.mostPostCount}")
|
||||
}
|
||||
}
|
||||
LazyColumn(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
){
|
||||
val list = reportViewModel.report.value?.listPostAuthor!!.map {
|
||||
it.toStory()
|
||||
}
|
||||
items(list){ item ->
|
||||
StoryListItem(item = item, navController = navController, isReadOnly = true)
|
||||
}
|
||||
}
|
||||
/*Text(text = "Наибольшее число публикаций у: ${reportViewModel.report.value?.mostPostAuthor}",
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier
|
||||
@ -88,11 +140,7 @@ fun ReportScreen(
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier
|
||||
.padding(8.dp))
|
||||
ActiveButton(label = "Сбросить", backgroundColor = ButtonColor2,
|
||||
textColor = Color.White, onClickAction = {
|
||||
reportViewModel.clearReport()
|
||||
})
|
||||
.padding(8.dp))*/
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user