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 연결 및 로직 추가 #18

Merged
merged 30 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1c1b01a
feat: 생성 버튼 구현 #14
HyomK Jan 28, 2024
1eced75
feat: 반응형 프레임 구현 #14
HyomK Jan 28, 2024
7ef2c8a
feat: Anniversay list Item Component 구현 #14
HyomK Jan 28, 2024
fd7f9f0
feat: 상세화면 구현 #14
HyomK Jan 29, 2024
586fe52
feat: IconButton 구현 #14
HyomK Jan 29, 2024
6114b47
fix: DetailAnniversary 필드 추가 #14
HyomK Jan 29, 2024
bdce9f3
fix: 네비게이션 후 스크롤 오류 해결 #14
HyomK Jan 30, 2024
888ebd4
feat: text 추가 #14
HyomK Jan 31, 2024
c37873e
feat : 생성 & 수정 화면 추가 #14
HyomK Jan 31, 2024
89871e3
feat: baseUrl 추가 #15
HyomK Feb 3, 2024
2b58d94
fix: dateFormat 변경 #15
HyomK Feb 3, 2024
bb795ae
fix: Enum value 변경 #15
HyomK Feb 3, 2024
c4c2a50
feat: Service Module 추가 #15
HyomK Feb 3, 2024
cb2f6db
feat: RepositoryUsecaseModule 추가 #15
HyomK Feb 3, 2024
c76ce7a
move : 모듈 파일 분리 #15
HyomK Feb 3, 2024
8de5bf2
Merge remote-tracking branch 'origin/develop' into feature/api
HyomK Feb 3, 2024
e49ce04
feat: api 변경에 따른 model 변경 #16
HyomK Feb 4, 2024
b1e557b
feat: Detail 화면 분리 #16
HyomK Feb 4, 2024
75f63d3
feat: 수정페이지 argument 추가 #16
HyomK Feb 4, 2024
f2f95ac
feat: CardType 추가 #16
HyomK Feb 4, 2024
f7e9bce
feat: guide 추가 #16
HyomK Feb 4, 2024
edfbe06
feat: alert warning 추가 #16
HyomK Feb 4, 2024
10fd4d5
feat: deviceId 추가 변경 #16
HyomK Feb 4, 2024
7cf596e
Merge branch 'develop' into feature/api
HyomK Feb 4, 2024
9e429fd
improve: lint format #16
HyomK Feb 6, 2024
2050f06
chore: BASE_URL workflow 추가
HyomK Feb 6, 2024
1a978df
improve : lint format
HyomK Feb 6, 2024
b6abec6
fix: workflow string err
HyomK Feb 6, 2024
70b32c6
fix: requireApi 제거
HyomK Feb 6, 2024
82fb353
Merge branch 'feature/api' of https://github.com/Nexters/Don-t-Forget…
HyomK Feb 6, 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
8 changes: 8 additions & 0 deletions .github/workflows/ktlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ jobs:

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: BASE_URL
run: |
echo BASE_URL=$BASE_URL > local.properties
shell: bash
env:
API_KEY: ${{ secrets.BASE_URL }}


- name: Ktlint Check
run: ./gradlew --no-daemon ktlintCheck --continue
Expand Down
10 changes: 10 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
Expand All @@ -6,6 +8,8 @@ plugins {
id("com.google.gms.google-services")
}

val localProperties = gradleLocalProperties(rootDir)

