Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Dec 6, 2023
1 parent 74f10b8 commit 7f477f6
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
package com.infomaniak.drive.ui.addFiles

import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
Expand All @@ -38,21 +39,34 @@ import com.infomaniak.drive.ui.MainViewModel
import com.infomaniak.drive.ui.fileList.fileShare.PermissionsAdapter
import com.infomaniak.drive.utils.AccountUtils
import com.infomaniak.drive.utils.showSnackbar
import com.infomaniak.lib.core.utils.*
import com.infomaniak.lib.core.utils.ApiErrorCode.Companion.translateError
import com.infomaniak.lib.core.utils.hideKeyboard
import com.infomaniak.lib.core.utils.hideProgress
import com.infomaniak.lib.core.utils.initProgress
import com.infomaniak.lib.core.utils.showProgress
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking

open class CreateFolderFragment : Fragment() {

protected var binding: FragmentCreateFolderBinding by safeBinding()
private var _binding: FragmentCreateFolderBinding? = null
protected val binding get() = _binding!! // This property is only valid between onCreateView and onDestroyView

protected val newFolderViewModel: NewFolderViewModel by navGraphViewModels(R.id.newFolderFragment)
protected val mainViewModel: MainViewModel by activityViewModels()

protected lateinit var adapter: PermissionsAdapter

private val folderNameTextWatcher by lazy {
object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = toggleCreateFolderButton()
override fun afterTextChanged(s: Editable?) = Unit
}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return FragmentCreateFolderBinding.inflate(inflater, container, false).also { binding = it }.root
return FragmentCreateFolderBinding.inflate(inflater, container, false).also { _binding = it }.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?): Unit = with(binding) {
Expand All @@ -66,9 +80,13 @@ open class CreateFolderFragment : Fragment() {
findNavController().popBackStack()
}

folderNameValueInput.doOnTextChanged { _, _, _, _ ->
toggleCreateFolderButton()
}
folderNameValueInput.addTextChangedListener(folderNameTextWatcher)
}

override fun onDestroyView() {
binding.folderNameValueInput.removeTextChangedListener(folderNameTextWatcher)
super.onDestroyView()
_binding = null
}

protected fun canInherit(userList: ArrayList<UserFileAccess>, teamList: ArrayList<Team>): Boolean {
Expand Down

0 comments on commit 7f477f6

Please sign in to comment.