From 5fdd4fae4b003c61088c417bec99c455010c31d3 Mon Sep 17 00:00:00 2001 From: Juja2025 Date: Wed, 19 Feb 2025 10:53:14 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D1=87=D0=B8=D0=BD=D1=8E=20=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_login.xml | 17 ++++- app/src/main/res/layout/fragment_profile.xml | 71 +++++++++++--------- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/app/src/main/res/layout/fragment_login.xml b/app/src/main/res/layout/fragment_login.xml index 2a92b15..eb72ce0 100644 --- a/app/src/main/res/layout/fragment_login.xml +++ b/app/src/main/res/layout/fragment_login.xml @@ -12,16 +12,23 @@ android:orientation="vertical" android:paddingStart="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:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + android:layout_height="58dp" + tools:ignore="MissingConstraints"> + - - + - + - + - - - - + + + + - + \ No newline at end of file From 59d6519f5692a05c8c51d1c9a9d6452a206ab67e Mon Sep 17 00:00:00 2001 From: v228a Date: Wed, 19 Feb 2025 11:35:14 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D1=81=D0=B2=D0=B0=D0=B9=D0=BF=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 1 + .../work/ui/profile/ProfileFragment.kt | 16 +++++++++++++++- .../work/ui/profile/ProfileViewModel.kt | 2 +- app/src/main/res/layout/fragment_profile.xml | 10 ++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a28d464..62ff353 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -35,6 +35,7 @@ android { } dependencies { + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") defaultLibrary() implementation(Dependencies.AndroidX.activity) diff --git a/app/src/main/java/ru/myitschool/work/ui/profile/ProfileFragment.kt b/app/src/main/java/ru/myitschool/work/ui/profile/ProfileFragment.kt index ea901a4..ae9b7a7 100644 --- a/app/src/main/java/ru/myitschool/work/ui/profile/ProfileFragment.kt +++ b/app/src/main/java/ru/myitschool/work/ui/profile/ProfileFragment.kt @@ -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 diff --git a/app/src/main/java/ru/myitschool/work/ui/profile/ProfileViewModel.kt b/app/src/main/java/ru/myitschool/work/ui/profile/ProfileViewModel.kt index b4210fb..680cf1d 100644 --- a/app/src/main/java/ru/myitschool/work/ui/profile/ProfileViewModel.kt +++ b/app/src/main/java/ru/myitschool/work/ui/profile/ProfileViewModel.kt @@ -52,7 +52,7 @@ class ProfileViewModel @Inject constructor( } } - private fun updateUserInfo() { + fun updateUserInfo() { viewModelScope.launch { _state.update { State.Loading } getUserInfoUseCase.get().invoke().fold( diff --git a/app/src/main/res/layout/fragment_profile.xml b/app/src/main/res/layout/fragment_profile.xml index e92178b..1b47083 100644 --- a/app/src/main/res/layout/fragment_profile.xml +++ b/app/src/main/res/layout/fragment_profile.xml @@ -1,7 +1,12 @@ - + @@ -117,4 +122,5 @@ app:layout_constraintEnd_toEndOf="parent" /> - \ No newline at end of file + + \ No newline at end of file From 122ef2efce37a8993a8a48adc0c9ca2586a3c4ac Mon Sep 17 00:00:00 2001 From: v228a Date: Wed, 19 Feb 2025 11:45:49 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A1=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=D0=B3=D0=BE=20=D0=B4=D0=BB=D1=8F=20=D0=B0?= =?UTF-8?q?=D0=B4=D0=BC=D0=B8=D0=BD=D0=B0=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB?= =?UTF-8?q?=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 4 ++ .../work/ui/entrylast/EntryListFragment.kt | 38 +++++++++++++++++++ .../work/ui/entrylast/EntryListViewModel.kt | 7 ++++ .../main/res/layout/fragment_entry_list.xml | 13 +++++++ build.gradle.kts | 1 + 5 files changed, 63 insertions(+) create mode 100644 app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListFragment.kt create mode 100644 app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListViewModel.kt create mode 100644 app/src/main/res/layout/fragment_entry_list.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 62ff353..941629f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -36,6 +36,10 @@ 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) diff --git a/app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListFragment.kt b/app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListFragment.kt new file mode 100644 index 0000000..ecdc58c --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListFragment.kt @@ -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() + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListViewModel.kt b/app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListViewModel.kt new file mode 100644 index 0000000..2476f6d --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/ui/entrylast/EntryListViewModel.kt @@ -0,0 +1,7 @@ +package ru.myitschool.work.ui.entrylast + +import androidx.lifecycle.ViewModel + +class EntryListViewModel : ViewModel() { + // TODO: Implement the ViewModel +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_entry_list.xml b/app/src/main/res/layout/fragment_entry_list.xml new file mode 100644 index 0000000..4aeab52 --- /dev/null +++ b/app/src/main/res/layout/fragment_entry_list.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 4a92e0e..cf1d650 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 } \ No newline at end of file From 2573b25371f1e95aaa2990a252af0a8809c1b10d Mon Sep 17 00:00:00 2001 From: Juja2025 Date: Wed, 19 Feb 2025 11:51:44 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=B4?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D0=B9=D0=BD=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_login.xml | 27 ++++++++++++++++------ app/src/main/res/values/strings_login.xml | 4 +++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/src/main/res/layout/fragment_login.xml b/app/src/main/res/layout/fragment_login.xml index eb72ce0..0a4589a 100644 --- a/app/src/main/res/layout/fragment_login.xml +++ b/app/src/main/res/layout/fragment_login.xml @@ -24,13 +24,26 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> + android:text="@string/login_login" /> + + diff --git a/app/src/main/res/values/strings_login.xml b/app/src/main/res/values/strings_login.xml index 888f173..6e2d84a 100644 --- a/app/src/main/res/values/strings_login.xml +++ b/app/src/main/res/values/strings_login.xml @@ -4,5 +4,7 @@ Login Something wrong Password - Добро пожаловать + Добро пожаловать! + Войдите чтобы продолжить + Войти \ No newline at end of file