Skip to content

Commit

Permalink
Merge pull request #56 from Team-Shaka/feat/minorfixes
Browse files Browse the repository at this point in the history
Feat/minorfixes
  • Loading branch information
gomsang authored Dec 23, 2023
2 parents b28ce92 + fd67220 commit 2a95ecd
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 64 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.dev.briefing"
minSdk 28
targetSdk 34
versionCode 3
versionName "1.1.1"
versionCode 4
versionName "2.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.dev.briefing.data.datasource
import com.dev.briefing.data.api.BriefingApi
import com.dev.briefing.data.model.response.BriefingArticleResponse
import com.dev.briefing.data.model.response.BriefingCategoryArticlesResponse
import com.dev.briefing.data.model.response.BriefingCompactArticleResponse
import com.dev.briefing.model.BriefingCategoryArticles
import com.dev.briefing.model.enum.BriefingArticleCategory
import com.dev.briefing.model.enum.TimeOfDay
import java.time.LocalDate
Expand All @@ -18,7 +16,7 @@ class BriefingDataSourceImpl(private val briefingApi: BriefingApi) : BriefingDat
timeOfDay: TimeOfDay?
): BriefingCategoryArticlesResponse {
return briefingApi.getBriefingCategoryArticles(
type = type.typeName,
type = type.typeId,
date = date?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),
timeOfDay = timeOfDay?.value
).result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.dev.briefing.model.enum

