Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/connect navigation #518

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ dependencies {
implementation project(":feature:danggn")
implementation project(":feature:myPage")
implementation project(":feature:moreMenu")
implementation project(':feature:moreMenu:notice')

// ml Kit
implementation "com.google.mlkit:barcode-scanning:$barcodeSacnnerVersion"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
tools:ignore="LockedOrientationActivity" />

<activity
android:name="com.example.moremenu.MoreMenuActivity"
android:name=".ui.moremenu.MoreMenuActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand Down
72 changes: 72 additions & 0 deletions app/src/main/java/com/mashup/ui/moremenu/MoreMenuActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.mashup.ui.moremenu

import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.example.moremenu.MoreMenuRoute
import com.example.moremenu.model.Menu
import com.example.moremenu.model.MenuType
import com.example.moremenu.model.MoreMenuSideEffect
import com.example.notice.NoticeActivity
import com.mashup.core.ui.theme.MashUpTheme
import com.mashup.ui.danggn.ShakeDanggnActivity
import com.mashup.ui.setting.SettingActivity
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
class MoreMenuActivity : ComponentActivity() {

private val moreMenuViewModel: MoreMenuViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
moreMenuViewModel.moreMenuEvent.collect { sideEffect ->
when (sideEffect) {
is MoreMenuSideEffect.NavigateMenu -> onNavigateMenu(sideEffect.menu)
is MoreMenuSideEffect.NavigateBackStack -> finish()
}
}
}
}
setContent {
MashUpTheme {
val moreMenuState by moreMenuViewModel.moreMenuState.collectAsState()
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
MoreMenuRoute(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding),
moreMenuState = moreMenuState,
onBackPressed = moreMenuViewModel::onClickBackButton,
onClickMenu = moreMenuViewModel::onClickMenuButton
)
}
}
}
}

private fun onNavigateMenu(menu: Menu) {
val intent = when (menu.type) {
MenuType.NOTI -> Intent(this, NoticeActivity::class.java)
MenuType.DANGGN -> Intent(this, ShakeDanggnActivity::class.java)
MenuType.MASHONG -> Intent(this, NoticeActivity::class.java)
MenuType.SETTING -> Intent(this, SettingActivity::class.java)
MenuType.BIRTHDAY -> Intent(this, NoticeActivity::class.java)
}
startActivity(intent)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.moremenu
package com.mashup.ui.moremenu

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import com.example.moremenu.MoreMenuActivity
import com.mashup.R
import com.mashup.base.BaseFragment
import com.mashup.core.common.extensions.setStatusBarColorRes
import com.mashup.core.ui.theme.MashUpTheme
import com.mashup.databinding.FragmentScheduleBinding
import com.mashup.ui.main.MainViewModel
import com.mashup.ui.moremenu.MoreMenuActivity
import dagger.hilt.android.AndroidEntryPoint
import com.mashup.core.common.R as CR

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,30 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Divider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.moremenu.components.MoreMenuItem
import com.example.moremenu.model.Menu
import com.example.moremenu.model.MoreMenuSideEffect
import com.example.moremenu.model.MoreMenuState
import com.mashup.core.ui.colors.Gray100
import com.mashup.core.ui.theme.MashUpTheme
import com.mashup.core.ui.widget.MashUpToolbar

@Composable
fun MoreMenuRoute(
moreMenuViewModel: MoreMenuViewModel,
moreMenuState: MoreMenuState,
modifier: Modifier = Modifier,
onNavigateBackStack: () -> Unit = {},
onNavigateMenu: (Menu) -> Unit = {}
onBackPressed: () -> Unit = {},
onClickMenu: (Menu) -> Unit = {}
) {
val moreMenuState by moreMenuViewModel.moreMenuState.collectAsState()
LaunchedEffect(Unit) {
moreMenuViewModel.moreMenuEvent.collect { sideEffect ->
when (sideEffect) {
is MoreMenuSideEffect.NavigateMenu -> onNavigateMenu(sideEffect.menu)

is MoreMenuSideEffect.NavigateBackStack -> onNavigateBackStack()
}
}
}
MoreMenuScreen(
modifier = modifier,
moreMenuState = moreMenuState,
onClickMenu = moreMenuViewModel::onClickMenuButton,
onBackPressed = moreMenuViewModel::onClickBackButton
onClickMenu = onClickMenu,
onBackPressed = onBackPressed
)
}

Expand All @@ -60,7 +47,7 @@ fun MoreMenuScreen(
modifier = Modifier.fillMaxWidth(),
title = "더 보기",
showBackButton = true,
onClickBackButton = { onBackPressed() }
onClickBackButton = onBackPressed
)
}
items(moreMenuState.menus) { menu ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.Divider
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down
Loading