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

Create Pin Bug #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -45,9 +45,8 @@ fun CreatePinScreen(
.safeDrawingPadding()
.provideTestTagsAsResourceId()
) {
val title = createRef()
val numButton = createRef()
val descriptionText = createRef()
val (title, descriptionText, numButton) = createRefs()

data.forEach { item ->
if (item is TopGroupOrgData) {
TopGroupOrg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ class CreatePinF : Fragment() {
private val args: CreatePinFArgs by navArgs()
private var composeView: ComposeView? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModel.doInit(args.flowType)
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down
12 changes: 10 additions & 2 deletions pin/src/main/java/ua/gov/diia/pin/ui/create/create/CreatePinVM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ua.gov.diia.pin.ui.create.create

import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.channels.BufferOverflow
Expand All @@ -26,7 +27,9 @@ import ua.gov.diia.ui_base.navigation.BaseNavigation
import javax.inject.Inject

@HiltViewModel
class CreatePinVM @Inject constructor() : ViewModel() {
class CreatePinVM @Inject constructor(
private val savedStateHandle: SavedStateHandle
) : ViewModel() {

private val _uiData = mutableStateListOf<UIElementData>()
val uiData: SnapshotStateList<UIElementData> = _uiData
Expand All @@ -37,7 +40,12 @@ class CreatePinVM @Inject constructor() : ViewModel() {
)
val navigation = _navigation.asSharedFlow()

fun doInit(flowType: CreatePinFlowType) {
init {
doInit()
}

fun doInit() {
val flowType: CreatePinFlowType = savedStateHandle["flowType"] ?: return

var title = R.string.create_screen_title_text
var descText = R.string.create_screen_description_text
Expand Down