Skip to content

Commit

Permalink
๐Ÿ”— :: (#47) ์•Œ๋ฆผ ํŽ˜์ด์ง€ ํผ๋ธ”๋ฆฌ์‹ฑ
Browse files Browse the repository at this point in the history
๐Ÿ”— :: (#47) ์•Œ๋ฆผ ํŽ˜์ด์ง€ ํผ๋ธ”๋ฆฌ์‹ฑ
  • Loading branch information
rladmsdh authored Feb 6, 2024
2 parents a635bae + 90aed0f commit 8bef5c5
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 15 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
implementation(project(":feature:signin"))
implementation(project(":feature:signup"))
implementation(project(":feature:home"))
implementation(project(":feature:alarm"))

implementation(platform(libs.androidx.compose.bom))
implementation(libs.jobis.design.system)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package team.retum.jobisandroidv2.navigation

import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.navigation
import team.retum.alarm.navigation.alarm
import team.retum.jobisandroidv2.root.NAVIGATION_ROOT
import team.retum.jobisandroidv2.root.root

const val NAVIGATION_MAIN = "main"

fun NavGraphBuilder.mainNavigation() {
fun NavGraphBuilder.mainNavigation(navHostController: NavHostController) {
navigation(
route = NAVIGATION_MAIN,
startDestination = NAVIGATION_ROOT,
) {
root()
root(navHostController = navHostController)
alarm(onBackPressed = navHostController::popBackStack)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package team.retum.jobisandroidv2.root

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.composable

const val NAVIGATION_ROOT = "root"

fun NavGraphBuilder.root() {
fun NavGraphBuilder.root(navHostController: NavHostController) {
composable(NAVIGATION_ROOT) {
Root()
Root(navHostController = navHostController)
}
}

Expand Down
16 changes: 12 additions & 4 deletions app/src/main/java/team/retum/jobisandroidv2/root/RootScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,39 @@ package team.retum.jobisandroidv2.root
import android.annotation.SuppressLint
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import team.retum.alarm.navigation.navigateToAlarm
import team.retum.home.navigation.NAVIGATION_HOME
import team.retum.home.navigation.home
import team.retum.jobisandroidv2.ui.BottomNavigationBar

@Composable
fun Root() {
fun Root(navHostController: NavHostController) {
val navController = rememberNavController()

RootScreen(navController = navController)
RootScreen(
navController = navController,
navHostController = navHostController,
)
}

@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@Composable
private fun RootScreen(navController: NavHostController) {
private fun RootScreen(
navController: NavHostController,
navHostController: NavController,
) {
Scaffold(
bottomBar = { BottomNavigationBar(navController = navController) },
) {
NavHost(
navController = navController,
startDestination = NAVIGATION_HOME,
) {
home()
home(onAlarmClick = navHostController::navigateToAlarm)
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/team/retum/jobisandroidv2/ui/JobisApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ internal fun JobisApp() {
startDestination = NAVIGATION_AUTH,
) {
authNavigation(navController = navController)
mainNavigation()
mainNavigation(navHostController = navController)
}
}
Binary file added feature/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions feature/alarm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
20 changes: 20 additions & 0 deletions feature/alarm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id(libs.plugins.android.library.get().pluginId)
id(libs.plugins.kotlin.android.get().pluginId)
id(libs.plugins.hilt.android.get().pluginId)
id(libs.plugins.kotlin.kapt.get().pluginId)
}

apply<CommonGradlePlugin>()
apply<ComposeGradlePlugin>()

android {
namespace = "team.retum.alarm"
}

dependencies {

implementation(project(":core:common"))
implementation(project(":core:domain"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package team.retum.alarm

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.TestCase.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("team.retum.alarm.test", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package team.retum.alarm.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import team.retum.alarm.ui.Alarm

const val NAVIGATION_ALARM = "alarm"

fun NavGraphBuilder.alarm(onBackPressed: () -> Unit) {
composable(NAVIGATION_ALARM) {
Alarm(onBackPressed = onBackPressed)
}
}

fun NavController.navigateToAlarm() {
navigate(NAVIGATION_ALARM)
}
99 changes: 99 additions & 0 deletions feature/alarm/src/main/java/team/retum/alarm/ui/AlarmScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package team.retum.alarm.ui

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import team.retum.alarm.R
import team.returm.jobisdesignsystemv2.appbar.JobisSmallTopAppBar
import team.returm.jobisdesignsystemv2.foundation.JobisTheme
import team.returm.jobisdesignsystemv2.foundation.JobisTypography

// TODO ์„œ๋ฒ„ ์—ฐ๋™ ์‹œ ์ œ๊ฑฐ
private data class AlarmData(
val companyName: String,
val content: String,
val date: String,
)

@Composable
internal fun Alarm(
onBackPressed: () -> Unit,
) {
val alarmList = emptyList<AlarmData>()
AlarmScreen(
onBackPressed = onBackPressed,
alarmList = alarmList,
)
}

@Composable
private fun AlarmScreen(
onBackPressed: () -> Unit,
alarmList: List<AlarmData>,
) {
Column(
modifier = Modifier
.fillMaxSize()
.background(JobisTheme.colors.background)
.padding(horizontal = 24.dp),
) {
JobisSmallTopAppBar(
title = stringResource(id = R.string.alarm),
onBackPressed = onBackPressed,
)
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
) {
alarmList.forEach {
AlarmContent(
companyName = it.companyName,
content = it.content,
date = it.date,
)
}
}
}
}

@Composable
fun AlarmContent(
companyName: String,
content: String,
date: String,
) {
Column(
modifier = Modifier
.fillMaxHeight(0.14f)
.padding(vertical = 16.dp),
) {
Text(
text = companyName,
style = JobisTypography.Description,
color = JobisTheme.colors.onPrimary,
)
Text(
text = content,
style = JobisTypography.HeadLine,
color = JobisTheme.colors.onBackground,
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = date,
style = JobisTypography.Description,
color = JobisTheme.colors.onSurfaceVariant,
)
}
}
4 changes: 4 additions & 0 deletions feature/alarm/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="alarm">์•Œ๋ฆผ</string>
</resources>
16 changes: 16 additions & 0 deletions feature/alarm/src/test/java/team/retum/alarm/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package team.retum.alarm

import junit.framework.TestCase.assertEquals
import org.junit.Test

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import team.retum.home.ui.Home

const val NAVIGATION_HOME = "home"

fun NavGraphBuilder.home() {
fun NavGraphBuilder.home(onAlarmClick: () -> Unit) {
composable(NAVIGATION_HOME) {
Home()
Home(onAlarmClick = onAlarmClick)
}
}
6 changes: 4 additions & 2 deletions feature/home/src/main/java/team/retum/home/ui/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private data class ApplyCompany(

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun Home() {
fun Home(onAlarmClick: () -> Unit) {
val pagerState = rememberPagerState(INITIAL_PAGE) { MAX_PAGE }
val menus = listOf(
MenuItem(
Expand All @@ -93,6 +93,7 @@ fun Home() {
HomeScreen(
pagerState = pagerState,
menus = menus,
onAlarmClick = onAlarmClick,
)
}

Expand All @@ -101,6 +102,7 @@ fun Home() {
private fun HomeScreen(
pagerState: PagerState,
menus: List<MenuItem>,
onAlarmClick: () -> Unit,
) {
Column(
modifier = Modifier
Expand All @@ -112,7 +114,7 @@ private fun HomeScreen(
JobisIconButton(
painter = painterResource(JobisIcon.Bell),
contentDescription = "notification",
onClick = {},
onClick = onAlarmClick,
)
}
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fun NavGraphBuilder.landing(
onSignInClick: () -> Unit,
onSignUpClick: () -> Unit,
) {
composable(route = NAVIGATION_LANDING) {
composable(NAVIGATION_LANDING) {
Landing(
onSignInClick = onSignInClick,
onSignUpClick = onSignUpClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fun NavGraphBuilder.signIn(
onBackPressed: () -> Unit,
onSignInSuccess: () -> Unit,
) {
composable(route = NAVIGATION_SIGN_IN) {
composable(NAVIGATION_SIGN_IN) {
SignIn(
onBackClick = onBackPressed,
onSignInSuccess = onSignInSuccess,
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ include(":feature:landing")
include(":feature:signin")
include(":feature:signup")
include(":feature:home")
include(":feature:alarm")

0 comments on commit 8bef5c5

Please sign in to comment.