-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from KNUTICE/main
[PR] Release 1.0.0 Alpha
- Loading branch information
Showing
48 changed files
with
588 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/doyoonkim/knutice/domain/CrawlFullContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.doyoonkim.knutice.domain | ||
|
||
import com.doyoonkim.knutice.viewModel.DetailedContentState | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface CrawlFullContent { | ||
|
||
fun getFullContentFromSource(title: String, info: String, url: String): Flow<DetailedContentState> | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/doyoonkim/knutice/domain/CrawlFullContentImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.doyoonkim.knutice.domain | ||
|
||
import com.doyoonkim.knutice.data.NoticeLocalRepository | ||
import com.doyoonkim.knutice.viewModel.DetailedContentState | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class CrawlFullContentImpl @Inject constructor( | ||
private val repository: NoticeLocalRepository | ||
): CrawlFullContent { | ||
override fun getFullContentFromSource( | ||
title: String, | ||
info: String, | ||
url: String | ||
): Flow<DetailedContentState> { | ||
return repository.getFullNoticeContent(url) | ||
.map { | ||
DetailedContentState( | ||
title = title, | ||
info = info, | ||
fullContent = it, | ||
fullContentUrl = url | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package com.doyoonkim.knutice.presentation | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
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.wrapContentHeight | ||
import androidx.compose.foundation.layout.wrapContentSize | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonColors | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.ColorFilter | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.doyoonkim.knutice.ui.theme.buttonContainer | ||
import com.doyoonkim.knutice.ui.theme.containerBackground | ||
import com.doyoonkim.knutice.ui.theme.title | ||
import com.doyoonkim.knutice.viewModel.DetailedContentState | ||
import com.example.knutice.R | ||
|
||
@Composable | ||
fun DetailedNoticeContent( | ||
modifier: Modifier = Modifier, | ||
requested: DetailedContentState = DetailedContentState(), | ||
onCloseRequested: () -> Unit = { } | ||
) { | ||
val localContext = LocalContext.current | ||
|
||
Surface( | ||
modifier = modifier.fillMaxWidth(), | ||
shape = RoundedCornerShape(10.dp), | ||
color = MaterialTheme.colorScheme.containerBackground | ||
) { | ||
Column( | ||
Modifier.padding(15.dp) | ||
) { | ||
Row( | ||
Modifier.fillMaxWidth() | ||
.weight(0.5f), | ||
horizontalArrangement = Arrangement.Center, | ||
verticalAlignment = Alignment.Bottom | ||
) { | ||
Text( | ||
modifier = Modifier.weight(5f).wrapContentHeight(), | ||
text = requested.title, | ||
fontSize = 28.sp, | ||
fontWeight = FontWeight.SemiBold, | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
IconButton( | ||
modifier = Modifier.weight(1f).wrapContentSize(), | ||
onClick = { onCloseRequested() } | ||
) { | ||
Image( | ||
painter = painterResource(R.drawable.baseline_close_24), | ||
contentDescription = "Close Button", | ||
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.title) | ||
) | ||
} | ||
} | ||
|
||
Text( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.wrapContentHeight() | ||
.weight(0.5f), | ||
text = requested.info, | ||
fontSize = 16.sp, | ||
fontWeight = FontWeight.Normal | ||
) | ||
|
||
Text( | ||
modifier = Modifier.fillMaxWidth() | ||
.weight(8f), | ||
text = requested.fullContent, | ||
fontSize = 18.sp, | ||
fontWeight = FontWeight.Medium, | ||
) | ||
|
||
Button( | ||
onClick = { | ||
val webIntent = Intent(Intent.ACTION_VIEW, Uri.parse(requested.fullContentUrl)) | ||
localContext.startActivity(webIntent) | ||
}, | ||
shape = RoundedCornerShape(15.dp), | ||
modifier = Modifier.fillMaxWidth() | ||
.padding(start = 15.dp, end = 15.dp, top = 5.dp, bottom = 5.dp) | ||
.weight(0.7f), | ||
colors = ButtonColors( | ||
containerColor = MaterialTheme.colorScheme.buttonContainer, | ||
contentColor = Color.White, | ||
disabledContentColor = Color.Unspecified, | ||
disabledContainerColor = Color.Unspecified | ||
) | ||
) { | ||
Text( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = stringResource(R.string.btn_more_on_browser), | ||
textAlign = TextAlign.Center, | ||
fontSize = 14.sp, | ||
fontWeight = FontWeight.SemiBold | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
@Preview | ||
@Composable | ||
fun DetailedNoticeContent_Preview() { | ||
DetailedNoticeContent( | ||
requested = DetailedContentState( | ||
title = "Test", | ||
info = "Test", | ||
fullContent = "Full Content" | ||
) | ||
) | ||
} |
Oops, something went wrong.