Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 관심 축제 등록/해제 API 연동 및 알림(fcm) 기능 추가(미완) #232

Merged
merged 29 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5501452
[feat] fcm 관련 의존성 추가
easyhooon Aug 11, 2024
557c08c
[feat] UnifestFirebaseMessagingService 클래스 추가
easyhooon Aug 11, 2024
06bef3b
Merge remote-tracking branch 'origin/develop' into feat/fcm
easyhooon Aug 17, 2024
49f6d02
[chore] LikedBoothViewModel 주석 처리된 함수 제거
easyhooon Aug 17, 2024
e453296
[add] 알림 권한 추가
easyhooon Aug 17, 2024
a340788
[add] 관심 부스 등록, 해제 API 연동
easyhooon Aug 17, 2024
dbfd1f9
[chore] 사용하지 않는 request data class 삭제
easyhooon Aug 17, 2024
682d73b
[refactor] BoothDetailScreen 내에 Component 분리
easyhooon Aug 17, 2024
43beceb
[refactor] PermissionDialog core:ui 모듈로 이동
easyhooon Aug 17, 2024
c49299a
[refactor] MapScreen 내에 Component 분리
easyhooon Aug 17, 2024
05fa2cd
[feat] 알림 권한 요청 및 FCM 토큰 저장 및 조회 로직 구현
easyhooon Aug 17, 2024
4ec7e92
[chore] 사용하지 않는 multi part 관련 Retrofit 모듈 제거
easyhooon Aug 17, 2024
adc84f6
[feat] 관심 부스 등록/해제 API 연동 테스트
easyhooon Aug 17, 2024
a67eafd
[fix] 확성기 관심 축제 등록/해제 API 네이밍 변경 및 위치 이동
easyhooon Aug 18, 2024
419e8e6
[feat] NotificationPermissionTextProvider 추가
easyhooon Aug 18, 2024
76a0316
[refactor] 알람 권한 요청 플로우 MapScreen 으로 이동
easyhooon Aug 18, 2024
5b19049
[chore] feature:booth 모듈내 Manifest 파일 제거, unused import 제거
easyhooon Aug 18, 2024
b8d6415
[refactor] 권한 관련 로직 기존 이벤트 처리 로직 적용
easyhooon Aug 18, 2024
22b3673
[style] Intro 모듈 system bar 다크모드 분기 적용
easyhooon Aug 18, 2024
9272b98
[feat] 관심 축제 등록/해제 API 연동
easyhooon Aug 18, 2024
42fb9ee
[chore] TODO 추가
easyhooon Aug 22, 2024
6bab86c
[fix] 관심 축제 등록 해제 API 연동 수정
easyhooon Aug 23, 2024
844b487
[style] ic_check svg 파일 교체
easyhooon Aug 23, 2024
df1cfe0
[feat] 관심 축제 API 성공/실패 토스트 메세지 추가
easyhooon Aug 23, 2024
9195ed4
[chore] style check success
easyhooon Aug 23, 2024
b2be8ea
[feat] 홈 화면 내에 관심 축제 추가 실패 처리 로직 변경
easyhooon Aug 23, 2024
a332da6
[refactor] 홈 화면 component 분리
easyhooon Aug 23, 2024
1fe0063
Merge remote-tracking branch 'origin/develop' into feat/fcm
easyhooon Aug 23, 2024
4d1aaf7
Merge remote-tracking branch 'origin/develop' into feat/fcm
easyhooon Aug 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="home_add_interest_festival_button">관심 축제 추가하기</string>
<string name="home_add_interest_festival_in_item_button">관심 축제로 추가</string>
<string name="home_add_interest_festival_saved_message">관심 축제로 저장했습니다</string>
<string name="home_add_interest_festival_saved_failed_message">관심 축제로 저장했습니다</string>
<string name="home_add_interest_festival_saved_failed_message">관심 축제로 저장을 실패했습니다.</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이럴수가

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 아니구나.. 요번에 추가된거군요 ㅋㅋㅋ

<string name='home_empty_festival_text'>축제 일정 없음</string>
<string name="home_empty_festival_schedule_description_text">오늘은 축제가 열리는 학교가 없어요</string>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
package com.unifest.android.feature.home

