Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation(project(":core:designsystem"))

implementation(libs.androidx.activity.compose)
implementation(libs.androidx.fragment.ktx)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphics)
Expand Down
46 changes: 46 additions & 0 deletions app/src/main/kotlin/com/giwon/aide/navigation/AideBottomBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.giwon.aide.navigation

import androidx.compose.material3.Icon
import androidx.compose.material3.ShortNavigationBar
import androidx.compose.material3.ShortNavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.giwon.aide.core.designsystem.theme.AideAndroidTheme

@Composable
fun AideBottomBar(
currentTab: TopLevelDestination,
onTabClick: (destination: TopLevelDestination) -> Unit,
) {
ShortNavigationBar(modifier = Modifier.shadow(elevation = 8.dp)) {
TopLevelDestination.entries.forEach { destination ->
ShortNavigationBarItem(
selected = destination == currentTab,
onClick = { onTabClick(destination) },
icon = {
Icon(
painterResource(destination.icon),
contentDescription = null
)
},
label = { Text(destination.label) },
)
}
}
}

@Preview
@Composable
private fun AideBottomBarPreview() {
AideAndroidTheme {
AideBottomBar(
currentTab = TopLevelDestination.HOME,
onTabClick = {}
)
}
}
44 changes: 16 additions & 28 deletions app/src/main/kotlin/com/giwon/aide/navigation/AideNavDisplay.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package com.giwon.aide.navigation

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.lifecycle.viewmodel.navigation3.rememberViewModelStoreNavEntryDecorator
import androidx.navigation3.runtime.entryProvider
import androidx.navigation3.runtime.rememberNavBackStack
Expand All @@ -18,35 +13,28 @@ import com.giwon.aide.feature.calendar.navigation.calendarEntry
import com.giwon.aide.feature.home.navigation.HomeKey
import com.giwon.aide.feature.home.navigation.homeEntry
import com.giwon.aide.feature.settings.navigation.settingsEntry
import kotlin.collections.listOf

@Composable
fun AideApp() {
val backStack = rememberNavBackStack(HomeKey)
val currentTab =
fun AideApp(startTab: TopLevelDestination = TopLevelDestination.HOME) {
val backStack = rememberNavBackStack(
*TopLevelDestination.entries
.filter { destination -> destination == TopLevelDestination.HOME || destination == startTab }
.map { destination -> destination.key }
.toTypedArray()
)
val currentTab: TopLevelDestination =
TopLevelDestination.entries.last { destination -> destination.key in backStack }

Scaffold(
bottomBar = {
NavigationBar {
TopLevelDestination.entries.forEach { destination ->
NavigationBarItem(
selected = destination == currentTab,
onClick = {
backStack.clear()
backStack.add(HomeKey)
if (destination.key != HomeKey) backStack.add(destination.key)
},
icon = {
Icon(
painterResource(destination.icon),
contentDescription = null
)
},
label = { Text(destination.label) },
)
AideBottomBar(
currentTab = currentTab,
onTabClick = { destination ->
backStack.clear()
backStack.add(HomeKey)
if (destination.key != HomeKey) backStack.add(destination.key)
}
}
)
}
) { innerPadding ->
NavDisplay(
Expand All @@ -61,7 +49,7 @@ fun AideApp() {
homeEntry()
calendarEntry()
settingsEntry()
}
},
)
}
}
32 changes: 26 additions & 6 deletions app/src/main/kotlin/com/giwon/aide/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package com.giwon.aide.ui

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.tooling.preview.Preview
import androidx.fragment.app.FragmentActivity
import androidx.navigationevent.compose.LocalNavigationEventDispatcherOwner
import androidx.navigationevent.compose.rememberNavigationEventDispatcherOwner
import com.giwon.aide.core.designsystem.theme.AideAndroidTheme
import com.giwon.aide.navigation.AideApp
import com.giwon.aide.navigation.TopLevelDestination
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
class MainActivity : FragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
Expand All @@ -23,10 +27,26 @@ class MainActivity : ComponentActivity() {
}
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
AideAndroidTheme {
AideApp()
private fun AideAppPreview(startTab: TopLevelDestination) {
CompositionLocalProvider(
LocalNavigationEventDispatcherOwner provides rememberNavigationEventDispatcherOwner(parent = null)
) {
AideAndroidTheme {
AideApp(startTab = startTab)
}
}
}

@Preview(showBackground = true, showSystemUi = true)
@Composable
private fun HomePreview() {
AideAppPreview(startTab = TopLevelDestination.HOME)
}


@Preview(showBackground = true, showSystemUi = true)
@Composable
private fun SettingsPreview() {
AideAppPreview(startTab = TopLevelDestination.SETTINGS)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ScreenConventionTest {

scope.classes()
.filter { it.name.endsWith("ViewModel") }
.filterNot { it.packagee?.name?.startsWith("com.giwon.aide.feature.calendar.scheduler") == true }
.assertTrue { viewModel ->
val expected =
viewModel.packagee?.name + "." + viewModel.name.removeSuffix("ViewModel") + "UiState"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ interface CalendarDataSource {
suspend fun queryInstances(from: Instant, to: Instant, calendarIds: Set<Long>): List<Event>
suspend fun findInstance(eventId: Long, start: Instant): Event?
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import javax.inject.Inject
internal class VisibleCalendarStore @Inject constructor(
private val dataStore: DataStore<Preferences>,
) {
/** 한 번도 고르지 않았으면 null */
val calendarIds: Flow<Set<Long>?> = dataStore.data.map { preferences ->
preferences[VISIBLE_CALENDAR_IDS]?.map(String::toLong)?.toSet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package com.giwon.aide.core.designsystem.theme

import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext

private val DarkColorScheme = darkColorScheme(
Expand Down Expand Up @@ -42,11 +44,11 @@ fun AideAndroidTheme(
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context).withWhiteBackground()
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
else -> LightColorScheme.withWhiteBackground()
}

MaterialTheme(
Expand All @@ -55,3 +57,6 @@ fun AideAndroidTheme(
content = content
)
}

private fun ColorScheme.withWhiteBackground(): ColorScheme =
copy(background = Color.White, surfaceContainer = Color.White)
16 changes: 16 additions & 0 deletions feature/calendar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@ plugins {

android {
namespace = "com.giwon.aide.feature.calendar"

buildFeatures {
viewBinding = true
}
}

dependencies {
implementation(libs.androidx.fragment.ktx)
implementation(libs.androidx.fragment.compose)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.google.material)
implementation(libs.timber)

testImplementation(libs.androidx.arch.core.testing)
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package com.giwon.aide.feature.calendar

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.fragment.compose.AndroidFragment
import com.giwon.aide.feature.calendar.scheduler.calendar.CalendarFragment

@Composable
fun CalendarRoute() {
CalendarScreen()
AndroidFragment<CalendarFragment>(modifier = Modifier.fillMaxSize())
}

@Composable
internal fun CalendarScreen(modifier: Modifier = Modifier) {
Box(modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text("캘린더")
}
}

Loading
Loading