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] 기능 추가 & 디자인 QA #139

Merged
merged 9 commits into from
Mar 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import io.ktor.client.request.get
import io.ktor.client.request.patch
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import javax.inject.Inject
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.LocalTime
import javax.inject.Inject

class ScheduleApi @Inject constructor(
@AuthHttpClient private val client: HttpClient,
Expand Down Expand Up @@ -90,6 +90,13 @@ class ScheduleApi @Inject constructor(
}.convert(errorMessageMapper::map)
}

suspend fun hideSchedule(
id: Long
): Result<Unit> {
return client.patch("$baseUrl/api/v1/schedules/${id}/hide")
.convert(errorMessageMapper::map)
}

suspend fun deleteSchedule(
id: Long,
): Result<Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class MockScheduleRepository @Inject constructor() : ScheduleRepository {
return Result.success(Unit)
}

override suspend fun hideSchedule(id: Long): Result<Unit> {
return Result.success(Unit)
}

override suspend fun deleteSchedule(
id: Long
): Result<Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import ac.dnd.mour.android.domain.model.feature.schedule.AlarmRepeatType
import ac.dnd.mour.android.domain.model.feature.schedule.Schedule
import ac.dnd.mour.android.domain.model.feature.schedule.UnrecordedSchedule
import ac.dnd.mour.android.domain.repository.ScheduleRepository
import javax.inject.Inject
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.LocalTime
import javax.inject.Inject

class RealScheduleRepository @Inject constructor(
private val scheduleApi: ScheduleApi,
Expand Down Expand Up @@ -69,6 +69,14 @@ class RealScheduleRepository @Inject constructor(
)
}

override suspend fun hideSchedule(
id: Long
): Result<Unit> {
return scheduleApi.hideSchedule(
id = id
)
}

override suspend fun deleteSchedule(
id: Long
): Result<Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ interface ScheduleRepository {
memo: String,
): Result<Unit>

suspend fun hideSchedule(
id: Long
): Result<Unit>

suspend fun deleteSchedule(
id: Long,
): Result<Unit>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ac.dnd.mour.android.domain.usecase.feature.schedule

import ac.dnd.mour.android.domain.repository.ScheduleRepository
import javax.inject.Inject

