Skip to content

Commit

Permalink
Merge pull request #256 from Team-B1ND/feature/c/224-create-eidt-memb…
Browse files Browse the repository at this point in the history
…er-info

[Core] Create Edit Member Info Feature
  • Loading branch information
wnsgur1 authored Nov 20, 2024
2 parents 7cf4de6 + 02197e0 commit 857ce27
Show file tree
Hide file tree
Showing 43 changed files with 834 additions and 99 deletions.
Empty file added %25%23ok%C3%A9k%C3%89%C8%A2
Empty file.
Empty file added a%20test%20%26
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ interface MemberRepository {
suspend fun getMyInfo(): Flow<Result<MemberInfo>>
suspend fun deactivation(): Flow<Result<Unit>>
suspend fun getMemberActiveAll(): Flow<Result<ImmutableList<MemberInfo>>>
suspend fun editMemberInfo(name: String, email: String, phone: String, profileImage: String?): Flow<Result<Unit>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ internal class MemberRepositoryImpl(
.asResult()
.flowOn(dispatcher)
}

override suspend fun editMemberInfo(name: String, email: String, phone: String, profileImage: String?): Flow<Result<Unit>> {
return flow {
emit(network.editMemberInfo(name, email, phone, profileImage))
}
.asResult()
.flowOn(dispatcher)
}
}
1 change: 1 addition & 0 deletions data/upload/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions data/upload/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import com.b1nd.dodam.dsl.android
import com.b1nd.dodam.dsl.kotlin
import com.b1nd.dodam.dsl.setIOS

plugins {
alias(libs.plugins.dodam.multiplatform)
alias(libs.plugins.dodam.multiplatform.kotlin)
alias(libs.plugins.dodam.multiplatform.koin)
}

kotlin {
setIOS("data.upload")

sourceSets.commonMain.dependencies {
api(projects.data.core)
implementation(projects.common)
implementation(projects.network.upload)

}
}


