Отображение юзера начало
This commit is contained in:
parent
90881142f3
commit
4dafc261ef
@ -47,7 +47,7 @@ class RootActivity : AppCompatActivity() {
|
|||||||
fragment<QrScanFragment, QrScanDestination>()
|
fragment<QrScanFragment, QrScanDestination>()
|
||||||
fragment<EntryListFragment, EntryListDestination>()
|
fragment<EntryListFragment, EntryListDestination>()
|
||||||
fragment<SearchUserFragment, SearchUserDestination>()
|
fragment<SearchUserFragment, SearchUserDestination>()
|
||||||
fragment<UserInfoFragment, UserInfoDestination>()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import ru.myitschool.work.R
|
|||||||
import ru.myitschool.work.databinding.FragmentSearchUserBinding
|
import ru.myitschool.work.databinding.FragmentSearchUserBinding
|
||||||
import ru.myitschool.work.ui.entrylist.EntryListFragment
|
import ru.myitschool.work.ui.entrylist.EntryListFragment
|
||||||
import ru.myitschool.work.ui.profile.ProfileDestination
|
import ru.myitschool.work.ui.profile.ProfileDestination
|
||||||
import ru.myitschool.work.ui.userInfo.UserInfoDestination
|
|
||||||
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -53,12 +53,7 @@ class SearchUserFragment : Fragment(R.layout.fragment_search_user) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
is SearchUserViewModel.Action.OpenInfo ->{
|
is SearchUserViewModel.Action.OpenInfo ->{
|
||||||
val bundle = Bundle().apply {
|
//TODO отобразить инфу о юзере
|
||||||
putString("username", action.userName)
|
|
||||||
}
|
|
||||||
findNavController().navigate(UserInfoDestination) {
|
|
||||||
popUpTo<UserInfoDestination> { inclusive = true }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
package ru.myitschool.work.ui.userInfo
|
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data object UserInfoDestination
|
|
@ -1,58 +0,0 @@
|
|||||||
package ru.myitschool.work.ui.userInfo
|
|
||||||
|
|
||||||
import ru.myitschool.work.ui.searchuser.SearchUserViewModel
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.View
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
|
||||||
import ru.myitschool.work.R
|
|
||||||
import ru.myitschool.work.databinding.FragmentSearchUserBinding
|
|
||||||
import ru.myitschool.work.databinding.FragmentUserInfoBinding
|
|
||||||
import ru.myitschool.work.ui.profile.ProfileDestination
|
|
||||||
import ru.myitschool.work.ui.searchuser.SearchUserDestination
|
|
||||||
import ru.myitschool.work.utils.collectWhenStarted
|
|
||||||
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
|
||||||
class UserInfoFragment : Fragment(R.layout.fragment_user_info) {
|
|
||||||
|
|
||||||
private var _binding: FragmentUserInfoBinding? = null
|
|
||||||
private val binding: FragmentUserInfoBinding get() = _binding!!
|
|
||||||
|
|
||||||
|
|
||||||
private val viewModel: UserInfoViewModel by viewModels()
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
_binding = FragmentUserInfoBinding.bind(view)
|
|
||||||
|
|
||||||
initCallback()
|
|
||||||
subscribe()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initCallback() {
|
|
||||||
binding.floatingActionButton2.setOnClickListener { viewModel.closeSearchUser() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun subscribe() {
|
|
||||||
viewModel.action.collectWhenStarted(this) { action ->
|
|
||||||
when (action) {
|
|
||||||
is UserInfoViewModel.Action.OpenProfile -> {
|
|
||||||
findNavController().navigate(SearchUserDestination) {
|
|
||||||
popUpTo<SearchUserDestination> { inclusive = true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
package ru.myitschool.work.ui.userInfo
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import kotlinx.coroutines.flow.asSharedFlow
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import ru.myitschool.work.utils.MutablePublishFlow
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
|
||||||
class UserInfoViewModel @Inject constructor(
|
|
||||||
@ApplicationContext private val context: Context,
|
|
||||||
) : ViewModel() {
|
|
||||||
private val _action = MutablePublishFlow<Action>()
|
|
||||||
val action = _action.asSharedFlow()
|
|
||||||
|
|
||||||
fun closeSearchUser(){
|
|
||||||
viewModelScope.launch {
|
|
||||||
_action.emit(Action.OpenProfile)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sealed interface Action {
|
|
||||||
data object OpenProfile: Action
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,24 +4,20 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:padding="16dp"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_height="match_parent">
|
android:padding="16dp">
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/floatingActionButton2"
|
|
||||||
style="@style/Theme.UiTemplate.FAB.Gray"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:clickable="true"
|
|
||||||
android:src="@drawable/ic_back" />
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="120dp"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="120dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/photo2"
|
android:id="@+id/photo2"
|
||||||
android:layout_width="120dp"
|
android:layout_width="120dp"
|
||||||
@ -44,6 +40,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/fullname"
|
android:id="@+id/fullname"
|
||||||
style="@style/Theme.UiTemplate.TextH3"
|
style="@style/Theme.UiTemplate.TextH3"
|
||||||
@ -71,20 +68,21 @@
|
|||||||
style="@style/Theme.UiTemplate.TextH4_2"
|
style="@style/Theme.UiTemplate.TextH4_2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_gravity="center"
|
|
||||||
tools:text="@tools:sample/date/hhmm" />
|
tools:text="@tools:sample/date/hhmm" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/login"
|
android:id="@+id/login"
|
||||||
|
style="@style/Theme.UiTemplate.OutlineButton.Error"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/Theme.UiTemplate.OutlineButton.Error"
|
|
||||||
android:layout_marginTop="100dp"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
android:text="@string/admin_block" />
|
android:text="@string/admin_block" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
x
Reference in New Issue
Block a user