import android.widget.Toast
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
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.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand All @@ -31,54 +22,43 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
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.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.unifest.android.core.common.ObserveAsEvents
import com.unifest.android.core.common.UiText
import com.unifest.android.core.common.utils.formatWithDayOfWeek
import com.unifest.android.core.common.utils.toLocalDate
import com.unifest.android.core.designsystem.R
import com.unifest.android.core.designsystem.component.NetworkImage
import com.unifest.android.core.designsystem.component.UnifestHorizontalDivider
import com.unifest.android.core.designsystem.component.UnifestOutlinedButton
import com.unifest.android.core.designsystem.theme.BoothLocation
import com.unifest.android.core.designsystem.theme.Content4
import com.unifest.android.core.designsystem.theme.Content5
import com.unifest.android.core.designsystem.theme.Content6
import com.unifest.android.core.designsystem.theme.DarkBlueGreen
import com.unifest.android.core.designsystem.theme.LightBlueGreen
import com.unifest.android.core.designsystem.theme.Title2
import com.unifest.android.core.designsystem.theme.Title3
import com.unifest.android.core.designsystem.theme.UnifestTheme
import com.unifest.android.core.model.FestivalModel
import com.unifest.android.core.model.FestivalTodayModel
import com.unifest.android.core.ui.DarkDevicePreview
import com.unifest.android.core.ui.DevicePreview
import com.unifest.android.core.ui.component.StarImage
import com.unifest.android.feature.festival.FestivalSearchBottomSheet
import com.unifest.android.feature.festival.viewmodel.FestivalUiAction
import com.unifest.android.feature.festival.viewmodel.FestivalUiEvent
import com.unifest.android.feature.festival.viewmodel.FestivalUiState
import com.unifest.android.feature.festival.viewmodel.FestivalViewModel
import com.unifest.android.feature.home.component.FestivalScheduleItem
import com.unifest.android.feature.home.component.IncomingFestivalCard
import com.unifest.android.feature.home.viewmodel.HomeUiAction
import com.unifest.android.feature.home.viewmodel.HomeUiEvent
import com.unifest.android.feature.home.viewmodel.HomeUiState
import com.unifest.android.feature.home.viewmodel.HomeViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit

// TODO 이미 관심 축제로 추가된 축제는 관심 축제로 추가하기 버튼이 보이면 안됨
@Composable
internal fun HomeRoute(
padding: PaddingValues,
Expand Down Expand Up @@ -140,7 +120,12 @@ internal fun HomeScreen(
)
}
item {
FestivalScheduleText(selectedDate = homeUiState.selectedDate)
Text(
text = DateTimeFormatter.ofPattern("M월 d일").format(homeUiState.selectedDate) + stringResource(id = R.string.home_festival_schedule_text),
modifier = Modifier.padding(start = 20.dp, top = 20.dp),
color = MaterialTheme.colorScheme.onBackground,
style = Title3,
)
}
if (homeUiState.todayFestivals.isEmpty()) {
item {
Expand Down Expand Up @@ -217,10 +202,17 @@ internal fun HomeScreen(
}
item { UnifestHorizontalDivider() }
item { Spacer(modifier = Modifier.height(20.dp)) }
item { IncomingFestivalText() }
item {
Text(
text = stringResource(id = R.string.home_incoming_festival_text),
modifier = Modifier.padding(start = 20.dp, bottom = 16.dp),
color = MaterialTheme.colorScheme.onBackground,
style = Title3,
)
}
if (homeUiState.incomingFestivals.isNotEmpty()) {
items(homeUiState.incomingFestivals) { festival ->
IncomingFestivalCard(festival)
IncomingFestivalCard(festival = festival)
Spacer(modifier = Modifier.height(8.dp))
}
}
Expand All @@ -246,202 +238,6 @@ internal fun HomeScreen(
}
}

@Composable
fun FestivalScheduleText(selectedDate: LocalDate) {
val formattedDate = DateTimeFormatter.ofPattern("M월 d일").format(selectedDate)
Text(
text = formattedDate + stringResource(id = R.string.home_festival_schedule_text),
modifier = Modifier.padding(start = 20.dp, top = 20.dp),
color = MaterialTheme.colorScheme.onBackground,
style = Title3,
)
}

@Composable
fun FestivalScheduleItem(
festival: FestivalTodayModel,
scheduleIndex: Int,
likedFestivals: ImmutableList<FestivalModel>,
selectedDate: LocalDate,
isStarImageClicked: ImmutableList<Boolean>,
isDataReady: Boolean,
onHomeUiAction: (HomeUiAction) -> Unit,
) {
Column {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 20.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Box(
modifier = Modifier
.width(3.dp)
.height(72.dp)
.background(if (isSystemInDarkTheme()) DarkBlueGreen else LightBlueGreen)
.align(Alignment.CenterVertically),
)
Spacer(modifier = Modifier.width(8.dp))
Column(
modifier = Modifier.width(172.dp),
) {
Text(
text = "${festival.beginDate.toLocalDate().formatWithDayOfWeek()} - ${festival.endDate.toLocalDate().formatWithDayOfWeek()}",
color = MaterialTheme.colorScheme.onSurfaceVariant,
style = Content4,
)
Spacer(modifier = Modifier.height(5.dp))
Row {
Text(
text = festival.festivalName + " Day ",
color = MaterialTheme.colorScheme.onBackground,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = Title2,
)
if (isDataReady) {
Text(
text = (ChronoUnit.DAYS.between(festival.beginDate.toLocalDate(), selectedDate) + 1).toString(),
color = MaterialTheme.colorScheme.onBackground,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = Title2,
)
}
}
Spacer(modifier = Modifier.height(7.dp))
Row {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_location_grey),
contentDescription = "Location Icon",
modifier = Modifier
.size(10.dp)
.align(Alignment.CenterVertically),
tint = Color.Unspecified,
)
Spacer(modifier = Modifier.width(5.dp))
Text(
text = festival.schoolName,
style = Content5,
color = MaterialTheme.colorScheme.onSecondary,
)
}
}
if (festival.starInfo.isNotEmpty()) {
LazyRow {
itemsIndexed(
items = festival.starInfo,
key = { _, starInfo -> starInfo.starId },
) { starIndex, starInfo ->
StarImage(
imgUrl = starInfo.imgUrl,
onClick = {
onHomeUiAction(HomeUiAction.OnToggleStarImageClick(scheduleIndex, starIndex, !isStarImageClicked[starIndex]))
},
onLongClick = {
onHomeUiAction(HomeUiAction.OnStarImageLongClick(scheduleIndex, starIndex))
},
isClicked = isStarImageClicked[starIndex],
label = starInfo.name,
modifier = Modifier
.size(72.dp)
.clip(CircleShape),
)
Spacer(modifier = Modifier.width(10.dp))
}
}
}
}
if (!likedFestivals.any { it.festivalId == festival.festivalId }) {
UnifestOutlinedButton(
onClick = {
onHomeUiAction(HomeUiAction.OnAddAsLikedFestivalClick(festival))
},
modifier = Modifier
.fillMaxWidth()
.height(48.dp)
.padding(top = 16.dp, start = 20.dp, end = 20.dp),
contentPadding = PaddingValues(6.dp),
) {
Text(
text = stringResource(id = R.string.home_add_interest_festival_in_item_button),
style = BoothLocation,
)
}
}
}
}

