Skip to content

Commit

Permalink
Merge pull request #23 from TeamTripmate/setting/navigator
Browse files Browse the repository at this point in the history
[setting] Splash,개인화 모듈 및 네비게이션 설정 및 리소스 추가
  • Loading branch information
wjdtkdgns777 authored Jul 25, 2024
2 parents 96e4bc0 + 63f00be commit 8f09163
Show file tree
Hide file tree
Showing 50 changed files with 854 additions and 5 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ dependencies {
projects.feature.home,
projects.feature.main,
projects.feature.menu,
projects.feature.navigator,
projects.feature.splash,
projects.feature.personalization,

libs.androidx.activity.compose,
libs.androidx.startup,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.tripmate.android.core.common.extension

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings

inline fun <reified T : Activity> Activity.startActivityWithAnimation(
withFinish: Boolean,
intentBuilder: Intent.() -> Intent = { this },
) {
startActivity(Intent(this, T::class.java).intentBuilder())
if (Build.VERSION.SDK_INT >= 34) {
overrideActivityTransition(
Activity.OVERRIDE_TRANSITION_OPEN,
android.R.anim.fade_in,
android.R.anim.fade_out,
)
} else {
@Suppress("DEPRECATION")
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
}
if (withFinish) finish()
}

fun Activity.goToAppSettings() {
Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null),
).also(::startActivity)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.tripmate.android.core.common.extension

import android.annotation.SuppressLint
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed

