We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
26.08.21 Load config from firebase
Lady-happy-Android/sources/dynamicFeature/postCreator/src/main/kotlin/com/egoriku/ladyhappy/postcreator/presentation/PostViewModel.kt
Line 75 in f7e30b1
import com.egoriku.ladyhappy.postcreator.domain.predefined.PredefinedData import com.egoriku.ladyhappy.postcreator.domain.usecase.PublishPostUseCase import com.egoriku.ladyhappy.postcreator.domain.usecase.UploadImagesUseCase import com.egoriku.ladyhappy.postcreator.presentation.state.DialogEvent import com.egoriku.ladyhappy.postcreator.presentation.state.Effect import com.egoriku.ladyhappy.postcreator.presentation.state.PostState import com.egoriku.ladyhappy.postcreator.presentation.state.ScreenState import com.egoriku.ladyhappy.postcreator.presentation.state.ScreenState.Uploading.Stage import com.google.firebase.Timestamp import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.* const val MAX_IMAGES_SIZE = 10 class PostViewModel( application: Application, private val uploadImagesUseCase: UploadImagesUseCase, private val publishPostUseCase: PublishPostUseCase, ) : AndroidViewModel(application) { private val _uiState = MutableStateFlow<ScreenState>(ScreenState.None) val uiState = _uiState.asStateFlow() private val _postState = MutableStateFlow(PostState()) val postState = _postState.asStateFlow() private val _publishButtonAvailability = MutableStateFlow(false) val publishButtonAvailability = _publishButtonAvailability.asStateFlow() private val _dialogEffects = MutableSharedFlow<DialogEvent>() val dialogEffects = _dialogEffects.asSharedFlow() private val _effects = MutableSharedFlow<Effect>() val effects = _effects.asSharedFlow() private val _currentPostState get() = _postState.value private val subCategoryId: Int get() = requireNotNull( _currentPostState.chooserState .filterIsInstance<ChooserType.SubCategory>() .firstOrNull() ?.categoryId ) init { viewModelScope.launch { _uiState.emit(ScreenState.Loading) // TODO: 26.08.21 Load config from firebase _uiState.emit(ScreenState.CreatePost) } } fun processEffect(effect: Effect) { viewModelScope.launch { _effects.emit(effect) } } fun openDialog(type: ChooserType) { val dialogEvent = when (type) { is ChooserType.Category -> DialogEvent.Category( data = PredefinedData.getCategoriesNames() ) is ChooserType.SubCategory -> DialogEvent.SubCategory( data = PredefinedData.getSubCategoriesNames(subCategoryId) ) is ChooserType.Color -> DialogEvent.Color is ChooserType.CreationDate -> DialogEvent.Date } viewModelScope.launch { _dialogEffects.emit(dialogEvent) } } fun processImageResult(list: List<Uri>) { val images = _currentPostState.imagesSection.images val newImages = list.map { ImageItem(uri = it) } _postState.value = _currentPostState.copy( imagesSection = ImageSection(images + newImages) )
1871318460819d14f96bf237fd5a6a6b44598b8e
The text was updated successfully, but these errors were encountered:
No branches or pull requests
26.08.21 Load config from firebase
Lady-happy-Android/sources/dynamicFeature/postCreator/src/main/kotlin/com/egoriku/ladyhappy/postcreator/presentation/PostViewModel.kt
Line 75 in f7e30b1
1871318460819d14f96bf237fd5a6a6b44598b8e
The text was updated successfully, but these errors were encountered: