Skip to content

Commit

Permalink
Merge pull request #5 from AND-SOPT-ANDROID/feat-week2
Browse files Browse the repository at this point in the history
[WEEK2] 2주차 필수과제 구현
  • Loading branch information
HAJIEUN02 authored Oct 31, 2024
2 parents 90ae8de + 34bdb6a commit c20ce9d
Show file tree
Hide file tree
Showing 33 changed files with 1,363 additions and 426 deletions.
8 changes: 8 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ dependencies {
// Hilt
implementation(libs.hilt)
kapt(libs.hilt.compiler)
implementation(libs.androidx.hilt.navigation)

// Timber
implementation(libs.timber)

// Navigation
implementation(libs.androidx.navigation)

// Coil
implementation(libs.coil3.compose)
implementation(libs.coil3.network)
}
17 changes: 5 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name=".WaveApp"
android:allowBackup="true"
Expand All @@ -14,23 +17,13 @@
android:theme="@style/Theme.ANDANDROID"
tools:targetApi="31">
<activity
android:name=".presentation.ui.auth.login.LoginActivity"
android:exported="true"
android:theme="@style/Theme.ANDANDROID">
android:name=".presentation.ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".presentation.ui.auth.register.RegisterActivity"
android:exported="false" />
<activity
android:name=".presentation.ui.my.MyActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="false" />
</application>
</manifest>
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
}
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 app/src/main/java/org/sopt/and/presentation/ui/MainActivity.kt
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 app/src/main/java/org/sopt/and/presentation/ui/MainScreen.kt
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()
}
}
Loading

0 comments on commit c20ce9d

Please sign in to comment.