enum class BriefingArticleCategory(val typeName: String) {
KOREA("KOREA"),
GLOBAL("GLOBAL"),
SOCIAL("SOCIAL"),
SCIENCE("SCIENCE"),
ECONOMY("ECONOMY");
import com.dev.briefing.R

enum class BriefingArticleCategory(val typeId: String, val typeName: Int) {
KOREA("KOREA", R.string.name_category_korea),
GLOBAL("GLOBAL", R.string.name_category_global),
SOCIAL("SOCIAL", R.string.name_category_society),
SCIENCE("SCIENCE", R.string.name_category_science),
ECONOMY("ECONOMY", R.string.name_category_economy);

companion object {
fun fromTypeName(typeName: String): BriefingArticleCategory {
return values().firstOrNull { it.typeName.equals(typeName, ignoreCase = true) }
return values().firstOrNull { it.typeId.equals(typeName, ignoreCase = true) }
?: throw IllegalArgumentException("Invalid typeName for ArticleType: $typeName")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
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.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.datasource.LoremIpsum
Expand All @@ -27,7 +28,10 @@ import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.dev.briefing.R
import com.dev.briefing.model.RelatedArticle
import com.dev.briefing.presentation.login.SignInActivity
import com.dev.briefing.presentation.theme.BriefingTheme
import com.dev.briefing.presentation.theme.utils.CommonDialog
import com.dev.briefing.util.preference.AuthPreferenceHelper
import org.koin.androidx.compose.getViewModel

@Composable
Expand All @@ -37,6 +41,25 @@ fun ArticleDetailScreen(
onBackClick: () -> Unit = {},
navController: NavController = rememberNavController()
) {
val context = LocalContext.current
val authPreferenceHelper = AuthPreferenceHelper(context)

val openSignInDialog = remember { mutableStateOf(false) }
if (openSignInDialog.value) {
CommonDialog(
onDismissRequest = { openSignInDialog.value = false },
onConfirmation = {
val intent = Intent(context, SignInActivity::class.java)
startActivity(context, intent, null)
openSignInDialog.value = false
},
dialogTitle = R.string.dialog_login_title,
dialogText = R.string.dialog_login_text,
dialogId = R.string.dialog_login_confirm,
confirmColor = BriefingTheme.color.PrimaryBlue
)
}

LaunchedEffect(articleId) {
articleDetailViewModel.loadBriefingArticle(articleId)
}
Expand Down Expand Up @@ -75,12 +98,16 @@ fun ArticleDetailScreen(
modifier = Modifier.padding(30.dp, 18.dp),
title = article.title,
date = article.createdDate.toString(),
section = article.category.typeName,
section = "${stringResource(id = article.category.typeName)} #${article.ranks}",
generatedEngine = article.gptModel,
scrapCount = article.scrapCount,
isScrapingInProgress = uiState.isScrapingInProgress,
isScrapped = article.isScrap,
onScrapClick = {
if (authPreferenceHelper.getMemberId() == -1) {
openSignInDialog.value = true
return@ArticleDetailHeader
}
if (article.isScrap) {
articleDetailViewModel.unScrap(article.id)
} else {
Expand Down Expand Up @@ -367,11 +394,12 @@ fun TopBar(onBackPressed: () -> Unit) {
)
}

IconButton(onClick = onBackPressed, modifier = Modifier.align(Alignment.CenterEnd)) {
// TODO : enable when function developed
/*IconButton(onClick = onBackPressed, modifier = Modifier.align(Alignment.CenterEnd)) {
Icon(
painter = painterResource(id = R.drawable.baseline_more_horiz_24),
contentDescription = null
)
}
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fun formatBriefingDate(date: Date): String {
val datePart = dateFormat.format(date)
val hourPart = timeFormat.format(date).toInt()

val briefingPart = if (hourPart < 12) "아침 브리핑" else "저녁 브리핑"
val briefingPart = if (hourPart < 16) "아침 브리핑" else "저녁 브리핑"

return "$datePart $briefingPart"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ class HomeViewModel(

runCatching {
briefingRepository.getBriefings(
briefingArticleCategory,
LocalDate.of(2023, 11, 30),
TimeOfDay.MORNING
briefingArticleCategory
)
}.onSuccess {
currentLoadingCategories.remove(briefingArticleCategory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SignInActivity : ComponentActivity() {
val token = authPreferenceHelper.getAccessToken()
val memberId = authPreferenceHelper.getMemberId()
if (token != "" && memberId != -1) {
Toast.makeText(this, "자동 로그인 되었습니다.", Toast.LENGTH_SHORT).show()
// Toast.makeText(this, "자동 로그인 되었습니다.", Toast.LENGTH_SHORT).show()
val intent = Intent(this@SignInActivity, HomeActivity::class.java)
startActivity(intent, null)
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fun SettingScreen(

val intent = Intent(context, SignInActivity::class.java)
startActivity(context, intent, null)
val activity = context as? ComponentActivity
val activity = context as? Activity
activity?.finish()
},
dialogTitle = R.string.dialog_logout_title,
Expand Down Expand Up @@ -138,8 +138,8 @@ fun SettingScreen(
timePickerDialog.show()
},
)
//구독 정보
SettingSection(R.string.setting_section_premium)
// TODO : enable when starting premium service
/*SettingSection(R.string.setting_section_premium)
SettingMenuItem(
type = SettingMenu(
isArrow = true,
Expand All @@ -148,7 +148,7 @@ fun SettingScreen(
onClick = {
navController.navigate(HomeScreen.Premium.route)
},
)
)*/
//앱 정보
SettingSection(R.string.setting_section_info)
SettingMenuItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ package com.dev.briefing.presentation.theme.component
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
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.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.dev.briefing.R
import androidx.constraintlayout.compose.ConstraintLayout
import com.dev.briefing.presentation.theme.BriefingTheme
import java.time.format.TextStyle

@Preview
@Composable
Expand All @@ -36,50 +42,32 @@ fun CommonHeader(
onBackClick: () -> Unit = {},
header: String = "",
color: Color = BriefingTheme.color.BackgroundWhite,
isPadding: Boolean = false
) {
ConstraintLayout(
modifier = modifier
.fillMaxWidth()
.background(color = color)
.padding(
top = 24.dp, bottom = 15.dp, start = if (isPadding) {
20.dp
} else {
0.dp
}, end = if (isPadding) {
20.dp
} else {
0.dp
}
),
)
{
val (backKey, title) = createRefs()
Image(
modifier = Modifier
.height(20.dp)
.clickable(onClick = onBackClick)
.constrainAs(backKey) {
start.linkTo(parent.start)
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)
},
painter = painterResource(
id = R.drawable.vector
),
contentDescription = "뒤로가기"
)
Box(modifier.fillMaxWidth().background(color).padding(20.dp, 16.dp)) {
Box(modifier = Modifier
.size(33.dp)
.clickable(onClick = onBackClick)
.align(Alignment.CenterStart)) {
Image(
modifier = Modifier
.size(8.dp, 16.dp)
.align(Alignment.Center),
painter = painterResource(
id = R.drawable.vector
),
contentDescription = "뒤로가기"
)
}

Text(
modifier = Modifier.constrainAs(title) {
start.linkTo(parent.start)
end.linkTo(parent.end)
},
text = header,
style = BriefingTheme.typography.SubtitleStyleBold.copy(
color = BriefingTheme.color.TextBlack,
modifier = Modifier
.align(Alignment.Center),
style = BriefingTheme.typography.TitleStyleRegular.copy(
fontSize = 20.sp,
fontWeight = FontWeight(400)
fontWeight = FontWeight(400),
color = Color(0xFF000000),
textAlign = TextAlign.Center,
)
)
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@
<string name="title_tab_home_science">과학</string>
<string name="title_tab_home_global">글로벌</string>
<string name="title_tab_home_economy">경제</string>
<string name="name_category_korea">한국</string>
<string name="name_category_global">세계</string>
<string name="name_category_society">사회</string>
<string name="name_category_science">과학</string>
<string name="name_category_economy">경제</string>
</resources>

0 comments on commit 2a95ecd

Please sign in to comment.