Skip to content

Commit

Permalink
Merge pull request #10 from MaxAstin/dev
Browse files Browse the repository at this point in the history
1.6.0
  • Loading branch information
MaxAstin committed Apr 26, 2024
2 parents 5865beb + e63095f commit a2a244e
Show file tree
Hide file tree
Showing 25 changed files with 1,218 additions and 389 deletions.
23 changes: 13 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.bunbeauty.fakelivestream"
minSdk = 27
targetSdk = 34
versionCode = 152
versionName = "1.5.2"
versionCode = 160
versionName = "1.6.0"
multiDexEnabled = true

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -65,12 +65,12 @@ android {

dependencies {
implementation("com.android.support:multidex:1.0.3")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.core:core-ktx:1.13.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")

// Compose
implementation("androidx.activity:activity-compose:1.8.2")
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
implementation("androidx.activity:activity-compose:1.9.0")
implementation(platform("androidx.compose:compose-bom:2024.04.01"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
Expand All @@ -87,9 +87,9 @@ dependencies {
implementation("io.coil-kt:coil-compose:2.5.0")

// Camera
implementation("androidx.camera:camera-camera2:1.3.2")
implementation("androidx.camera:camera-lifecycle:1.3.2")
implementation("androidx.camera:camera-view:1.3.2")
implementation("androidx.camera:camera-camera2:1.3.3")
implementation("androidx.camera:camera-lifecycle:1.3.3")
implementation("androidx.camera:camera-view:1.3.3")

// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
Expand All @@ -103,8 +103,8 @@ dependencies {
implementation("com.google.accompanist:accompanist-permissions:0.34.0")

// Media3
implementation("androidx.media3:media3-ui:1.3.0")
implementation("androidx.media3:media3-exoplayer:1.3.0")
implementation("androidx.media3:media3-ui:1.3.1")
implementation("androidx.media3:media3-exoplayer:1.3.1")

// Firebase
implementation(platform("com.google.firebase:firebase-bom:32.7.3"))
Expand All @@ -116,6 +116,9 @@ dependencies {

// Image Cropping
implementation("com.vanniktech:android-image-cropper:4.5.0")

// Immutable collections
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.7")
}

kapt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ abstract class BaseViewModel<S : Base.State, A : Base.Action, E : Base.Event>(
) : ViewModel() {

protected val mutableState = MutableStateFlow(initState())
protected val currentState: S
get() = mutableState.value
val state: StateFlow<S> = mutableState.asStateFlow()

private val mutableEvent = Channel<E>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ fun FakeLiveBottomSheet(
windowInsets = windowInsets,
modifier = modifier
) {
Column(modifier = Modifier.navigationBarsPadding()) {
Column(
modifier = Modifier
.fillMaxWidth()
.navigationBarsPadding()
) {
content()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.bunbeauty.fakelivestream.common.ui.components.bottomsheet

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.bunbeauty.fakelivestream.common.ui.theme.FakeLiveStreamTheme

@Composable
fun ColumnScope.FakeLiveBottomSheetContent(
@StringRes titleResId: Int,
content: @Composable () -> Unit
) {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(
top = 16.dp,
bottom = 12.dp
),
text = stringResource(titleResId),
color = FakeLiveStreamTheme.colors.onSurface,
style = FakeLiveStreamTheme.typography.titleMedium,
textAlign = TextAlign.Center
)
Divider(
modifier = Modifier.fillMaxWidth(),
thickness = 0.5.dp,
color = FakeLiveStreamTheme.colors.border
)
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
content()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color

val White = Color(0xFFFFFFFF)
val Black = Color(0xFF000000)
val Black200 = Color(0xFF000000)
val Black100 = Color(0xFF1A1A1A)
val Gray400 = Color(0xFF262626)
val Gray300 = Color(0xFF6D6D6D)
val Gray200 = Color(0xFF888888)
Expand All @@ -21,10 +22,12 @@ val Amber = Color(0xFFFFBF00)
@Stable
class ColorScheme(
interactive: Color,
important: Color,
icon: Color,
iconVariant: Color,
surface: Color,
surfaceVariant: Color,
selectedSurface: Color,
onSurface: Color,
onSurfaceVariant: Color,
background: Color,
Expand All @@ -37,6 +40,9 @@ class ColorScheme(
var interactive by mutableStateOf(interactive)
internal set

var important by mutableStateOf(important)
internal set

var icon by mutableStateOf(icon)
internal set

Expand All @@ -49,6 +55,9 @@ class ColorScheme(
var surfaceVariant by mutableStateOf(surfaceVariant)
internal set

var selectedSurface by mutableStateOf(selectedSurface)
internal set

var onSurface by mutableStateOf(onSurface)
internal set

Expand All @@ -73,10 +82,12 @@ class ColorScheme(

fun copy(
interactive: Color = this.interactive,
important: Color = this.important,
icon: Color = this.icon,
iconVariant: Color = this.iconVariant,
surface: Color = this.surface,
surfaceVariant: Color = this.surfaceVariant,
selectedSurface: Color = this.selectedSurface,
onSurface: Color = this.onSurface,
onSurfaceVariant: Color = this.onSurfaceVariant,
background: Color = this.background,
Expand All @@ -86,10 +97,12 @@ class ColorScheme(
instagram: InstagramColors = this.instagram,
): ColorScheme = ColorScheme(
interactive = interactive,
important = important,
icon = icon,
iconVariant = iconVariant,
surface = surface,
surfaceVariant = surfaceVariant,
selectedSurface = selectedSurface,
onSurface = onSurface,
onSurfaceVariant = onSurfaceVariant,
background = background,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf

private val DarkColorScheme = ColorScheme(
important = Scarlet,
interactive = Blue,
icon = White,
iconVariant = Gray200,
surface = Black,
surface = Black200,
surfaceVariant = Gray400,
selectedSurface = Black100,
onSurface = White,
onSurfaceVariant = Gray200,
background = White,
onBackground = Black,
onBackground = Black200,
border = Gray300,
borderVariant = Gray100,
instagram = InstagramColors(
Expand All @@ -31,14 +33,16 @@ private val DarkColorScheme = ColorScheme(

private val LightColorScheme = ColorScheme(
interactive = Blue,
important = Scarlet,
icon = White,
iconVariant = Gray200,
surface = Black,
surface = Black200,
surfaceVariant = Gray400,
selectedSurface = Black100,
onSurface = White,
onSurfaceVariant = Gray200,
background = White,
onBackground = Black,
onBackground = Black200,
border = Gray300,
borderVariant = Gray100,
instagram = InstagramColors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package com.bunbeauty.fakelivestream.features.stream.data.user
import com.bunbeauty.fakelivestream.features.stream.data.comment.PictureStore
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.random.Random

@Singleton
class UserRepository @Inject constructor() {

private val pictureStore = PictureStore()
private val commentPictureStore = PictureStore()
private val questionPictureStore = PictureStore()

fun getPictureName(): String? {
return if (Random.nextInt(10) == 0) {
null
} else {
pictureStore.getNext()
}
fun getCommentPictureName(): String {
return commentPictureStore.getNext()
}

fun getQuestionPictureName(): String {
return questionPictureStore.getNext()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.bunbeauty.fakelivestream.features.stream.domain

import javax.inject.Inject
import kotlin.random.Random

class GetCommentsDelayUseCase @Inject constructor() {

operator fun invoke(viewersCount: Int): Long {
return if (viewersCount < 1000) {
Random.nextLong(1_000, 2_000)
} else {
Random.nextLong(500, 1_000)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@ package com.bunbeauty.fakelivestream.features.stream.domain
import com.bunbeauty.fakelivestream.features.stream.data.user.UserRepository
import com.bunbeauty.fakelivestream.features.stream.domain.model.Comment
import javax.inject.Inject
import kotlin.random.Random

class GetCommentsUseCase @Inject constructor(
private val userRepository: UserRepository,
private val getRandomCommentText: GetRandomCommentTextUseCase,
private val getRandomUsernameUseCase: GetRandomUsernameUseCase,
) {

operator fun invoke(count: Int): List<Comment> {
operator fun invoke(viewersCount: Int): List<Comment> {
val count = if (viewersCount < 1000) {
1
} else {
val maxCommentCount = (viewersCount / 1_000).coerceIn(2, 5)
Random.nextInt(1, maxCommentCount)
}

return List(count) {
val picture = if (Random.nextInt(10) == 0) {
null
} else {
userRepository.getCommentPictureName()
}
Comment(
picture = userRepository.getPictureName(),
picture = picture,
username = getRandomUsernameUseCase(),
text = getRandomCommentText(),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.bunbeauty.fakelivestream.features.stream.domain

import com.bunbeauty.fakelivestream.features.stream.data.user.UserRepository
import com.bunbeauty.fakelivestream.features.stream.domain.model.Question
import java.util.UUID
import javax.inject.Inject

private const val QUESTION_LIMIT = 3

class GetQuestionUseCase @Inject constructor(
private val userRepository: UserRepository,
private val getRandomCommentText: GetRandomCommentTextUseCase,
private val getRandomUsernameUseCase: GetRandomUsernameUseCase,
) {

operator fun invoke(questionCount: Int): Question? {
if (questionCount >= QUESTION_LIMIT) {
return null
}

return Question(
uuid = UUID.randomUUID().toString(),
picture = userRepository.getQuestionPictureName(),
username = getRandomUsernameUseCase(),
text = getRandomCommentText(type = CommentType.QUESTION),
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ class GetRandomCommentTextUseCase @Inject constructor(
private val commentRepository: CommentRepository,
) {

operator fun invoke(type: CommentType): String {
return buildTextComment(
type = type,
withEmoji = false
)
}

operator fun invoke(): String {
return when (Random.nextInt(CommentType.entries.size + 2)) {
0 -> buildEmojiString(maxCount = 5)
1 -> buildSymbolString()
else -> buildTextComment()
else -> buildTextComment(type = randomType())
}
}

Expand All @@ -30,8 +37,10 @@ class GetRandomCommentTextUseCase @Inject constructor(
}
}

private fun buildTextComment(): String {
val type = randomType()
private fun buildTextComment(
type: CommentType,
withEmoji: Boolean = true,
): String {
var comment = commentRepository.getNextComment(type)
comment = when (type) {
CommentType.ONE_LETTER,
Expand All @@ -57,7 +66,7 @@ class GetRandomCommentTextUseCase @Inject constructor(
}
}

return if (Random.nextBoolean()) {
return if (withEmoji && Random.nextBoolean()) {
comment.addRandomEmoji()
} else {
comment
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bunbeauty.fakelivestream.features.stream.domain.model

data class Question(
val uuid: String,
val picture: String?,
val username: String,
val text: String,
)
Loading

0 comments on commit a2a244e

Please sign in to comment.