// https://stackoverflow.com/questions/66703448/how-to-disable-ripple-effect-when-clicking-in-jetpack-compose
@SuppressLint("ModifierFactoryUnreferencedReceiver")
inline fun Modifier.noRippleClickable(crossinline onClick: () -> Unit): Modifier = composed {
clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() },
) {
onClick()
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.tripmate.android.core.data.di

import com.tripmate.android.core.data.repository.PersonalizationRepository
import com.tripmate.android.core.data.repository.PersonalizationRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
internal abstract class RepositoryModule {

@Binds
@Singleton
abstract fun bindPersonalizationRepository(personalizationRepositoryImpl: PersonalizationRepositoryImpl): PersonalizationRepository
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.tripmate.android.core.data.repository

interface PersonalizationRepository {
suspend fun checkPersonalizationCompletion(): Boolean
suspend fun completePersonalization(flag: Boolean)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.tripmate.android.core.data.repository

import com.tripmate.android.core.datastore.PersonalizationDataSource
import javax.inject.Inject

internal class PersonalizationRepositoryImpl @Inject constructor(
private val personalizationDataSource: PersonalizationDataSource,
) : PersonalizationRepository {
override suspend fun checkPersonalizationCompletion(): Boolean {
return personalizationDataSource.checkPersonalizationCompletion()
}

override suspend fun completePersonalization(flag: Boolean) {
personalizationDataSource.completePersonalization(flag)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.tripmate.android.core.datastore

interface PersonalizationDataSource {
suspend fun checkPersonalizationCompletion(): Boolean
suspend fun completePersonalization(flag: Boolean)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.tripmate.android.core.datastore

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.emptyPreferences
import com.tripmate.android.core.datastore.di.PersonalizationDataStore
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.first
import java.io.IOException
import javax.inject.Inject

class PersonalizationDataSourceImpl @Inject constructor(
@PersonalizationDataStore private val dataStore: DataStore<Preferences>,
) : PersonalizationDataSource {
private companion object {
private val KEY_PERSONALIZATION_COMPLETE = booleanPreferencesKey("Personalization_complete")
}

override suspend fun checkPersonalizationCompletion(): Boolean = dataStore.data
.catch { exception ->
if (exception is IOException) emit(emptyPreferences())
else throw exception
}.first()[KEY_PERSONALIZATION_COMPLETE] ?: false

override suspend fun completePersonalization(flag: Boolean) {
dataStore.edit { preferences -> preferences[KEY_PERSONALIZATION_COMPLETE] = flag }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tripmate.android.core.datastore.di

import com.tripmate.android.core.datastore.PersonalizationDataSource
import com.tripmate.android.core.datastore.PersonalizationDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class DataSourceModule {
@Binds
@Singleton
abstract fun bindPersonalizationDataSource(personalizationDataSourceImpl: PersonalizationDataSourceImpl): PersonalizationDataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.tripmate.android.core.datastore.di

import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.preferencesDataStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

private const val PERSONALIZATION_DATASTORE = "personalization_datastore"
private val Context.personalizationDataStore: DataStore<Preferences> by preferencesDataStore(name = PERSONALIZATION_DATASTORE)

@Module
@InstallIn(SingletonComponent::class)
internal object DataStoreModule {

@PersonalizationDataStore
@Singleton
@Provides
internal fun providePersonalizationDataStore(@ApplicationContext context: Context) = context.personalizationDataStore
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.tripmate.android.core.datastore.di

import javax.inject.Qualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class PersonalizationDataStore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.tripmate.android.core.designsystem

import androidx.compose.ui.tooling.preview.Preview

@Preview(showBackground = true)
annotation class ComponentPreview
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.tripmate.android.core.designsystem.component

import androidx.compose.foundation.layout.Box
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.tripmate.android.core.common.extension.noRippleClickable
import com.tripmate.android.core.designsystem.ComponentPreview
import com.tripmate.android.core.designsystem.theme.Primary01
import com.tripmate.android.core.designsystem.theme.TripmateTheme

@Composable
fun LoadingWheel(
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier.noRippleClickable { },
contentAlignment = Alignment.Center,
) {
CircularProgressIndicator(color = Primary01)
}
}

@ComponentPreview
@Composable
fun LoadingWheelPreview() {
TripmateTheme {
LoadingWheel()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.tripmate.android.core.designsystem.theme

import androidx.compose.ui.graphics.Color

// Light mode colors
val Primary01 = Color(0xFF0B57D0)
val Primary02 = Color(0xFF1742A6)
val Primary03 = Color(0xFF1A73E8)

val Background01 = Color(0xFFF3F6FC)
val Background02 = Color(0xFFFFFFFF)
val Background03 = Color(0xFFD3E3FD)

// Dark mode colors
val Primary01Dark = Color(0xFFA8C7FA)
val Primary02Dark = Color(0xFFD2E3FC)
val Primary03Dark = Color(0xFF8AB4F8)

val Background01Dark = Color(0xFF222327)
val Background02Dark = Color(0xFF18191B)
val Background03Dark = Color(0xFF2A2A2A)

// Light mode gray scale
val Gray001 = Color(0xFF1F1F1F)
val Gray002 = Color(0xFF3C4043)
val Gray003 = Color(0xFF5F6368)
val Gray004 = Color(0xFF6F7277)
val Gray005 = Color(0xFF83878B)
val Gray006 = Color(0xFF989BA0)
val Gray007 = Color(0xFFA9ADB1)
val Gray008 = Color(0xFFC4C7CA)
val Gray009 = Color(0xFFF5F5F5)

// Dark mode gray scale
val Gray001Dark = Color(0xFFE2E2E2)
val Gray002Dark = Color(0xFFCDCDCD)
val Gray003Dark = Color(0xFFBFBFBF)
val Gray004Dark = Color(0xFFA0A0A0)
val Gray005Dark = Color(0xFF8C8C8C)
val Gray006Dark = Color(0xFF77797C)
val Gray007Dark = Color(0xFF5E5F63)
val Gray008Dark = Color(0xFF3A3B3F)
val Gray009Dark = Color(0xFF2A2A2A)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.tripmate.android.core.designsystem.theme

import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.tripmate.android.core.designsystem.R

val pretendardFamily = FontFamily(
Font(R.font.pretendard_bold, FontWeight.Bold, FontStyle.Normal),
Font(R.font.pretendard_regular, FontWeight.Normal, FontStyle.Normal),
Font(R.font.pretendard_light, FontWeight.Light, FontStyle.Normal),
)

val Title0 = TextStyle(
fontFamily = pretendardFamily,
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.tripmate.android.core.designsystem.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable

private val DarkColorScheme = darkColorScheme(
primary = Primary01Dark,
secondary = Primary02Dark,
tertiary = Primary03Dark,
background = Background01Dark,
surface = Background02Dark,
onPrimary = Gray009Dark,
onSecondary = Gray009Dark,
onTertiary = Gray009Dark,
onBackground = Gray001Dark,
onSurface = Gray001Dark,
)

private val LightColorScheme = lightColorScheme(
primary = Primary01,
secondary = Primary02,
tertiary = Primary03,
background = Background01,
surface = Background02,
onPrimary = Gray009,
onSecondary = Gray009,
onTertiary = Gray009,
onBackground = Gray001,
onSurface = Gray001,
)

@Composable
fun TripmateTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit,
) {
val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tripmate.android.core.designsystem.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp,
),
)
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions core/designsystem/src/main/res/values/splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.Tripmate.Splash" parent="Theme.SplashScreen">
<item name="postSplashScreenTheme">@style/Theme.Tripmateandroid</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="android:windowLightStatusBar">true</item>
</style>

</resources>
1 change: 1 addition & 0 deletions feature/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {
implementations(
projects.feature.home,
projects.feature.menu,
projects.feature.navigator,

libs.androidx.activity.compose,
libs.kotlinx.collections.immutable,
Expand Down
Loading

0 comments on commit 8f09163

Please sign in to comment.