-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: 양주현 <didwngus01@snu.ac.kr>
- Loading branch information
1 parent
47e5a44
commit 967ff99
Showing
110 changed files
with
1,598 additions
and
155 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.wafflestudio.snutt2 | ||
|
||
import com.wafflestudio.snutt2.data.user.UserRepository | ||
import com.wafflestudio.snutt2.lib.network.ApiOnError | ||
import com.wafflestudio.snutt2.lib.network.SNUTTRestApi | ||
import com.wafflestudio.snutt2.lib.network.dto.core.RemoteConfigDto | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.SharingStarted | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import kotlinx.coroutines.flow.filter | ||
import kotlinx.coroutines.flow.stateIn | ||
import kotlinx.coroutines.withContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class RemoteConfig @Inject constructor( | ||
api: SNUTTRestApi, | ||
userRepository: UserRepository, | ||
apiOnError: ApiOnError, | ||
) { | ||
private val config = callbackFlow { | ||
userRepository.accessToken.filter { it.isNotEmpty() }.collect { | ||
withContext(Dispatchers.IO) { | ||
try { | ||
send(api._getRemoteConfig()) | ||
} catch (e: Exception) { | ||
apiOnError(e) | ||
} | ||
} | ||
} | ||
awaitClose {} | ||
}.stateIn( | ||
CoroutineScope(Dispatchers.Main), | ||
SharingStarted.Eagerly, | ||
RemoteConfigDto() | ||
) | ||
|
||
val friendBundleSrc: String | ||
get() = config.value.reactNativeBundleSrc?.src?.get("android") ?: "" | ||
|
||
val vacancyNotificationBannerEnabled: Boolean | ||
get() = config.value.vacancyBannerConfig.visible | ||
|
||
val sugangSNUUrl: String | ||
get() = config.value.vacancyUrlConfig.url ?: "" | ||
|
||
val settingPageNewBadgeTitles: List<String> | ||
get() = config.value.settingsBadgeConfig.new | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/wafflestudio/snutt2/components/compose/RoundCheckbox.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.wafflestudio.snutt2.components.compose | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.animation.animateColorAsState | ||
import androidx.compose.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Check | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import com.wafflestudio.snutt2.ui.SNUTTColors | ||
|
||
@Composable | ||
fun RoundCheckbox( | ||
checked: Boolean, | ||
onCheckedChange: ((Boolean) -> Unit)?, | ||
modifier: Modifier = Modifier, | ||
checkedBgColor: Color = SNUTTColors.Black900, | ||
uncheckedBgColor: Color = SNUTTColors.Transparent, | ||
checkMarkColor: Color = SNUTTColors.White900, | ||
borderColor: Color = SNUTTColors.VacancyGray | ||
) { | ||
val animatedBgColor: Color by animateColorAsState(if (checked) checkedBgColor else uncheckedBgColor) | ||
val animatedBorderColor: Color by animateColorAsState(if (checked) checkedBgColor else borderColor) | ||
Box( | ||
modifier = modifier | ||
.clip(CircleShape) | ||
.size(20.dp) | ||
.border(width = 2.dp, color = animatedBorderColor, shape = CircleShape) | ||
.background(animatedBgColor) | ||
.clicks { | ||
onCheckedChange?.invoke(checked.not()) | ||
}, | ||
contentAlignment = Alignment.Center | ||
) { | ||
AnimatedVisibility( | ||
visible = checked, | ||
enter = fadeIn(), | ||
exit = fadeOut() | ||
) { | ||
Icon( | ||
modifier = Modifier.padding(4.dp), | ||
imageVector = Icons.Default.Check, | ||
tint = checkMarkColor, | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/wafflestudio/snutt2/data/vacancy_noti/VacancyRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.wafflestudio.snutt2.data.vacancy_noti | ||
|
||
import com.wafflestudio.snutt2.lib.network.dto.core.LectureDto | ||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
interface VacancyRepository { | ||
val firstVacancyVisit: StateFlow<Boolean> | ||
|
||
val vacancyBannerOpenTime: StateFlow<Long> | ||
|
||
suspend fun getVacancyLectures(): List<LectureDto> | ||
|
||
suspend fun addVacancyLecture(lectureId: String) | ||
|
||
suspend fun removeVacancyLecture(lectureId: String) | ||
|
||
suspend fun setVacancyVisited() | ||
|
||
suspend fun updateVacancyBannerOpenTime() | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/wafflestudio/snutt2/data/vacancy_noti/VacancyRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.wafflestudio.snutt2.data.vacancy_noti | ||
|
||
import com.wafflestudio.snutt2.data.SNUTTStorage | ||
import com.wafflestudio.snutt2.lib.network.SNUTTRestApi | ||
import com.wafflestudio.snutt2.lib.network.dto.core.LectureDto | ||
import kotlinx.coroutines.flow.StateFlow | ||
import java.util.* | ||
import java.util.concurrent.TimeUnit | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class VacancyRepositoryImpl @Inject constructor( | ||
private val api: SNUTTRestApi, | ||
private val storage: SNUTTStorage, | ||
) : VacancyRepository { | ||
|
||
override val firstVacancyVisit = storage.firstVacancyVisit.asStateFlow() | ||
|
||
override val vacancyBannerOpenTime: StateFlow<Long> = storage.vacancyBannerOpenTime.asStateFlow() | ||
|
||
override suspend fun getVacancyLectures(): List<LectureDto> { | ||
return api._getVacancyLectures().lectures | ||
} | ||
|
||
override suspend fun addVacancyLecture(lectureId: String) { | ||
api._postVacancyLecture(lectureId) | ||
} | ||
|
||
override suspend fun removeVacancyLecture(lectureId: String) { | ||
api._deleteVacancyLecture(lectureId) | ||
} | ||
|
||
override suspend fun setVacancyVisited() { | ||
storage.firstVacancyVisit.update(false) | ||
} | ||
|
||
override suspend fun updateVacancyBannerOpenTime() { | ||
storage.vacancyBannerOpenTime.update(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.