android {
namespace = "com.b1nd.dodam.data.upload"

defaultConfig {
consumerProguardFiles("consumer-rules.pro")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.b1nd.dodam.data.upload

import com.b1nd.dodam.common.result.Result
import com.b1nd.dodam.data.upload.model.UploadModel
import kotlinx.coroutines.flow.Flow

interface UploadRepository {

suspend fun upload(fileName: String, fileMimeType: String, byteArray: ByteArray): Flow<Result<UploadModel>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.b1nd.dodam.data.upload.di

import com.b1nd.dodam.common.DispatcherType
import com.b1nd.dodam.data.upload.UploadRepository
import com.b1nd.dodam.data.upload.repository.UploadRepositoryImpl
import org.koin.core.qualifier.named
import org.koin.dsl.module

val uploadRepositoryModule = module {
single<UploadRepository> {
UploadRepositoryImpl(
network = get(),
dispatcher = get(named(DispatcherType.IO)),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.b1nd.dodam.data.upload.model

data class UploadModel(
val profileImage: String,
)

fun String.toModel() = UploadModel(
profileImage = this,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.b1nd.dodam.data.upload.repository

import com.b1nd.dodam.common.Dispatcher
import com.b1nd.dodam.common.DispatcherType
import com.b1nd.dodam.common.result.Result
import com.b1nd.dodam.common.result.asResult
import com.b1nd.dodam.data.upload.UploadRepository
import com.b1nd.dodam.data.upload.model.UploadModel
import com.b1nd.dodam.data.upload.model.toModel
import com.b1nd.dodam.network.upload.datasource.UploadDataSource
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn

class UploadRepositoryImpl(
private val network: UploadDataSource,
@Dispatcher(DispatcherType.IO) private val dispatcher: CoroutineDispatcher,
) : UploadRepository {
override suspend fun upload(fileName: String, fileMimeType: String, byteArray: ByteArray): Flow<Result<UploadModel>> {
return flow {
emit(
network.upload(
fileName = fileName,
fileMimeType = fileMimeType,
byteArray = byteArray,
).toModel(),
)
}
.asResult()
.flowOn(dispatcher)
}
}
3 changes: 3 additions & 0 deletions dodam-student/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,7 @@ dependencies {
implementation(projects.network.login)
implementation(projects.network.bundleidInfo)
implementation(projects.data.bundleidInfo)
implementation(projects.feature.editMemberInfo)
implementation(projects.network.upload)
implementation(projects.data.upload)
}
13 changes: 13 additions & 0 deletions dodam-student/src/main/kotlin/com/b1nd/dodam/student/DodamApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import com.b1nd.dodam.bus.navigation.navigateToBus
import com.b1nd.dodam.dds.component.DodamErrorToast
import com.b1nd.dodam.dds.component.DodamSuccessToast
import com.b1nd.dodam.dds.component.DodamWarningToast
import com.b1nd.dodam.editmemberinfo.navigation.editMemberInfoScreen
import com.b1nd.dodam.editmemberinfo.navigation.navigationToEditMemberInfo
import com.b1nd.dodam.login.navigation.loginScreen
import com.b1nd.dodam.login.navigation.navigationToLogin
import com.b1nd.dodam.onboarding.navigation.ONBOARDING_ROUTE
Expand Down Expand Up @@ -239,6 +241,14 @@ fun DodamApp(
versionInfo = "3.2.0",
popBackStack = navController::popBackStack,
logout = logout,
navigationToEditMemberInfo = { profileImage, name, email, phone ->
navController.navigationToEditMemberInfo(
profileImage = profileImage,
name = name,
email = email,
phone = phone,
)
},
)
askWakeupSongScreen(
popBackStack = navController::popBackStack,
Expand All @@ -250,6 +260,9 @@ fun DodamApp(
pointScreen(
popBackStack = navController::popBackStack,
)
editMemberInfoScreen(
popBackStack = navController::popBackStack,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import com.b1nd.dodam.data.nightstudy.di.nightStudyRepositoryModule
import com.b1nd.dodam.data.outing.di.outingRepositoryModule
import com.b1nd.dodam.data.point.di.pointRepositoryModule
import com.b1nd.dodam.data.schedule.di.scheduleRepositoryModule
import com.b1nd.dodam.data.upload.di.uploadRepositoryModule
import com.b1nd.dodam.datastore.di.dataStoreModule
import com.b1nd.dodam.editmemberinfo.di.editMemberInfoViewModelModule
import com.b1nd.dodam.keystore.keystoreManagerModule
import com.b1nd.dodam.login.di.loginViewModelModule
import com.b1nd.dodam.member.di.memberDataSourceModule
Expand All @@ -30,6 +32,7 @@ import com.b1nd.dodam.network.nightstudy.di.nightStudyDataSourceModule
import com.b1nd.dodam.network.outing.di.outingDataSourceModule
import com.b1nd.dodam.network.point.di.pointDataSourceModule
import com.b1nd.dodam.network.schedule.di.scheduleDatasourceModule
import com.b1nd.dodam.network.upload.di.uploadDatasourceModule
import com.b1nd.dodam.nightstudy.di.nightStudyViewModelModule
import com.b1nd.dodam.outing.di.outingViewModelModule
import com.b1nd.dodam.register.di.registerDataSourceModule
Expand Down Expand Up @@ -96,6 +99,9 @@ class DodamApplication : Application() {
outingViewModelModule,
bundleIdInfoRepositoryModule,
bundleIdInfoDataSourceModule,
editMemberInfoViewModelModule,
uploadDatasourceModule,
uploadRepositoryModule,
) + mainViewModelModules,
)
}
Expand Down
3 changes: 3 additions & 0 deletions dodam-teacher-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ kotlin {
implementation(projects.network.point)
implementation(projects.network.bundleidInfo)
implementation(projects.data.bundleidInfo)
implementation(projects.feature.editMemberInfo)
implementation(projects.network.upload)
implementation(projects.data.upload)
}

androidMain.dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import com.b1nd.dodam.designsystem.component.DodamDialog
import com.b1nd.dodam.designsystem.component.DodamNavigationBar
import com.b1nd.dodam.designsystem.component.DodamNavigationBarItem
import com.b1nd.dodam.designsystem.foundation.DodamIcons
import com.b1nd.dodam.editmemberinfo.navigation.editMemberInfoScreen
import com.b1nd.dodam.editmemberinfo.navigation.navigationToEditMemberInfo
import com.b1nd.dodam.home.navigation.HOME_ROUTE
import com.b1nd.dodam.home.navigation.homeScreen
import com.b1nd.dodam.home.navigation.navigateToHome
Expand Down Expand Up @@ -255,7 +257,19 @@ fun DodamTeacherApp(exit: () -> Unit, viewModel: DodamTeacherAppViewModel = koin
settingScreen(
popBackStack = navHostController::popBackStack,
logout = exit,
versionInfo = getPlatformName(),
versionInfo = VERSION_INFO,
navigationToEditMemberInfo = { profileImage, name, email, phone ->
navHostController.navigationToEditMemberInfo(
profileImage = profileImage,
name = name,
email = email,
phone = phone,
)
},
)

editMemberInfoScreen(
popBackStack = navHostController::popBackStack,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import com.b1nd.dodam.data.nightstudy.di.nightStudyRepositoryModule
import com.b1nd.dodam.data.outing.di.outingRepositoryModule
import com.b1nd.dodam.data.point.di.pointRepositoryModule
import com.b1nd.dodam.data.schedule.di.scheduleRepositoryModule
import com.b1nd.dodam.data.upload.di.uploadRepositoryModule
import com.b1nd.dodam.datastore.di.dataStoreModule
import com.b1nd.dodam.editmemberinfo.di.editMemberInfoViewModelModule
import com.b1nd.dodam.home.di.homeViewModelModule
import com.b1nd.dodam.login.di.loginViewModelModule
import com.b1nd.dodam.meal.di.mealViewModelModule
Expand All @@ -27,6 +29,7 @@ import com.b1nd.dodam.network.nightstudy.di.nightStudyDataSourceModule
import com.b1nd.dodam.network.outing.di.outingDataSourceModule
import com.b1nd.dodam.network.point.di.pointDataSourceModule
import com.b1nd.dodam.network.schedule.di.scheduleDatasourceModule
import com.b1nd.dodam.network.upload.di.uploadDatasourceModule
import com.b1nd.dodam.nightstudy.di.nightStudyViewModelModule
import com.b1nd.dodam.outing.di.outingViewModelModule
import com.b1nd.dodam.point.di.pointViewModelModule
Expand Down Expand Up @@ -78,6 +81,9 @@ fun initKoin(block: KoinApplication.() -> Unit = {}) {
settingViewModelModule,
bundleIdInfoRepositoryModule,
bundleIdInfoDataSourceModule,
editMemberInfoViewModelModule,
uploadDatasourceModule,
uploadRepositoryModule,
)
block()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,26 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import com.b1nd.dodam.designsystem.DodamTheme
import com.b1nd.dodam.designsystem.animation.rememberBounceIndication
import com.b1nd.dodam.designsystem.component.ActionIcon
import com.b1nd.dodam.designsystem.component.AvatarSize
import com.b1nd.dodam.designsystem.component.DividerType
import com.b1nd.dodam.designsystem.component.DodamAvatar
import com.b1nd.dodam.designsystem.component.DodamDefaultTopAppBar
import com.b1nd.dodam.designsystem.component.DodamDivider
import com.b1nd.dodam.designsystem.foundation.DodamIcons
import com.b1nd.dodam.ui.component.modifier.`if`
import com.b1nd.dodam.ui.effect.shimmerEffect
import com.b1nd.dodam.ui.icons.BarChart
import com.b1nd.dodam.ui.icons.ColoredBus
Expand All @@ -64,6 +65,10 @@ fun AllScreen(
navigateToAddWakeUpSong: () -> Unit,
) {
val uiState by viewModel.uiState.collectAsState()

LaunchedEffect(key1 = true) {
viewModel.getMyInfo()
}
Scaffold(
modifier = Modifier
.fillMaxSize(),
Expand Down Expand Up @@ -130,36 +135,21 @@ fun AllScreen(
) {
uiState.memberInfo?.let { myInfo ->
Box {
if (!myInfo.profileImage.isNullOrEmpty()) {
AsyncImage(
model = myInfo.profileImage,
contentDescription = "profile",
modifier = Modifier
.clip(shape = CircleShape)
.size(64.dp),
contentScale = ContentScale.Crop,
)
} else {
Box(
modifier = Modifier
.clip(shape = CircleShape)
.size(64.dp)
.border(
val borderColor = DodamTheme.colors.lineAlternative
DodamAvatar(
avatarSize = AvatarSize.ExtraLarge,
contentDescription = "프로필 이미지",
model = myInfo.profileImage,
modifier = Modifier
.`if`(myInfo.profileImage.isNullOrEmpty()) {
border(
width = 1.dp,
color = DodamTheme.colors.lineAlternative,
color = borderColor,
shape = CircleShape,
),
contentAlignment = Alignment.Center,
) {
Image(
imageVector = DodamIcons.Person.value,
contentDescription = "profile",
modifier = Modifier.size(40.dp),
contentScale = ContentScale.Crop,
colorFilter = ColorFilter.tint(DodamTheme.colors.fillAlternative),
)
}
}
)
},
contentScale = ContentScale.Crop,
)
}
Spacer(modifier = Modifier.width(16.dp))
val classInfo = myInfo.student
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AllViewModel : ViewModel(), KoinComponent {
private val _uiState = MutableStateFlow(AllUiState())
val uiState = _uiState.asStateFlow()

init {
fun getMyInfo() {
viewModelScope.launch {
memberRepository.getMyInfo().collect { result ->
_uiState.update { uiState ->
Expand Down
Loading

0 comments on commit 857ce27

Please sign in to comment.