Skip to content

Commit

Permalink
download homework attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
x3lfyn committed Mar 29, 2024
1 parent 9fc5f84 commit 188698a
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.vobbla16.mesh.ui.screens.lessonScreen.subscreens

import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -16,6 +18,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -50,6 +53,7 @@ fun HomeworkTabUI(
snackbarHostState: SnackbarHostState
) {
val scope = rememberCoroutineScope()
val context = LocalContext.current

GenericHolderContainer(
holder = state.lessonInfo,
Expand All @@ -76,15 +80,18 @@ fun HomeworkTabUI(
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(8.dp, 2.dp)
modifier = Modifier.padding(8.dp, 0.dp)
) {
Text(
text = material.title,
style = MaterialTheme.typography.labelMedium,
modifier = Modifier.weight(1f)
)
IconButton(onClick = {
scope.launch { snackbarHostState.showSnackbar("Not yet implemented") }
scope.launch {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(material.links.first()))
context.startActivity(browserIntent)
}
}) {
Icon(
painter = painterResource(id = R.drawable.download),
Expand Down Expand Up @@ -118,7 +125,10 @@ private fun HomeworkTabPreview1() {
Homework(
name = "длинное название длинное название длинное название длинное название длинное название длинное название длинное название длинное название длинное название длинное название длинное название",
additionMaterials = listOf(
AdditionalMaterial.Attachment(title = "приложение 1.pdf", links = listOf("https://ya.ru"))
AdditionalMaterial.Attachment(
title = "приложение 1.pdf",
links = listOf("https://ya.ru")
)
),
isDone = false
)
Expand Down

0 comments on commit 188698a

Please sign in to comment.