Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
e656d452f2
@ -35,6 +35,11 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||
implementation("androidx.legacy:legacy-support-v4:1.0.0")
|
||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.7")
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
|
||||
implementation("androidx.fragment:fragment-ktx:1.5.6")
|
||||
defaultLibrary()
|
||||
|
||||
implementation(Dependencies.AndroidX.activity)
|
||||
|
@ -0,0 +1,38 @@
|
||||
package ru.myitschool.work.ui.entrylast
|
||||
|
||||
import androidx.fragment.app.viewModels
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import ru.myitschool.work.R
|
||||
import ru.myitschool.work.databinding.FragmentEntryListBinding
|
||||
import ru.myitschool.work.databinding.FragmentLoginBinding
|
||||
import ru.myitschool.work.ui.login.LoginViewModel
|
||||
|
||||
class EntryListFragment : Fragment(R.layout.fragment_entry_list) {
|
||||
|
||||
private var _binding: FragmentEntryListBinding? = null
|
||||
private val binding: FragmentEntryListBinding get() = _binding!!
|
||||
|
||||
private val viewModel: LoginViewModel by viewModels()
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentEntryListBinding.bind(view)
|
||||
|
||||
}
|
||||
private fun subscribe(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
private fun initCallback(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
_binding = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.myitschool.work.ui.entrylast
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class EntryListViewModel : ViewModel() {
|
||||
// TODO: Implement the ViewModel
|
||||
}
|
@ -5,6 +5,7 @@ import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.squareup.picasso.Picasso
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import ru.myitschool.work.R
|
||||
@ -22,11 +23,20 @@ class ProfileFragment : Fragment(R.layout.fragment_profile) {
|
||||
|
||||
private val viewModel: ProfileViewModel by viewModels()
|
||||
|
||||
private lateinit var swipeRefreshLayout: SwipeRefreshLayout
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentProfileBinding.bind(view)
|
||||
|
||||
initCallback()
|
||||
subscribe()
|
||||
|
||||
swipeRefreshLayout = binding.swipeRefreshLayout
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener {
|
||||
viewModel.updateUserInfo()
|
||||
}
|
||||
}
|
||||
|
||||
private fun subscribe() {
|
||||
@ -36,11 +46,15 @@ class ProfileFragment : Fragment(R.layout.fragment_profile) {
|
||||
binding.loading.visibleOrGone(state is ProfileViewModel.State.Loading)
|
||||
|
||||
when(state) {
|
||||
is ProfileViewModel.State.Loading -> Unit
|
||||
is ProfileViewModel.State.Loading -> {
|
||||
swipeRefreshLayout.isRefreshing = true
|
||||
}
|
||||
is ProfileViewModel.State.Error -> {
|
||||
swipeRefreshLayout.isRefreshing = false
|
||||
binding.error.text = state.errorText
|
||||
}
|
||||
is ProfileViewModel.State.Show -> {
|
||||
swipeRefreshLayout.isRefreshing = false
|
||||
binding.fullname.text = state.fullname
|
||||
binding.position.text = state.position
|
||||
binding.lastEntry.text = state.lastEntry
|
||||
|
@ -52,7 +52,7 @@ class ProfileViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateUserInfo() {
|
||||
fun updateUserInfo() {
|
||||
viewModelScope.launch {
|
||||
_state.update { State.Loading }
|
||||
getUserInfoUseCase.get().invoke().fold(
|
||||
|
13
app/src/main/res/layout/fragment_entry_list.xml
Normal file
13
app/src/main/res/layout/fragment_entry_list.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.entrylast.EntryListFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Hello" />
|
||||
|
||||
</FrameLayout>
|
@ -1,7 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
@ -117,4 +122,5 @@
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
@ -4,4 +4,5 @@ plugins {
|
||||
kotlinJvm version Version.Kotlin.language apply false
|
||||
kotlinAnnotationProcessor version Version.Kotlin.language apply false
|
||||
id("com.google.dagger.hilt.android") version "2.51.1" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.9.24" apply false
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user