Сделаны карточки дом. задания и начат шильдик в расписании
This commit is contained in:
@@ -3,7 +3,6 @@ package ru.megboyzz.dnevnik.screens.ui
|
|||||||
import androidx.compose.animation.*
|
import androidx.compose.animation.*
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.*
|
import androidx.compose.foundation.*
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.grid.GridCells
|
import androidx.compose.foundation.lazy.grid.GridCells
|
||||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
@@ -14,10 +13,8 @@ import androidx.compose.foundation.text.KeyboardOptions
|
|||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Check
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.filled.Menu
|
|
||||||
import androidx.compose.material.icons.filled.Visibility
|
import androidx.compose.material.icons.filled.Visibility
|
||||||
import androidx.compose.material.icons.filled.VisibilityOff
|
import androidx.compose.material.icons.filled.VisibilityOff
|
||||||
import androidx.compose.material.ripple.rememberRipple
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
@@ -28,8 +25,6 @@ import androidx.compose.ui.focus.focusRequester
|
|||||||
import androidx.compose.ui.focus.onFocusChanged
|
import androidx.compose.ui.focus.onFocusChanged
|
||||||
import androidx.compose.ui.graphics.*
|
import androidx.compose.ui.graphics.*
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
import androidx.compose.ui.layout.ContentScale
|
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.semantics.Role
|
import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
@@ -38,16 +33,9 @@ import androidx.compose.ui.text.input.VisualTransformation
|
|||||||
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.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.*
|
import androidx.compose.ui.unit.*
|
||||||
import androidx.compose.ui.viewinterop.AndroidView
|
|
||||||
import androidx.navigation.NavController
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import ru.megboyzz.dnevnik.*
|
import ru.megboyzz.dnevnik.*
|
||||||
import ru.megboyzz.dnevnik.R
|
import ru.megboyzz.dnevnik.R
|
||||||
import ru.megboyzz.dnevnik.navigation.AppNavRoute
|
|
||||||
import ru.megboyzz.dnevnik.navigation.BaseNavRote
|
|
||||||
import ru.megboyzz.dnevnik.ui.theme.*
|
import ru.megboyzz.dnevnik.ui.theme.*
|
||||||
import java.time.DayOfWeek
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
//Рефакторинг компонентов: разбиение файла с компонентами на отдельные файлы
|
//Рефакторинг компонентов: разбиение файла с компонентами на отдельные файлы
|
||||||
@@ -57,10 +45,12 @@ import java.util.*
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AlmostOutlinedText(
|
fun AlmostOutlinedText(
|
||||||
text: String
|
text: String,
|
||||||
|
contentColor: Color = white,
|
||||||
|
textAlign: TextAlign = TextAlign.Center
|
||||||
){
|
){
|
||||||
Column() {
|
Column() {
|
||||||
Divider(color = white, thickness = 1.dp)
|
Divider(color = contentColor, thickness = 1.dp)
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -69,14 +59,14 @@ fun AlmostOutlinedText(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
color = white,
|
color = contentColor,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = textAlign,
|
||||||
style = H2,
|
style = H2,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Divider(color = white, thickness = 1.dp)
|
Divider(color = contentColor, thickness = 1.dp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,11 +539,23 @@ fun EmptyMessage(message: String) = ContentMessage(message = message, isFine = f
|
|||||||
fun FineMessage(message: String) = ContentMessage(message = message)
|
fun FineMessage(message: String) = ContentMessage(message = message)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MessageCard(
|
fun MessageAlert(
|
||||||
message: String,
|
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
BaseCard {
|
BaseCard {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier.defaultMinSize(300.dp),
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
){
|
||||||
|
content.invoke()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun MessageAlertInWork() {
|
||||||
|
MessageAlert {
|
||||||
|
EmptyMessage(message = "Раздел находится в разработке!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
package ru.megboyzz.dnevnik.screens.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.*
|
||||||
|
import androidx.compose.runtime.*
|
||||||
|
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.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import ru.megboyzz.dnevnik.AsPainter
|
||||||
|
import ru.megboyzz.dnevnik.AsString
|
||||||
|
import ru.megboyzz.dnevnik.R
|
||||||
|
import ru.megboyzz.dnevnik.ui.theme.H2
|
||||||
|
import ru.megboyzz.dnevnik.ui.theme.dark
|
||||||
|
import ru.megboyzz.dnevnik.ui.theme.mainBlue
|
||||||
|
import ru.megboyzz.dnevnik.ui.theme.white
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BaseHomeWorkCard(
|
||||||
|
subjectName: String,
|
||||||
|
homeWorkTaskText: String,
|
||||||
|
deadlineDate: LocalDate,
|
||||||
|
deadlineLesson: Int = -1,
|
||||||
|
isDone: Boolean,
|
||||||
|
onClickBox: (Boolean) -> Unit
|
||||||
|
) {
|
||||||
|
val deadlineLessonText = if(deadlineLesson != -1) "$deadlineLesson-го урока" else ""
|
||||||
|
|
||||||
|
val format = DateTimeFormatter.ofPattern("dd.MM.yyyy", Locale.getDefault())
|
||||||
|
var expanded by remember {
|
||||||
|
mutableStateOf(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseCard {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.defaultMinSize(300.dp)
|
||||||
|
.padding(5.dp)
|
||||||
|
){
|
||||||
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(0.dp)
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.defaultMinSize(500.dp)
|
||||||
|
){
|
||||||
|
HomeWorkIsDoneCheckBox(isDone = isDone, onClickBox = onClickBox)
|
||||||
|
Text(
|
||||||
|
text = subjectName,
|
||||||
|
style = H2,
|
||||||
|
color = dark,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
HomeWorkCardToggler(expanded = expanded, onChangeExpand = {expanded = !it})
|
||||||
|
}
|
||||||
|
if(expanded) {
|
||||||
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(5.dp),
|
||||||
|
modifier = Modifier.padding(5.dp)
|
||||||
|
) {
|
||||||
|
HomeworkText(text = homeWorkTaskText)
|
||||||
|
Text(
|
||||||
|
text = "${R.string.title_deadline.AsString()} ${
|
||||||
|
deadlineDate.format(
|
||||||
|
format
|
||||||
|
)
|
||||||
|
} $deadlineLessonText",
|
||||||
|
style = H2,
|
||||||
|
color = dark
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HomeWorkIsDoneCheckBox(
|
||||||
|
isDone: Boolean,
|
||||||
|
onClickBox: (Boolean) -> Unit
|
||||||
|
) {
|
||||||
|
val shape = RoundedCornerShape(9.dp)
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(25.dp, 20.dp)
|
||||||
|
.clip(shape)
|
||||||
|
.border(
|
||||||
|
border = BorderStroke(
|
||||||
|
width = 1.dp,
|
||||||
|
color = mainBlue
|
||||||
|
),
|
||||||
|
shape = shape
|
||||||
|
)
|
||||||
|
.clickable { onClickBox.invoke(isDone) },
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
){
|
||||||
|
if(isDone)
|
||||||
|
Image(
|
||||||
|
painter = R.drawable.ic_done.AsPainter(),
|
||||||
|
contentDescription = ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HomeWorkCardToggler(
|
||||||
|
expanded: Boolean,
|
||||||
|
onChangeExpand: (Boolean) -> Unit
|
||||||
|
) {
|
||||||
|
Box(modifier = Modifier.size(24.dp)) {
|
||||||
|
IconButton(
|
||||||
|
onClick = { onChangeExpand.invoke(expanded) },
|
||||||
|
modifier = Modifier.fillMaxSize()
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
painter = (if (expanded) R.drawable.ic_hw_toggled else R.drawable.ic_hw_untoggled).AsPainter(),
|
||||||
|
contentDescription = ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HomeworkText(
|
||||||
|
text: String,
|
||||||
|
){
|
||||||
|
Column() {
|
||||||
|
Divider(color = dark, thickness = 1.dp, modifier = Modifier.width(500.dp))
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.defaultMinSize(500.dp)
|
||||||
|
.height(40.dp),
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = text,
|
||||||
|
color = dark,
|
||||||
|
style = H2,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Divider(color = dark, thickness = 1.dp, modifier = Modifier.width(500.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ import ru.megboyzz.dnevnik.screens.ui.piechart.PieChartCard
|
|||||||
import ru.megboyzz.dnevnik.screens.ui.piechart.PieChartData
|
import ru.megboyzz.dnevnik.screens.ui.piechart.PieChartData
|
||||||
import ru.megboyzz.dnevnik.ui.theme.mainBlue
|
import ru.megboyzz.dnevnik.ui.theme.mainBlue
|
||||||
import ru.megboyzz.dnevnik.ui.theme.white
|
import ru.megboyzz.dnevnik.ui.theme.white
|
||||||
|
import java.time.LocalDate
|
||||||
import java.time.YearMonth
|
import java.time.YearMonth
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -34,7 +35,8 @@ fun NicePreviewContainer(
|
|||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.verticalScroll(rememberScrollState()).height(1500.dp),
|
.verticalScroll(rememberScrollState())
|
||||||
|
.height(1500.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
) { content() }
|
) { content() }
|
||||||
@@ -252,3 +254,39 @@ fun PieChartNullPrev() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun MessagesPrev() {
|
||||||
|
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
|
) {
|
||||||
|
MessageAlert {
|
||||||
|
EmptyMessage(message = "Таких оценок нет((")
|
||||||
|
}
|
||||||
|
MessageAlert {
|
||||||
|
FineMessage(message = "Сегодня нет уроков!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun HomeWorkCardPrev() {
|
||||||
|
var isDone by remember {
|
||||||
|
mutableStateOf(false)
|
||||||
|
}
|
||||||
|
BaseHomeWorkCard(
|
||||||
|
subjectName = "Алгебра и начала математического анализа",
|
||||||
|
homeWorkTaskText = "C. 45 №45, №56, №46",
|
||||||
|
deadlineDate = LocalDate.now(),
|
||||||
|
isDone = isDone,
|
||||||
|
onClickBox = {
|
||||||
|
isDone = !it
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package ru.megboyzz.dnevnik.screens.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BaseScheduleShield(
|
||||||
|
subjectName: String,
|
||||||
|
teacherName: String,
|
||||||
|
classNumber: String,
|
||||||
|
nextLessonName: String
|
||||||
|
) {
|
||||||
|
BaseCard {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TextHeader(
|
||||||
|
title: String,
|
||||||
|
value: String,
|
||||||
|
valueIsBlue: Boolean = true
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M11.667,10.002C11.512,10.001 11.361,10.056 11.241,10.155L7.241,13.488C7.105,13.601 7.019,13.764 7.003,13.94C6.987,14.117 7.041,14.292 7.154,14.428C7.267,14.564 7.43,14.65 7.606,14.666C7.782,14.682 7.958,14.628 8.094,14.515L11.667,11.528L15.241,14.408C15.309,14.464 15.387,14.505 15.472,14.53C15.556,14.555 15.644,14.563 15.732,14.554C15.819,14.544 15.904,14.518 15.981,14.476C16.058,14.434 16.126,14.377 16.181,14.308C16.242,14.24 16.288,14.159 16.317,14.072C16.345,13.985 16.355,13.893 16.347,13.801C16.338,13.71 16.31,13.621 16.266,13.541C16.221,13.461 16.16,13.391 16.087,13.335L12.087,10.115C11.964,10.031 11.816,9.991 11.667,10.002Z"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
</vector>
|
||||||
@@ -65,4 +65,5 @@
|
|||||||
<string name="title_reason">"Reason: "</string>
|
<string name="title_reason">"Reason: "</string>
|
||||||
<string name="title_result_mark">Result</string>
|
<string name="title_result_mark">Result</string>
|
||||||
<string name="title_average_mark">Average</string>
|
<string name="title_average_mark">Average</string>
|
||||||
|
<string name="title_deadline">Deadline:</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -64,4 +64,5 @@
|
|||||||
<string name="title_reason">Причина:</string>
|
<string name="title_reason">Причина:</string>
|
||||||
<string name="title_result_mark">Итог</string>
|
<string name="title_result_mark">Итог</string>
|
||||||
<string name="title_average_mark">Ср. балл</string>
|
<string name="title_average_mark">Ср. балл</string>
|
||||||
|
<string name="title_deadline">Выполнить до:</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user