class HideScheduleUseCase @Inject constructor(
private val scheduleRepository: ScheduleRepository
){
suspend operator fun invoke(
id : Long
) : Result<Unit> {
return scheduleRepository.hideSchedule(
id = id
)
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[versions]
# App Version
app-versioncode = "1"
app-versionname = "0.0.5"
app-versionname = "0.0.6"
# SDK Version
sdk-min = "24"
sdk-target = "34"
Expand Down
1 change: 1 addition & 0 deletions presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<application>
<activity
android:name=".ui.main.MainActivity"
android:windowSoftInputMode="adjustPan"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 왜 하시나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjustPan + .imePadding() 같이해야지 키보드 올라올 때 뷰 올라오는 거 같아요
둘다 따로 쓸때는 안되다가 이제 됩니다
근데 다 안올라오는게 제대로 적용 안된듯.. 할 줄 모르겠네요

android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ac.dnd.mour.android.presentation.common.view.calendar

import ac.dnd.mour.android.presentation.common.theme.Body0
import ac.dnd.mour.android.presentation.common.theme.Gray200
import ac.dnd.mour.android.presentation.common.theme.Gray500
import ac.dnd.mour.android.presentation.common.theme.Gray700
import ac.dnd.mour.android.presentation.common.theme.Gray800
import ac.dnd.mour.android.presentation.common.theme.Headline2
Expand All @@ -16,8 +18,12 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material.RadioButton
import androidx.compose.material.RadioButtonDefaults
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -40,8 +46,9 @@ fun TimePicker(
localTime: LocalTime = LocalTime(0, 0),
properties: BottomSheetDialogProperties = BottomSheetDialogProperties(),
onDismissRequest: () -> Unit,
onConfirm: (LocalTime) -> Unit
) {
onConfirm: (LocalTime?) -> Unit,

) {
val timeTextStyle = Headline3.merge(
color = Gray700,
fontWeight = FontWeight.SemiBold
Expand All @@ -57,14 +64,13 @@ fun TimePicker(
)
}
var minuteValue by remember { mutableIntStateOf(localTime.minute) }
var isCheckNotValue by remember { mutableStateOf(false) }

BottomSheetScreen(
onDismissRequest = onDismissRequest,
properties = properties
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Column {
Box(
modifier = Modifier
.background(Gray200)
Expand Down Expand Up @@ -98,19 +104,34 @@ fun TimePicker(
TimePickerType.PM -> if (hourValue == 12) 0 else 12
}
onConfirm(
LocalTime(
hour = hourValue + transHour,
minute = minuteValue
)
if (isCheckNotValue) {
null
} else {
LocalTime(
hour = hourValue + transHour,
minute = minuteValue
)
}
)
onDismissRequest()
}
)
}
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
horizontalArrangement = Arrangement.Center,
modifier = Modifier.fillMaxWidth()
) {
ListItemPicker(
value = timeType.typeName,
list = TimePickerType.getEntryNames(),
onValueChange = {
timeType = TimePickerType.getTimeType(it)
},
dividersColor = Primary3,
textStyle = timeTextStyle
)
Spacer(modifier = Modifier.width(40.dp))
NumberPicker(
value = hourValue,
range = 1..12,
Expand All @@ -120,7 +141,15 @@ fun TimePicker(
hourValue = it
},
)
Spacer(modifier = Modifier.width(20.dp))
Spacer(modifier = Modifier.width(10.dp))
Text(
text = "시",
style = Body0.merge(
color = Gray800,
fontWeight = FontWeight.Normal
),
)
Spacer(modifier = Modifier.width(26.dp))
NumberPicker(
value = minuteValue,
range = 0..59,
Expand All @@ -130,17 +159,37 @@ fun TimePicker(
minuteValue = it
},
)
Spacer(modifier = Modifier.width(20.dp))
ListItemPicker(
value = timeType.typeName,
list = TimePickerType.getEntryNames(),
onValueChange = {
timeType = TimePickerType.getTimeType(it)
Text(
text = "분",
fontWeight = FontWeight.Normal,
style = Body0.merge(color = Gray800),
)
}

Spacer(modifier = Modifier.height(35.dp))
Row(
verticalAlignment = Alignment.CenterVertically
) {
Spacer(modifier = Modifier.width(22.dp))
RadioButton(
selected = isCheckNotValue,
onClick = {
isCheckNotValue = !isCheckNotValue
},
dividersColor = Primary3,
textStyle = timeTextStyle
modifier = Modifier.size(16.dp),
colors = RadioButtonDefaults.colors(
selectedColor = Primary4,
unselectedColor = Gray500
)
)
Spacer(modifier = Modifier.width(8.dp))
Text(
text = "선택 안함",
fontWeight = FontWeight.Normal,
style = Body0.merge(color = Gray800),
)
}
Spacer(modifier = Modifier.height(28.dp))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ac.dnd.mour.android.presentation.ui.main.common.calendar

import ac.dnd.mour.android.presentation.R
import ac.dnd.mour.android.presentation.common.theme.Gray000
import ac.dnd.mour.android.presentation.common.theme.Gray600
import ac.dnd.mour.android.presentation.common.theme.Gray700
import ac.dnd.mour.android.presentation.common.theme.Gray800
import ac.dnd.mour.android.presentation.common.theme.Gray900
Expand Down Expand Up @@ -55,7 +54,7 @@ import com.holix.android.bottomsheetdialog.compose.BottomSheetDialogProperties
import kotlinx.datetime.LocalDate

@Composable
fun HistoryCalendarScreen(
fun SelectCalendarScreen(
calendarConfig: CalendarConfig,
selectedYear: Int,
selectedMonth: Int,
Expand Down Expand Up @@ -239,7 +238,7 @@ fun HistoryCalendarScreen(
@Preview(apiLevel = 33)
@Composable
fun HistoryCalendarScreenPreview() {
HistoryCalendarScreen(
SelectCalendarScreen(
calendarConfig = CalendarConfig(),
selectedYear = 2024,
selectedMonth = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package ac.dnd.mour.android.presentation.ui.main.home.common.group.get
sealed interface GetGroupEvent {
sealed interface DeleteGroup : GetGroupEvent {
data object Success : DeleteGroup
data object Fail : DeleteGroup
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ac.dnd.mour.android.presentation.common.util.logevent.LogEventUtil
import ac.dnd.mour.android.presentation.common.util.logevent.viewLogEvent
import ac.dnd.mour.android.presentation.common.view.BottomSheetScreen
import ac.dnd.mour.android.presentation.common.view.DialogScreen
import ac.dnd.mour.android.presentation.common.view.SnackBarScreen
import ac.dnd.mour.android.presentation.model.relation.DefaultGroupType
import ac.dnd.mour.android.presentation.ui.main.ApplicationState
import ac.dnd.mour.android.presentation.ui.main.home.common.group.add.AddGroupScreen
Expand Down Expand Up @@ -56,6 +57,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -70,6 +72,8 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.holix.android.bottomsheetdialog.compose.BottomSheetBehaviorProperties
import com.holix.android.bottomsheetdialog.compose.BottomSheetDialogProperties
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@Composable
fun GetGroupScreen(
Expand Down Expand Up @@ -122,9 +126,25 @@ private fun GetGroupScreen(
event: EventFlow<GetGroupEvent>,
handler: CoroutineExceptionHandler
) {
val scope = rememberCoroutineScope()
var currentDeleteGroupIndex by remember { mutableIntStateOf(-1) }
var currentEditGroupIndex by remember { mutableIntStateOf(-1) }
var isShowingAddGroupSheet by remember { mutableStateOf(false) }
var isShowingDeleteFailToast by remember { mutableStateOf(false) }

fun deleteEvent(event: GetGroupEvent.DeleteGroup) {
when (event) {
is GetGroupEvent.DeleteGroup.Fail -> {
scope.launch {
isShowingDeleteFailToast = true
delay(1000L)
isShowingDeleteFailToast = false
}
}

is GetGroupEvent.DeleteGroup.Success -> {}
}
}

BottomSheetScreen(
onDismissRequest = onDismissRequest,
Expand Down Expand Up @@ -339,6 +359,16 @@ private fun GetGroupScreen(
}
Spacer(modifier = Modifier.height(Space12))
}

if (isShowingDeleteFailToast) {
Box(
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(bottom = 65.dp)
) {
SnackBarScreen("등록된 관계가 존재하기 때문에 삭제할 수 없습니다.")
}
}
}
}

Expand Down Expand Up @@ -392,9 +422,7 @@ private fun GetGroupScreen(
LaunchedEffectWithLifecycle(event, handler) {
event.eventObserve { event ->
when (event) {
is GetGroupEvent.DeleteGroup -> {

}
is GetGroupEvent.DeleteGroup -> deleteEvent(event)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GetGroupViewModel @Inject constructor(
_state.value = GetGroupState.Init
when (exception) {
is ServerException -> {
_errorEvent.emit(ErrorEvent.InvalidRequest(exception))
_event.emit(GetGroupEvent.DeleteGroup.Fail)
}

else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,6 @@ fun RelationScreen(
"등록이 완료되었습니다.",
)
appState.navController.popBackStack()
// val route = makeRoute(
// HomeConstant.ROUTE,
// listOf(HomeConstant.ROUTE_ARGUMENT_MESSAGE to "등록이 완료되었습니다.")
// )
// appState.navController.navigate(route) {
// popUpTo(RelationConstant.ROUTE) {
// inclusive = true
// }
// }
}
}
}
Expand Down
Loading
Loading