Skip to content

Commit

Permalink
Merge pull request #461 from BCSDLab/feature/bus-renewal
Browse files Browse the repository at this point in the history
[Feature] 대성, 시내버스 시간표 뷰
  • Loading branch information
ThirFir authored Nov 8, 2024
2 parents 662e7a9 + fd91a58 commit 4d6fd7c
Show file tree
Hide file tree
Showing 27 changed files with 923 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ fun TextChip(
Box(
modifier = modifier
.clip(shape)
.background(if(isSelected) chipColors.selectedContainerColor else chipColors.unselectedContainerColor)
.padding(contentPadding)
.then(
if (showClickRipple) Modifier.clickable {
onSelect()
} else Modifier.noRippleClickable {
onSelect()
}
),
)
.background(if(isSelected) chipColors.selectedContainerColor else chipColors.unselectedContainerColor)
.padding(contentPadding),
contentAlignment = Alignment.Center
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ class OnboardingManager @Inject internal constructor(
}
}

fun getShouldOnboardFlow(
type: OnboardingType
) = onboardingRepository.getShouldOnboardingFlow(type.name)

suspend fun getShouldOnboard(
type: OnboardingType,
) : Boolean {
return onboardingRepository.getShouldOnboarding(type.name)
}

suspend fun updateShouldOnboard(
type: OnboardingType,
shouldShow: Boolean
) {
onboardingRepository.updateShouldOnboarding(type.name, shouldShow)
}

fun dismissTooltip() {
if (::tooltip.isInitialized)
tooltip.dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.android.scopes.ActivityScoped
import dagger.hilt.components.SingletonComponent
import `in`.koreatech.koin.domain.repository.OnboardingRepository
import javax.inject.Singleton

@Module
@InstallIn(ActivityComponent::class)
@InstallIn(SingletonComponent::class)
object OnboardingModule {

@Provides
@ActivityScoped
@Singleton
fun provideOnboardingManager(
onboardingRepository: OnboardingRepository,
@ApplicationContext context: Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ enum class OnboardingType(
DINING_IMAGE(R.string.dining_image_tooltip),
DINING_NOTIFICATION(0),
DINING_SHARE(0),
ARTICLE_KEYWORD(R.string.article_keyword_tooltip)
ARTICLE_KEYWORD(R.string.article_keyword_tooltip),
SHOW_BUS_HEAD_ARTICLE(0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,33 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.android.scopes.ActivityScoped
import dagger.hilt.components.SingletonComponent
import `in`.koreatech.koin.data.repository.OnboardingRepositoryImpl
import `in`.koreatech.koin.data.source.local.OnboardingLocalDataSource
import `in`.koreatech.koin.domain.repository.OnboardingRepository
import javax.inject.Singleton

@Module
@InstallIn(ActivityComponent::class)
@InstallIn(SingletonComponent::class)
abstract class OnboardingRepositoryModule {

@Binds
@ActivityScoped
@Singleton
abstract fun bindOnboardingRepository(
onboardingRepositoryImpl: OnboardingRepositoryImpl
): OnboardingRepository
}

@Module
@InstallIn(ActivityComponent::class)
@InstallIn(SingletonComponent::class)
object OnboardingLocalDataSourceModule {

private val Context.onboardingDataStore: DataStore<Preferences> by preferencesDataStore(
name = "onboarding"
)

@Provides
@ActivityScoped
@Singleton
fun provideOnboardingManager(
@ApplicationContext context: Context
): OnboardingLocalDataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package `in`.koreatech.koin.data.repository

import `in`.koreatech.koin.data.source.local.OnboardingLocalDataSource
import `in`.koreatech.koin.domain.repository.OnboardingRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class OnboardingRepositoryImpl @Inject constructor(
Expand All @@ -15,4 +16,7 @@ class OnboardingRepositoryImpl @Inject constructor(
override suspend fun updateShouldOnboarding(onboardingType: String, shouldShow: Boolean) {
onboardingLocalDataSource.updateShouldOnboarding(onboardingType, shouldShow)
}

override fun getShouldOnboardingFlow(onboardingType: String): Flow<Boolean> =
onboardingLocalDataSource.getShouldOnboardingFlow(onboardingType)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ class OnboardingLocalDataSource @Inject constructor(
preferences[booleanPreferencesKey(onboardingType)] = shouldShow
}
}

fun getShouldOnboardingFlow(onboardingType: String) = dataStore.data.catch {
emit(emptyPreferences())
}.map { preferences ->
preferences[booleanPreferencesKey(onboardingType)] ?: true
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package `in`.koreatech.koin.domain.repository

import kotlinx.coroutines.flow.Flow

interface OnboardingRepository {
suspend fun getShouldOnboarding(onboardingType: String): Boolean
suspend fun updateShouldOnboarding(onboardingType: String, shouldShow: Boolean)
fun getShouldOnboardingFlow(onboardingType: String): Flow<Boolean>
}
2 changes: 2 additions & 0 deletions feature/bus/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.koin.hilt)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlinx.serialization)
id("kotlin-parcelize")
}

android {
Expand All @@ -20,6 +21,7 @@ android {
dependencies {
implementation(project(":core"))
implementation(project(":domain"))
implementation(project(":core:onboarding"))
implementation(project(":core:designsystem"))

implementation(libs.core.ktx)
Expand Down
10 changes: 5 additions & 5 deletions feature/bus/src/main/java/in/koreatech/bus/Bus2Activity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package `in`.koreatech.bus

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -13,19 +14,18 @@ import androidx.core.view.WindowInsetsCompat
import androidx.navigation.compose.rememberNavController
import dagger.hilt.android.AndroidEntryPoint
import `in`.koreatech.bus.navigation.BusNavigation
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme
import `in`.koreatech.koin.feature.bus.R

@AndroidEntryPoint
class Bus2Activity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_bus2)
findViewById<ComposeView>(R.id.compose_view_bus).setContent {
MaterialTheme {
setContent {
KoinTheme {
BusNavigation(
modifier = Modifier.fillMaxSize(),
navController = rememberNavController(),
modifier = Modifier.fillMaxSize()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ package `in`.koreatech.bus.navigation

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import `in`.koreatech.bus.screen.timetable.viewmodel.BusViewModel
import `in`.koreatech.bus.screen.timetable.composable.BusTimetableScreen

@Composable
fun BusNavigation(
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
viewModel: BusViewModel = hiltViewModel()
) {

NavHost(
Expand All @@ -30,7 +29,10 @@ fun BusNavigation(
) {

composable<Routes.BusTimetable> {

BusTimetableScreen(
modifier = Modifier.fillMaxSize(),
onNavigationIconClick = { navController.popBackStack() }
)
}
}
}
Loading

0 comments on commit 4d6fd7c

Please sign in to comment.