android {
namespace = "nexters.hyomk.dontforget"
compileSdk = Apps.compileSdk
Expand All @@ -21,6 +25,8 @@ android {
vectorDrawables {
useSupportLibrary = true
}

buildConfigField("String", "BASE_URL", "\"${getProperty("BASE_URL")}\"")
}

buildTypes {
Expand Down Expand Up @@ -94,3 +100,7 @@ dependencies {
implementation("com.google.firebase:firebase-messaging-directboot:${Versions.fcm_direct}")
implementation("com.google.accompanist:accompanist-permissions:${Versions.permission}")
}

fun getProperty(propertyKey: String): String {
return gradleLocalProperties(rootDir).getProperty(propertyKey)
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Dont_forget"
android:usesCleartextTraffic="true"
tools:targetApi="31">

<meta-data
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/nexters/hyomk/dontforget/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package nexters.hyomk.dontforget

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@SuppressLint("CustomSplashScreen")
class SplashActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { true }
}
super.onCreate(savedInstanceState)
lifecycleScope.launch {
delay(1000)

val intent = Intent(this@SplashActivity, MainActivity::class.java)
startActivity(intent)
finish()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ package nexters.hyomk.dontforget.di.data

import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import nexters.hyomk.data.util.TokenManager
import nexters.hyomk.data.util.DeviceInfoManager
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
import javax.inject.Inject

class AuthInterceptor @Inject constructor(
private val tokenManager: TokenManager,
private val deviceInfoManager: DeviceInfoManager,
) : Interceptor {

override fun intercept(chain: Interceptor.Chain): Response {
val accessToken = runBlocking { tokenManager.getAccessToken().first() }
return if (accessToken.isNullOrBlank()) {
val deviceId = runBlocking { deviceInfoManager.getDeviceId().first() }
return if (deviceId.isNullOrBlank()) {
chain.proceed(chain.request())
} else {
val request = from(chain.request(), accessToken)
val request = from(chain.request(), deviceId)
chain.proceed(request)
}
}

companion object {
private const val AUTHORIZATION = "Authorization"
fun from(request: Request, accessToken: String): Request =
private const val DEVICE_ID = "deviceId"
fun from(request: Request, deviceId: String): Request =
request.newBuilder()
.removeHeader(AUTHORIZATION)
.addHeader(AUTHORIZATION, "Bearer $accessToken")
.removeHeader(DEVICE_ID)
.addHeader(DEVICE_ID, "$deviceId")
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import nexters.hyomk.data.util.TokenManager
import nexters.hyomk.data.util.DeviceInfoManager
import nexters.hyomk.dontforget.BuildConfig
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object HttpClientModule {

@Provides
@Singleton
fun provideLoggingHttpClient(tokenManager: TokenManager): OkHttpClient {
fun provideLoggingHttpClient(deviceInfoManager: DeviceInfoManager): OkHttpClient {
val builder = OkHttpClient.Builder()

builder.addInterceptor(
AuthInterceptor(tokenManager),
AuthInterceptor(deviceInfoManager),
)

if (BuildConfig.DEBUG) {
val loggingInterceptor = HttpLoggingInterceptor()
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
builder.addInterceptor(loggingInterceptor)
builder.addInterceptor(loggingInterceptor).connectTimeout(3, TimeUnit.SECONDS)
}

return builder.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import nexters.hyomk.dontforget.BuildConfig
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
Expand All @@ -12,7 +13,7 @@ import retrofit2.converter.scalars.ScalarsConverterFactory
@Module
@InstallIn(SingletonComponent::class)
object RetrofitModule {
private const val BASE_URL = ""
private const val BASE_URL = BuildConfig.BASE_URL

@Provides
fun provideRetrofit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ package nexters.hyomk.dontforget.navigation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.google.gson.Gson
import nexters.hyomk.domain.model.DetailAnniversary
import nexters.hyomk.dontforget.presentation.feature.create.CreateScreen
import nexters.hyomk.dontforget.presentation.feature.detail.DetailScreen
import nexters.hyomk.dontforget.presentation.feature.edit.EditScreen
import nexters.hyomk.dontforget.presentation.feature.home.HomeScreen
import nexters.hyomk.dontforget.presentation.feature.splash.SplashScreen
Expand All @@ -23,8 +28,35 @@ fun AppNavHost(
composable(NavigationItem.Splash.route) {
SplashScreen(navHostController = navController)
}
composable(
route = NavigationItem.Detail.route + "/{eventId}",
arguments = listOf(
navArgument("eventId") {
type = NavType.LongType
defaultValue = 0
},
),
) { navBackStackEntry ->
DetailScreen(navController, navBackStackEntry.arguments?.getLong("eventId") ?: 0)
}

composable(NavigationItem.Home.route) { HomeScreen(navController) }
composable(NavigationItem.Create.route) { CreateScreen(modifier, navController) }
composable(NavigationItem.Edit.route) { EditScreen() }
composable(
route = NavigationItem.Edit.route + "/{anniversary}",
arguments = listOf(
navArgument("anniversary") {
type = NavType.StringType
defaultValue = ""
},
),
) { navBackStackEntry ->
val anniversaryDataJson = navBackStackEntry.arguments?.getString("anniversary")
val anniversary = Gson().fromJson<DetailAnniversary>(anniversaryDataJson, DetailAnniversary::class.java)
EditScreen(
anniversary = anniversary,
navHostController = navController,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import nexters.hyomk.dontforget.ui.theme.Gray600
import nexters.hyomk.dontforget.ui.theme.Gray700
import nexters.hyomk.dontforget.ui.theme.Gray800
import nexters.hyomk.dontforget.ui.theme.Primary500
import nexters.hyomk.dontforget.ui.theme.Red500
import nexters.hyomk.dontforget.ui.theme.White

@Composable
Expand All @@ -33,22 +34,28 @@ fun BaseAlertDialog(
content: String,
left: String,
right: String,
isWarning: Boolean = false,
onClickLeft: () -> Unit,
onClickRight: () -> Unit,
) {
Column(
modifier = Modifier.background(
color = Gray700,
shape = RoundedCornerShape(12.dp),
).width(300.dp).clip(RoundedCornerShape(12.dp)),
modifier = Modifier
.background(
color = Gray700,
shape = RoundedCornerShape(12.dp),
)
.width(300.dp)
.clip(RoundedCornerShape(12.dp)),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Column(
modifier = Modifier.padding(vertical = 32.dp, horizontal = 20.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Box(
modifier = Modifier.size(56.dp).background(color = Gray500),
modifier = Modifier
.size(56.dp)
.background(color = Gray500),
)
Text(
modifier = Modifier.padding(vertical = 24.dp),
Expand All @@ -70,9 +77,12 @@ fun BaseAlertDialog(
) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.width(150.dp).height(51.dp).clickable {
onClickLeft()
},
modifier = Modifier
.width(150.dp)
.height(51.dp)
.clickable {
onClickLeft()
},
) {
Text(
text = left,
Expand All @@ -81,18 +91,25 @@ fun BaseAlertDialog(
}
Divider(
color = Gray800,
modifier = Modifier.height(51.dp).width(1.dp),
modifier = Modifier
.height(51.dp)
.width(1.dp),
)

Box(
contentAlignment = Alignment.Center,
modifier = Modifier.width(150.dp).height(51.dp).clickable {
onClickRight()
},
modifier = Modifier
.width(150.dp)
.height(51.dp)
.clickable {
onClickRight()
},
) {
Text(
text = right,
style = MaterialTheme.typography.bodySmall.copy(color = Primary500),
style = MaterialTheme.typography.bodySmall.copy(
color = if (isWarning) Red500 else Primary500,
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nexters.hyomk.dontforget.presentation.component.card
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -21,12 +22,17 @@ import androidx.compose.runtime.remember
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.graphicsLayer
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import nexters.hyomk.domain.model.AnniversaryCardType
import nexters.hyomk.domain.utils.toFormatString
import nexters.hyomk.dontforget.presentation.utils.conditional
import nexters.hyomk.dontforget.presentation.utils.createGradientBrush
import nexters.hyomk.dontforget.ui.theme.Gray700
import nexters.hyomk.dontforget.ui.theme.Gray900
import java.util.Calendar

Expand All @@ -50,19 +56,31 @@ fun AnniversaryCard(
onClick = onClick,
modifier = modifier
.background(Gray900)
.clip(RoundedCornerShape(16.dp))
.aspectRatio(ratio = 1f)
.graphicsLayer(
scaleX = scale.value,
scaleY = scale.value,
).border(
color = Gray700,
width = 1.dp,
shape = RoundedCornerShape(16.dp),
),
shape = RoundedCornerShape(16.dp),

) {
Image(
painter = painterResource(id = properties.background),
contentDescription = null,
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize()
.background(properties.backgroundColor)
.conditional(
properties.type == AnniversaryCardType.LUNAR,
) {
background(createGradientBrush(listOf(Color(0xFF181E23), Color(0xFF1E2830)), true))
}.clip(
shape = RoundedCornerShape(16.dp),
),
)
Column(
modifier.padding(end = 20.dp, start = 20.dp, bottom = 20.dp, top = 24.dp),
Expand All @@ -74,7 +92,7 @@ fun AnniversaryCard(
style = MaterialTheme.typography.headlineSmall.copy(color = properties.titleColor),
)
Text(
text = "D$dday",
text = if (dday == 365L) "D-DAY" else "D$dday",
modifier = Modifier.padding(top = 4.dp),
style = MaterialTheme.typography.titleMedium.copy(color = properties.dDayColor),
)
Expand All @@ -98,7 +116,7 @@ fun PreviewAnniversaryCard() {
calendar2.set(2024, 1, 24)

AnniversaryCard(
properties = ATypeCard(),
properties = BTypeCard(),
title = "생일이다",
)
}
Loading
Loading