Skip to content
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.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies {
implementation(projects.feature.profile)
implementation(projects.feature.signup)
implementation(projects.feature.login)
implementation(projects.feature.history)
implementation(projects.core.designsystem)
implementation(projects.core.ui)
implementation(projects.core.data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import com.yapp.app.official.ui.NavigatorState
import com.yapp.app.official.ui.clearBackStackNavOptions
import com.yapp.feature.history.navigation.attendanceHistoryNavGraph
import com.yapp.feature.home.navigation.homeNavGraph
import com.yapp.feature.home.navigation.settingNavGraph
import com.yapp.feature.login.navigation.loginNavGraph
Expand Down Expand Up @@ -78,7 +79,13 @@ fun YappNavHost(
navigateBack = { navigator.popBackStack() }
)
profileNavGraph(
onNavigateToSetting = { navigator.navigateSettingScreen() }
onNavigateToSetting = { navigator.navigateSettingScreen() },
onNavigateToLogin = { navigator.navigateLoginScreen(clearBackStackNavOptions) },
onNavigateToPreviousHistory = {},
onNavigateToAttendHistory = { navigator.navigateToAttendance() }
)
attendanceHistoryNavGraph(
navigateToBack = { navigator.popBackStack() }
)
}
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/yapp/app/official/ui/Navigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navOptions
import com.yapp.app.official.navigation.TopLevelDestination
import com.yapp.feature.history.navigation.navigateToAttendance
import com.yapp.feature.home.navigation.navigateToHome
import com.yapp.feature.home.navigation.navigateToSetting
import com.yapp.feature.login.navigation.LoginRoute
Expand Down Expand Up @@ -81,6 +82,10 @@ class NavigatorState(
navController.navigateToNoticeDetail(noticeId)
}

fun navigateToAttendance() {
navController.navigateToAttendance()
}

fun popBackStack() {
navController.popBackStack()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.yapp.dataapi

import com.yapp.model.AttendStatistics
import kotlinx.coroutines.flow.Flow

interface AttendanceRepository {
fun getAttendanceStatistics(): Flow<AttendStatistics>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.yapp.dataapi

import com.yapp.model.Sessions
import kotlinx.coroutines.flow.Flow

interface SessionRepository {
fun getSessions(): Flow<List<Sessions>>
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.yapp.core.data.data.di

import com.yapp.core.data.data.repository.AlarmRepositoryImpl
import com.yapp.core.data.data.repository.AttendanceRepositoryImpl
import com.yapp.core.data.data.repository.AuthRepositoryImpl
import com.yapp.core.data.data.repository.OperationsRepositoryImpl
import com.yapp.core.data.data.repository.PostsRepositoryImpl
import com.yapp.core.data.data.repository.SessionsRepositoryImpl
import com.yapp.core.data.data.repository.UserRepositoryImpl
import com.yapp.dataapi.AlarmRepository
import com.yapp.dataapi.AttendanceRepository
import com.yapp.dataapi.AuthRepository
import com.yapp.dataapi.OperationsRepository
import com.yapp.dataapi.PostsRepository
import com.yapp.dataapi.SessionRepository
import com.yapp.dataapi.UserRepository
import dagger.Binds
import dagger.Module
Expand Down Expand Up @@ -43,4 +47,14 @@ internal abstract class RepositoryModule {
abstract fun bindPostsRepositoryImpl(
repositoryImpl: PostsRepositoryImpl,
): PostsRepository

@Binds
abstract fun bindsAttendanceRepositoryImpl(
repositoryImpl: AttendanceRepositoryImpl
): AttendanceRepository

@Binds
abstract fun bindsSessionRepositoryImpl(
repositoryImpl: SessionsRepositoryImpl
): SessionRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.yapp.core.data.data.repository

import com.yapp.core.data.remote.api.AttendanceApi
import com.yapp.dataapi.AttendanceRepository
import com.yapp.model.AttendStatistics
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

internal class AttendanceRepositoryImpl @Inject constructor(
private val attendApi: AttendanceApi
): AttendanceRepository{
override fun getAttendanceStatistics(): Flow<AttendStatistics> = flow {
emit(attendApi.getAttendanceStatistics().toModel())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.yapp.core.data.data.repository

import com.yapp.core.data.remote.api.SessionApi
import com.yapp.dataapi.SessionRepository
import com.yapp.model.Sessions
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

internal class SessionsRepositoryImpl @Inject constructor(
private val sessionApi: SessionApi
): SessionRepository{
override fun getSessions() = flow {
emit(sessionApi.getSessions().map { result ->
Sessions(
id = result.id,
name = result.name,
place = result.place,
date = result.date,
endDate = result.endDate,
time = result.time,
type = Sessions.AttendType.valueOf(result.type),
progressPhase = result.progressPhase
)
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.yapp.core.data.remote.api

import com.yapp.core.data.remote.model.response.AttendStatisticsResponse
import retrofit2.http.GET
import retrofit2.http.POST

interface AttendanceApi {
@POST("v1/attendances")
suspend fun postAttendance()

@GET("v1/attendances/statistics")
suspend fun getAttendanceStatistics(): AttendStatisticsResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.yapp.core.data.remote.api

import com.yapp.core.data.remote.model.response.SessionResponse
import retrofit2.http.GET

interface SessionApi {
@GET("v1/sessions")
suspend fun getSessions(): List<SessionResponse>
}
15 changes: 15 additions & 0 deletions core/data/src/main/java/com/yapp/core/data/remote/di/ApiModule.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.yapp.core.data.remote.di

import com.yapp.core.data.remote.api.AlarmApi
import com.yapp.core.data.remote.api.AttendanceApi
import com.yapp.core.data.remote.api.AuthApi
import com.yapp.core.data.remote.api.OperationsApi
import com.yapp.core.data.remote.api.PostsApi
import com.yapp.core.data.remote.api.SessionApi
import com.yapp.core.data.remote.api.UserApi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.create
import javax.inject.Singleton

@Module
Expand Down Expand Up @@ -45,4 +48,16 @@ internal object ApiModule {
fun providePostsApi(retrofit: Retrofit): PostsApi {
return retrofit.create(PostsApi::class.java)
}

@Singleton
@Provides
fun provideAttendanceApi(@AuthRetrofit retrofit: Retrofit): AttendanceApi {
return retrofit.create(AttendanceApi::class.java)
}

@Singleton
@Provides
fun providesSessionsApi(@AuthRetrofit retrofit: Retrofit): SessionApi {
return retrofit.create(SessionApi::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.yapp.core.data.remote.model.response

import com.yapp.model.AttendStatistics
import com.yapp.model.UserInfo
import kotlinx.serialization.Serializable

@Serializable
data class AttendStatisticsResponse(
val totalSessionCount: Int,
val remainingSessionCount: Int,
val sessionProgressRate: Int,
val attendancePoint: Int,
val attendanceCount: Int,
val lateCount: Int,
val absenceCount: Int,
val latePassCount: Int
) {
fun toModel() = AttendStatistics(
totalSessionCount = totalSessionCount,
remainingSessionCount = remainingSessionCount,
sessionProgressRate = sessionProgressRate,
attendancePoint = attendancePoint,
attendanceCount = attendanceCount,
lateCount = lateCount,
absenceCount = absenceCount,
latePassCount = latePassCount
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.yapp.core.data.remote.model.response

import kotlinx.serialization.Serializable

@Serializable
data class SessionResponse(
val id: String,
val name: String,
val place: String?,
val date: String,
val endDate: String?,
val time: String?,
val type: String,
val progressPhase: String
)
12 changes: 12 additions & 0 deletions core/model/src/main/java/com/yapp/model/AttendStatistics.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.yapp.model

data class AttendStatistics(
val totalSessionCount: Int,
val remainingSessionCount: Int,
val sessionProgressRate: Int,
val attendancePoint: Int,
val attendanceCount: Int,
val lateCount: Int,
val absenceCount: Int,
val latePassCount: Int
)
16 changes: 16 additions & 0 deletions core/model/src/main/java/com/yapp/model/Sessions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.yapp.model

data class Sessions(
val id: String,
val name: String,
val place: String?,
val date: String,
val endDate: String?,
val time: String?,
val type: AttendType,
val progressPhase: String
) {
enum class AttendType {

}
}
1 change: 1 addition & 0 deletions feature/history/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
16 changes: 16 additions & 0 deletions feature/history/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import com.yapp.app.setNamespace

plugins {
id("yapp.android.feature")
}

android {
setNamespace("feature.history")
}

dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.activity.compose)
implementation(libs.material)
}
Empty file.
21 changes: 21 additions & 0 deletions feature/history/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
4 changes: 4 additions & 0 deletions feature/history/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.yapp.feature.history

import com.yapp.model.Sessions

data class AttendHistoryState(
val totalSessionCount: Int = 0,
val remainingSessionCount: Int = 0,
val sessionProgressRate: Int = 0,
val attendancePoint: Int = 0,
val attendanceCount: Int = 0,
val lateCount: Int = 0,
val absenceCount: Int = 0,
val latePassCount: Int = 0,
val sessions: List<Sessions> = emptyList()
) {
val alertMessage: String
get() {
return if (absenceCount >= 10) {
"결석이 10번 이상이 되면 출결에 문제가 생겨 재적처리가 될 수 있어요. 출석 관리에 조금 더 신경 써 주세요!"
} else {
""
}
}
}
Comment on lines +16 to +24
Copy link
Member

Choose a reason for hiding this comment

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

A: get을 쓰지 않더라도 매번 AttendHistoryState는 copy로 새로 생성되기 때문에 get이 없어도 될거에요


sealed interface AttendHistoryIntent {
data object OnEntryScreen : AttendHistoryIntent
data object OnClickBackButton : AttendHistoryIntent
}
Comment on lines +27 to +29
Copy link
Member

Choose a reason for hiding this comment

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

C: Intent는 'On' 없이 그냥 EntryScreen으로 작성하고 있어서 컨벤션 맞춰주시면 감사하겠습니다.


sealed interface AttendHistorySideEffect {
data object NavigateToBack : AttendHistorySideEffect
}
Loading