Merge remote-tracking branch 'origin/main'
# Conflicts: # app/build.gradle.kts # app/src/main/res/layout/fragment_entry_list.xml
This commit is contained in:
commit
a544fcd513
@ -35,6 +35,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||||
implementation("androidx.legacy:legacy-support-v4:1.0.0")
|
implementation("androidx.legacy:legacy-support-v4:1.0.0")
|
||||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.7")
|
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.7")
|
||||||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
|
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
|
||||||
|
@ -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.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import ru.myitschool.work.R
|
import ru.myitschool.work.R
|
||||||
@ -22,11 +23,20 @@ class ProfileFragment : Fragment(R.layout.fragment_profile) {
|
|||||||
|
|
||||||
private val viewModel: ProfileViewModel by viewModels()
|
private val viewModel: ProfileViewModel by viewModels()
|
||||||
|
|
||||||
|
private lateinit var swipeRefreshLayout: SwipeRefreshLayout
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
_binding = FragmentProfileBinding.bind(view)
|
_binding = FragmentProfileBinding.bind(view)
|
||||||
|
|
||||||
initCallback()
|
initCallback()
|
||||||
subscribe()
|
subscribe()
|
||||||
|
|
||||||
|
swipeRefreshLayout = binding.swipeRefreshLayout
|
||||||
|
|
||||||
|
swipeRefreshLayout.setOnRefreshListener {
|
||||||
|
viewModel.updateUserInfo()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun subscribe() {
|
private fun subscribe() {
|
||||||
@ -36,11 +46,15 @@ class ProfileFragment : Fragment(R.layout.fragment_profile) {
|
|||||||
binding.loading.visibleOrGone(state is ProfileViewModel.State.Loading)
|
binding.loading.visibleOrGone(state is ProfileViewModel.State.Loading)
|
||||||
|
|
||||||
when(state) {
|
when(state) {
|
||||||
is ProfileViewModel.State.Loading -> Unit
|
is ProfileViewModel.State.Loading -> {
|
||||||
|
swipeRefreshLayout.isRefreshing = true
|
||||||
|
}
|
||||||
is ProfileViewModel.State.Error -> {
|
is ProfileViewModel.State.Error -> {
|
||||||
|
swipeRefreshLayout.isRefreshing = false
|
||||||
binding.error.text = state.errorText
|
binding.error.text = state.errorText
|
||||||
}
|
}
|
||||||
is ProfileViewModel.State.Show -> {
|
is ProfileViewModel.State.Show -> {
|
||||||
|
swipeRefreshLayout.isRefreshing = false
|
||||||
binding.fullname.text = state.fullname
|
binding.fullname.text = state.fullname
|
||||||
binding.position.text = state.position
|
binding.position.text = state.position
|
||||||
binding.lastEntry.text = state.lastEntry
|
binding.lastEntry.text = state.lastEntry
|
||||||
|
@ -52,7 +52,7 @@ class ProfileViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUserInfo() {
|
fun updateUserInfo() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
_state.update { State.Loading }
|
_state.update { State.Loading }
|
||||||
getUserInfoUseCase.get().invoke().fold(
|
getUserInfoUseCase.get().invoke().fold(
|
||||||
|
@ -1,37 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout 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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/frameLayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="16dp"
|
tools:context=".ui.entrylast.EntryListFragment">
|
||||||
tools:context=".ui.entrylist.EntryListFragment">
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/close"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:clickable="true"
|
|
||||||
android:src="@drawable/ic_close"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView3"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:text="Hello" />
|
||||||
android:text="TextView"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/close"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/close"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/close" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
</FrameLayout>
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/close" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -12,18 +12,38 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
app:constraint_referenced_ids="text_welcome, input_username, input_password, login"
|
app:constraint_referenced_ids="log"
|
||||||
app:flow_verticalGap="32dp"
|
app:flow_verticalGap="32dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/log"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_welcome"
|
android:id="@+id/text_login"
|
||||||
style="@style/Theme.UiTemplate.TextH1"
|
style="@style/Theme.UiTemplate.TextH1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/login_login" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_welcome"
|
||||||
|
style="@style/Theme.UiTemplate.TextH4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/login_welcome" />
|
android:text="@string/login_welcome" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_login_small"
|
||||||
|
style="@style/Theme.UiTemplate.TextH4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginBottom="50dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/login_text" />
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/Theme.UiTemplate.Input"
|
style="@style/Theme.UiTemplate.Input"
|
||||||
android:id="@+id/input_username"
|
android:id="@+id/input_username"
|
||||||
@ -46,11 +66,12 @@
|
|||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/Theme.UiTemplate.Input"
|
style="@style/Theme.UiTemplate.Input"
|
||||||
android:id="@+id/input_password"
|
android:id="@+id/input_password"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
app:layout_constraintWidth_max="400dp"
|
app:layout_constraintWidth_max="400dp"
|
||||||
app:layout_constraintWidth_percent="0.8"
|
app:layout_constraintWidth_percent="0.8"
|
||||||
android:layout_height="58dp">
|
android:layout_height="58dp"
|
||||||
|
tools:ignore="MissingConstraints">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/password"
|
android:id="@+id/password"
|
||||||
@ -69,10 +90,13 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/login"
|
android:id="@+id/login"
|
||||||
android:layout_width="250dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/Theme.UiTemplate.Button"
|
style="@style/Theme.UiTemplate.Button"
|
||||||
|
android:layout_marginTop="48dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:text="@string/login_button" />
|
android:text="@string/login_button" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/loading"
|
android:id="@+id/loading"
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
@ -118,3 +123,4 @@
|
|||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
@ -4,5 +4,7 @@
|
|||||||
<string name="login_button">Login</string>
|
<string name="login_button">Login</string>
|
||||||
<string name="login_error">Something wrong</string>
|
<string name="login_error">Something wrong</string>
|
||||||
<string name="login_password_hint">Password</string>
|
<string name="login_password_hint">Password</string>
|
||||||
<string name="login_welcome">Добро пожаловать</string>
|
<string name="login_welcome">Добро пожаловать!</string>
|
||||||
|
<string name="login_text">Войдите чтобы продолжить</string>
|
||||||
|
<string name="login_login">Войти</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user