Skip to content

Commit a9aec30

Browse files
authored
Merge pull request #87 from LanPet-dev/develop
Develop
2 parents 4cc5891 + 6771179 commit a9aec30

60 files changed

Lines changed: 2069 additions & 349 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/auth/src/main/java/com/lanpet/core/auth/AuthManager.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ open class AuthManager
9292
AuthState.Success(
9393
socialAuthToken = socialAuthToken,
9494
account = account,
95-
profile = profiles,
95+
profile = profiles.toHashSet(),
9696
defaultProfile = defaultProfile,
9797
profileDetail = detail,
9898
navigationHandleFlag = true,
@@ -139,7 +139,7 @@ open class AuthManager
139139
socialAuthToken = socialAuthToken,
140140
account = account,
141141
navigationHandleFlag = true,
142-
profile = emptyList(),
142+
profile = emptySet(),
143143
),
144144
)
145145
}
@@ -158,7 +158,7 @@ open class AuthManager
158158
AuthState.Success(
159159
socialAuthToken = socialAuthToken,
160160
account = account,
161-
profile = profile,
161+
profile = profile.toHashSet(),
162162
defaultProfile = defaultProfile,
163163
profileDetail = detail,
164164
navigationHandleFlag = true,
@@ -267,7 +267,7 @@ open class AuthManager
267267
AuthState.Success(
268268
socialAuthToken = socialAuthToken,
269269
account = account,
270-
profile = profile,
270+
profile = profile.toHashSet(),
271271
defaultProfile = defaultProfile,
272272
profileDetail = detail,
273273
navigationHandleFlag = false,
@@ -330,7 +330,7 @@ open class AuthManager
330330
AuthState.Success(
331331
socialAuthToken = currentAuthState.socialAuthToken,
332332
account = currentAuthState.account,
333-
profile = res,
333+
profile = res.toHashSet(),
334334
defaultProfile = defaultProfile,
335335
profileDetail = detail,
336336
navigationHandleFlag = false,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.lanpet.core.common
2+
3+
import androidx.lifecycle.ViewModel
4+
import androidx.lifecycle.viewModelScope
5+
import kotlinx.coroutines.CoroutineStart
6+
import kotlinx.coroutines.launch
7+
import kotlinx.coroutines.sync.Mutex
8+
import kotlinx.coroutines.sync.withLock
9+
import kotlin.coroutines.CoroutineContext
10+
import kotlin.coroutines.EmptyCoroutineContext
11+
12+
fun ViewModel.mutexLockScope(
13+
mutex: Mutex,
14+
context: CoroutineContext = EmptyCoroutineContext,
15+
start: CoroutineStart = CoroutineStart.DEFAULT,
16+
block: suspend () -> Unit,
17+
) {
18+
viewModelScope.launch(context, start) {
19+
try {
20+
mutex.withLock {
21+
block()
22+
}
23+
} catch (e: Exception) {
24+
mutex.unlock()
25+
throw e
26+
}
27+
}
28+
}

core/common/src/main/java/com/lanpet/core/common/widget/IosActionSheet.kt

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.height
99
import androidx.compose.foundation.layout.padding
1010
import androidx.compose.foundation.shape.RoundedCornerShape
1111
import androidx.compose.material3.ButtonColors
12-
import androidx.compose.material3.Divider
12+
import androidx.compose.material3.HorizontalDivider
1313
import androidx.compose.material3.Surface
1414
import androidx.compose.material3.Text
1515
import androidx.compose.material3.TextButton
@@ -62,8 +62,15 @@ fun IOSActionSheet(
6262
@Composable
6363
fun ActionButton(
6464
text: String,
65-
onClick: () -> Unit,
6665
modifier: Modifier = Modifier,
66+
buttonColors: ButtonColors =
67+
ButtonColors(
68+
contentColor = GrayColor.Gray950,
69+
containerColor = WhiteColor.White,
70+
disabledContainerColor = GrayColor.Gray950,
71+
disabledContentColor = WhiteColor.White,
72+
),
73+
onClick: () -> Unit = {},
6774
) {
6875
Surface {
6976
TextButton(
@@ -73,13 +80,7 @@ fun ActionButton(
7380
Modifier
7481
.fillMaxWidth()
7582
.height(64.dp),
76-
colors =
77-
ButtonColors(
78-
contentColor = GrayColor.Gray950,
79-
containerColor = WhiteColor.White,
80-
disabledContainerColor = GrayColor.Gray950,
81-
disabledContentColor = WhiteColor.White,
82-
),
83+
colors = buttonColors,
8384
) {
8485
Text(text, fontSize = 20.sp)
8586
}
@@ -94,8 +95,16 @@ private fun IOSActionSheetPreview() {
9495
content = {
9596
Column {
9697
ActionButton(text = "사진 촬영", onClick = { /* */ })
97-
Divider(color = Color.LightGray, thickness = 0.5.dp)
98+
HorizontalDivider(color = Color.LightGray, thickness = 1.dp)
9899
ActionButton(text = "사진 앨범", onClick = { /* */ })
100+
HorizontalDivider(color = Color.LightGray, thickness = 1.dp)
101+
ActionButton(text = "버튼", buttonColors =
102+
ButtonColors(
103+
contentColor = Color.Red,
104+
containerColor = WhiteColor.White,
105+
disabledContainerColor = GrayColor.Gray950,
106+
disabledContentColor = WhiteColor.White,
107+
),onClick = { /* */ })
99108
}
100109
},
101110
cancelButton = {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.lanpet.core.common.widget
2+
3+
import androidx.compose.foundation.layout.Box
4+
import androidx.compose.foundation.layout.fillMaxSize
5+
import androidx.compose.foundation.layout.size
6+
import androidx.compose.material3.CircularProgressIndicator
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.Alignment
9+
import androidx.compose.ui.Modifier
10+
import androidx.compose.ui.unit.dp
11+
12+
@Composable
13+
fun LoadingView(modifier: Modifier = Modifier) {
14+
Box(
15+
modifier = modifier.fillMaxSize(),
16+
contentAlignment = Alignment.Center,
17+
) {
18+
CircularProgressIndicator(
19+
modifier =
20+
Modifier
21+
.size(36.dp),
22+
)
23+
}
24+
}

core/common/src/main/java/com/lanpet/core/common/widget/PreparingScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fun PreparingScreen(
7171
)
7272

7373
BoxWithConstraints(
74-
modifier = Modifier.fillMaxSize(),
74+
modifier = modifier.fillMaxSize(),
7575
) {
7676
Box(
7777
modifier =
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.lanpet.core.di
2+
3+
import com.lanpet.data.dto.mapper.ButlerDtoToDomainButlerMapper
4+
import com.lanpet.data.dto.mapper.DefaultMapperRegistry
5+
import com.lanpet.data.dto.mapper.DomainButlerToButlerDtoMapper
6+
import com.lanpet.data.dto.mapper.DomainPetToPetDtoMapper
7+
import com.lanpet.data.dto.mapper.MapperRegistry
8+
import com.lanpet.data.dto.mapper.PetDtoToDomainPetMapper
9+
import dagger.Module
10+
import dagger.Provides
11+
import dagger.hilt.InstallIn
12+
import dagger.hilt.components.SingletonComponent
13+
import javax.inject.Singleton
14+
15+
@Module
16+
@InstallIn(SingletonComponent::class)
17+
object DataModule {
18+
@Singleton
19+
@Provides
20+
fun provideMapperRegistry(): MapperRegistry =
21+
DefaultMapperRegistry().apply {
22+
register(PetDtoToDomainPetMapper())
23+
register(DomainPetToPetDtoMapper())
24+
register(ButlerDtoToDomainButlerMapper())
25+
register(DomainButlerToButlerDtoMapper())
26+
}
27+
}

core/di/src/main/java/com/lanpet/core/di/RepositoryModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lanpet.core.di
22

3+
import com.lanpet.data.dto.mapper.MapperRegistry
34
import com.lanpet.data.repository.AccountRepositoryImpl
45
import com.lanpet.data.repository.FreeBoardRepositoryImpl
56
import com.lanpet.data.repository.ProfileRepositoryImpl
@@ -41,10 +42,12 @@ class RepositoryModule {
4142
fun provideProfileRepository(
4243
profileService: ProfileApiService,
4344
authDatabase: AuthDatabase,
45+
mapperRegistry: MapperRegistry,
4446
): ProfileRepository =
4547
ProfileRepositoryImpl(
4648
profileService,
4749
authDatabase,
50+
mapperRegistry,
4851
)
4952

5053
@Singleton

core/navigation/src/main/java/com/lanpet/core/navigation/AppNavigation.kt

Lines changed: 70 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import androidx.navigation.compose.NavHost
2323
import androidx.navigation.compose.currentBackStackEntryAsState
2424
import androidx.navigation.compose.navigation
2525
import androidx.navigation.compose.rememberNavController
26+
import androidx.navigation.navOptions
2627
import com.lanpet.core.auth.LocalAuthManager
2728
import com.lanpet.core.common.widget.BottomNavItem
2829
import com.lanpet.core.common.widget.LanPetBottomNavBar
@@ -40,6 +41,7 @@ import com.lanpet.feature.settings.navigation.settingsNavGraph
4041
import com.lanpet.free.navigation.FreeBoard
4142
import com.lanpet.free.navigation.freeNavGraph
4243
import com.lanpet.free.navigation.navigateToFreeBoardBaseRoute
44+
import com.lanpet.free.navigation.navigateToFreeBoardCommentDetailScreen
4345
import com.lanpet.free.navigation.navigateToFreeBoardDetailScreen
4446
import com.lanpet.free.navigation.navigateToFreeBoardWriteScreen
4547
import com.lanpet.myprofile.navigation.MyProfile
@@ -90,55 +92,6 @@ fun AppNavigation(modifier: Modifier = Modifier) {
9092
mutableStateOf(BottomNavItem.Wiki)
9193
}
9294

93-
LaunchedEffect(navBackStackEntry?.destination?.route) {
94-
// 현재 화면이 BottomNav를 표시해야 하는지 확인
95-
shouldShowBottomBar =
96-
when (navBackStackEntry?.destination?.route) {
97-
Wiki.toString() -> {
98-
navItem = BottomNavItem.Wiki
99-
true
100-
}
101-
102-
FreeBoard.toString() -> {
103-
navItem = BottomNavItem.Free
104-
true
105-
}
106-
107-
MyProfile.toString() -> {
108-
navItem = BottomNavItem.MyPage
109-
true
110-
}
111-
112-
toString(),
113-
-> true
114-
115-
else -> false
116-
}
117-
}
118-
119-
// BottomNav의 item이 변경되면 해당 item에 맞는 화면으로 이동
120-
LaunchedEffect(Unit) {
121-
snapshotFlow { navItem }
122-
.distinctUntilChanged()
123-
.drop(1) // 초기 값은 스킵
124-
.collect { newValue ->
125-
// value가 변경될 때만 실행되는 로직
126-
when (newValue) {
127-
BottomNavItem.Wiki -> {
128-
navController.navigateToWikiBaseRoute()
129-
}
130-
131-
BottomNavItem.Free -> {
132-
navController.navigateToFreeBoardBaseRoute()
133-
}
134-
135-
BottomNavItem.MyPage -> {
136-
navController.navigateToMyProfileBaseRoute()
137-
}
138-
}
139-
}
140-
}
141-
14295
Box {
14396
Column(
14497
modifier =
@@ -199,7 +152,9 @@ fun AppNavigation(modifier: Modifier = Modifier) {
199152
navController.navigateToSettings()
200153
},
201154
onNavigateToMyPosts = {
202-
navController.navigateToMyPosts()
155+
navController.navigateToMyPosts(
156+
profileId = it,
157+
)
203158
},
204159
onNavigateToMyProfileModifyProfile = {
205160
navController.navigateToMyProfileModifyProfile()
@@ -229,6 +184,12 @@ fun AppNavigation(modifier: Modifier = Modifier) {
229184
navOptions,
230185
)
231186
},
187+
onNavigateToFreeBoardCommentDetail = { postId, freeBoardComment ->
188+
navController.navigateToFreeBoardCommentDetailScreen(
189+
postId = postId,
190+
freeBoardComment = freeBoardComment,
191+
)
192+
},
232193
)
233194
wikiNavGraph()
234195
}
@@ -298,4 +259,63 @@ fun AppNavigation(modifier: Modifier = Modifier) {
298259
)
299260
}
300261
}
262+
263+
LaunchedEffect(navBackStackEntry?.destination?.route) {
264+
// 현재 화면이 BottomNav를 표시해야 하는지 확인
265+
shouldShowBottomBar =
266+
when (navBackStackEntry?.destination?.route) {
267+
Wiki.toString() -> {
268+
navItem = BottomNavItem.Wiki
269+
true
270+
}
271+
272+
FreeBoard.toString() -> {
273+
navItem = BottomNavItem.Free
274+
true
275+
}
276+
277+
MyProfile.toString() -> {
278+
navItem = BottomNavItem.MyPage
279+
true
280+
}
281+
282+
toString(),
283+
-> true
284+
285+
else -> false
286+
}
287+
}
288+
289+
val topLevelDestinationNavOptions =
290+
navOptions {
291+
popUpTo(MainNavigationRoute(BottomNavItem.Wiki)) {
292+
saveState = true
293+
}
294+
295+
launchSingleTop = true
296+
restoreState = true
297+
}
298+
299+
// BottomNav의 item이 변경되면 해당 item에 맞는 화면으로 이동
300+
LaunchedEffect(Unit) {
301+
snapshotFlow { navItem }
302+
.distinctUntilChanged()
303+
.drop(1) // 초기 값은 스킵
304+
.collect { newValue ->
305+
// value가 변경될 때만 실행되는 로직
306+
when (newValue) {
307+
BottomNavItem.Wiki -> {
308+
navController.navigateToWikiBaseRoute(topLevelDestinationNavOptions)
309+
}
310+
311+
BottomNavItem.Free -> {
312+
navController.navigateToFreeBoardBaseRoute(topLevelDestinationNavOptions)
313+
}
314+
315+
BottomNavItem.MyPage -> {
316+
navController.navigateToMyProfileBaseRoute(topLevelDestinationNavOptions)
317+
}
318+
}
319+
}
320+
}
301321
}

core/navigation/src/main/java/com/lanpet/core/navigation/NavigationHandler.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.lanpet.core.navigation
22

3+
import androidx.collection.forEach
34
import androidx.compose.runtime.Composable
45
import androidx.compose.runtime.LaunchedEffect
56
import androidx.compose.runtime.remember
7+
import androidx.navigation.NavGraph
68
import androidx.navigation.NavHostController
79
import com.lanpet.core.common.widget.BottomNavItem
810
import com.lanpet.domain.model.AuthState

0 commit comments

Comments
 (0)