@Composable
fun IncomingFestivalText() {
Text(
text = stringResource(id = R.string.home_incoming_festival_text),
modifier = Modifier.padding(start = 20.dp, bottom = 16.dp),
color = MaterialTheme.colorScheme.onBackground,
style = Title3,
)
}

@Composable
fun IncomingFestivalCard(festival: FestivalModel) {
Card(
modifier = Modifier
.padding(horizontal = 20.dp)
.fillMaxWidth(),
shape = RoundedCornerShape(10.dp),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.onBackground),
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline),
) {
Row(
modifier = Modifier
.padding(20.dp)
.fillMaxSize(),
verticalAlignment = Alignment.CenterVertically,
) {
NetworkImage(
imgUrl = festival.thumbnail,
contentDescription = "Festival Thumbnail",
modifier = Modifier
.size(52.dp)
.clip(CircleShape),
)
Spacer(modifier = Modifier.width(10.dp))
Column(
modifier = Modifier.fillMaxWidth(),
) {
Text(
text = "${festival.beginDate.toLocalDate().formatWithDayOfWeek()} - ${festival.endDate.toLocalDate().formatWithDayOfWeek()}",
color = MaterialTheme.colorScheme.onSurfaceVariant,
style = Content6,
)
Spacer(modifier = Modifier.height(5.dp))
Text(
text = festival.festivalName,
color = MaterialTheme.colorScheme.onBackground,
style = Content4,
)
Spacer(modifier = Modifier.height(5.dp))
Row {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_location_grey),
contentDescription = "Location Icon",
modifier = Modifier
.size(10.dp)
.align(Alignment.CenterVertically),
tint = Color.Unspecified,
)
Spacer(modifier = Modifier.width(5.dp))
Text(
text = festival.schoolName,
style = Content6,
color = MaterialTheme.colorScheme.onSecondary,
)
}
}
}
}
}

@DevicePreview
@Composable
fun HomeScreenPreview() {
Expand Down
Loading