generated from AND-SOPT-ANDROID/and-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from AND-SOPT-ANDROID/feat-week2
[WEEK2] 2주차 필수과제 구현
- Loading branch information
Showing
33 changed files
with
1,363 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/sopt/and/presentation/model/WaveBottomNavigationRoute.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.and.presentation.model | ||
|
||
sealed interface Route | ||
|
||
sealed interface WaveBottomNavigationRoute : Route { | ||
data object HOME : WaveBottomNavigationRoute | ||
data object SEARCH : WaveBottomNavigationRoute | ||
data object MY : WaveBottomNavigationRoute | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/org/sopt/and/presentation/type/WaveBottomNavigationType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.sopt.and.presentation.type | ||
|
||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import androidx.compose.runtime.Composable | ||
import org.sopt.and.R | ||
import org.sopt.and.presentation.model.Route | ||
import org.sopt.and.presentation.model.WaveBottomNavigationRoute | ||
|
||
enum class WaveBottomNavigationType( | ||
@DrawableRes val bnvIcon: Int, | ||
@StringRes val bnvText: Int, | ||
val route: WaveBottomNavigationRoute | ||
) { | ||
HOME( | ||
bnvIcon = R.drawable.ic_bnv_home_32, | ||
bnvText = R.string.bnv_home, | ||
route = WaveBottomNavigationRoute.HOME | ||
), | ||
SEARCH( | ||
bnvIcon = R.drawable.ic_bnv_search_32, | ||
bnvText = R.string.bnv_search, | ||
route = WaveBottomNavigationRoute.SEARCH | ||
), | ||
MY( | ||
bnvIcon = R.drawable.ic_bnv_my_32, | ||
bnvText = R.string.bnv_my, | ||
route = WaveBottomNavigationRoute.MY | ||
); | ||
|
||
companion object { | ||
@Composable | ||
fun find(bnvRoute: @Composable (WaveBottomNavigationRoute) -> Boolean): WaveBottomNavigationType? { | ||
return entries.firstOrNull { bnvRoute(it.route) } | ||
} | ||
|
||
@Composable | ||
fun contains(route: @Composable (Route) -> Boolean): Boolean { | ||
return entries.map { it.route }.any { route(it) } | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/sopt/and/presentation/ui/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.sopt.and.presentation.ui | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.enableEdgeToEdge | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import org.sopt.and.presentation.ui.navigator.WaveNavigator | ||
import org.sopt.and.presentation.ui.navigator.rememberWaveNavigator | ||
import org.sopt.and.ui.theme.ANDANDROIDTheme | ||
|
||
@AndroidEntryPoint | ||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
enableEdgeToEdge() | ||
setContent { | ||
val navigator: WaveNavigator = rememberWaveNavigator() | ||
|
||
ANDANDROIDTheme { | ||
MainScreen(navigator = navigator) | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/org/sopt/and/presentation/ui/MainScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.sopt.and.presentation.ui | ||
|
||
import androidx.compose.foundation.layout.navigationBarsPadding | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import org.sopt.and.presentation.type.WaveBottomNavigationType | ||
import org.sopt.and.presentation.ui.navigator.WaveBottomNavigation | ||
import org.sopt.and.presentation.ui.navigator.WaveNavHost | ||
import org.sopt.and.presentation.ui.navigator.WaveNavigator | ||
import org.sopt.and.presentation.ui.navigator.rememberWaveNavigator | ||
import org.sopt.and.ui.theme.ANDANDROIDTheme | ||
|
||
@Composable | ||
fun MainScreen( | ||
navigator: WaveNavigator = rememberWaveNavigator() | ||
) { | ||
Scaffold( | ||
content = { paddingValues -> | ||
WaveNavHost( | ||
navigator = navigator, | ||
paddingValues = paddingValues | ||
) | ||
}, | ||
bottomBar = { | ||
WaveBottomNavigation( | ||
isVisible = navigator.showBottomNavigation(), | ||
bottomNaviItems = WaveBottomNavigationType.entries.toList(), | ||
currentBottomNaviItem = navigator.currentWaveBottomNavigation, | ||
onClickBottomNavItem = { navigator.navigateToWaveBottomNavigation(it) }, | ||
modifier = Modifier.navigationBarsPadding() | ||
) | ||
} | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun MainPreview() { | ||
ANDANDROIDTheme { | ||
MainScreen() | ||
} | ||
} |
Oops, something went wrong.