Merge remote-tracking branch 'origin/main'

This commit is contained in:
Juja2025 2025-02-19 15:34:49 +03:00
commit e00a7aa591
7 changed files with 162 additions and 132 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Проект команды дроидо коты
Открыть в студии и собрать как норм проект/n
В файле ```Constants.kt``` есть параметр ```SERVER_ADDRESS``` который отвечает за адрес сервера

View File

@ -0,0 +1,10 @@
package ru.myitschool.work.data.dto
import com.google.gson.annotations.SerializedName
class LoginDto(
@SerializedName("username")
val username: String?,
@SerializedName("password")
val password: String?
)

View File

@ -1,7 +1,9 @@
package ru.myitschool.work.data.source package ru.myitschool.work.data.source
import retrofit2.Response import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path import retrofit2.http.Path
interface AuthorizationApi { interface AuthorizationApi {
@ -9,4 +11,9 @@ interface AuthorizationApi {
suspend fun checkLogin( suspend fun checkLogin(
@Path("username") username: String @Path("username") username: String
) : Response<Unit> ) : Response<Unit>
@GET("api/login")
suspend fun login(
@Body content: AccountApi
): Response<Unit>
} }

View File

@ -40,7 +40,7 @@ class EntryListFragment : Fragment(R.layout.fragment_entry_list) {
viewModel.action.collectWhenStarted(this) { action -> viewModel.action.collectWhenStarted(this) { action ->
when (action) { when (action) {
is EntryListViewModel.Action.OpenProfile -> { is EntryListViewModel.Action.OpenProfile -> {
findNavController().navigate(LoginDestination) { findNavController().navigate(ProfileDestination) {
popUpTo<ProfileDestination> { inclusive = true } popUpTo<ProfileDestination> { inclusive = true }
} }
} }

View File

@ -64,6 +64,11 @@ class LoginFragment : Fragment(R.layout.fragment_login) {
viewModel.inputLogin(s.toString()) viewModel.inputLogin(s.toString())
} }
}) })
binding.password.addTextChangedListener(object : TextChangedListener() {
override fun afterTextChanged(s: Editable?) {
viewModel.inputLogin(s.toString())
}
})
} }
override fun onDestroyView() { override fun onDestroyView() {

View File

@ -1,151 +1,156 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/showState" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="match_parent"
android:layout_height="0dp" android:padding="16dp">
app:constraint_referenced_ids="logout,fullname,photo2,position,lastEntry,scan" />
<TextView
android:id="@+id/error"
style="@style/Theme.UiTemplate.TextH5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:textAlignment="center"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Something wrong. Try later" />
<androidx.constraintlayout.widget.Group
android:id="@+id/showState"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="logout,fullname,photo2,position,lastEntry,scan" />
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textView"
style="@style/Theme.UiTemplate.TextH1" style="@style/Theme.UiTemplate.TextH1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/profile_main_textview" android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="@+id/logout" android:text="@string/profile_main_textview"
app:layout_constraintStart_toStartOf="parent" android:textAlignment="center"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar <ProgressBar
android:id="@+id/loading" android:id="@+id/loading"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
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" />
<androidx.cardview.widget.CardView
android:id="@+id/photo2"
android:layout_width="120dp"
android:layout_height="120dp"
app:cardCornerRadius="12dp"
android:layout_margin="5dp"
app:layout_constraintBottom_toTopOf="@+id/scan"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:elevation="10dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/photo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginBottom="16dp"
android:contentDescription="@null"
style="@style/roundedImageView"
app:layout_constraintBottom_toTopOf="@+id/scan" <androidx.cardview.widget.CardView
app:layout_constraintEnd_toEndOf="parent" android:id="@+id/photo2"
app:layout_constraintStart_toStartOf="parent" android:layout_width="120dp"
app:layout_constraintTop_toTopOf="parent" android:layout_height="120dp"
tools:src="@tools:sample/avatars" /> android:layout_margin="5dp"
</androidx.cardview.widget.CardView> android:elevation="10dp"
<TextView app:cardCornerRadius="12dp"
android:id="@+id/fullname" app:layout_constraintBottom_toTopOf="@+id/scan"
style="@style/Theme.UiTemplate.TextH3" app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp" app:layout_constraintStart_toStartOf="parent"
android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent">
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/photo2"
tools:text="@tools:sample/full_names" />
<TextView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/position" android:id="@+id/photo"
style="@style/Theme.UiTemplate.TextH4" style="@style/roundedImageView"
android:layout_width="0dp" android:layout_width="120dp"
android:layout_height="wrap_content" android:layout_height="120dp"
android:layout_marginTop="16dp" android:layout_marginBottom="16dp"
app:layout_constraintEnd_toEndOf="@+id/fullname" android:contentDescription="@null"
app:layout_constraintStart_toStartOf="@+id/fullname"
app:layout_constraintTop_toBottomOf="@+id/fullname"
tools:text="@tools:sample/cities" />
<TextView app:layout_constraintBottom_toTopOf="@+id/scan"
android:id="@+id/lastEntry" app:layout_constraintEnd_toEndOf="parent"
style="@style/Theme.UiTemplate.TextH4_2" app:layout_constraintStart_toStartOf="parent"
android:layout_width="wrap_content" app:layout_constraintTop_toTopOf="parent"
android:layout_height="wrap_content" tools:src="@tools:sample/avatars" />
android:layout_marginHorizontal="16dp" </androidx.cardview.widget.CardView>
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="@+id/fullname"
app:layout_constraintStart_toStartOf="@+id/fullname"
app:layout_constraintTop_toBottomOf="@+id/position"
tools:text="@tools:sample/date/hhmm" />
<TextView <TextView
android:id="@+id/error" android:id="@+id/fullname"
android:layout_width="0dp" style="@style/Theme.UiTemplate.TextH3"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_marginHorizontal="16dp" android:layout_height="wrap_content"
android:textAlignment="center" android:layout_marginHorizontal="16dp"
android:visibility="gone" android:layout_marginTop="16dp"
style="@style/Theme.UiTemplate.TextH5" android:textAlignment="center"
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_toBottomOf="@+id/photo2"
app:layout_constraintTop_toTopOf="parent" tools:text="@tools:sample/full_names" />
tools:text="Something wrong. Try later" />
<TextView
android:id="@+id/position"
style="@style/Theme.UiTemplate.TextH4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="@+id/fullname"
app:layout_constraintStart_toStartOf="@+id/fullname"
app:layout_constraintTop_toBottomOf="@+id/fullname"
tools:text="@tools:sample/cities" />
<TextView
android:id="@+id/lastEntry"
style="@style/Theme.UiTemplate.TextH4_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="@+id/fullname"
app:layout_constraintStart_toStartOf="@+id/fullname"
app:layout_constraintTop_toBottomOf="@+id/position"
tools:text="@tools:sample/date/hhmm" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/logout" android:id="@+id/logout"
style="@style/Theme.UiTemplate.FAB.Gray" style="@style/Theme.UiTemplate.FAB.Gray"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/profile_refresh_button" android:contentDescription="@string/profile_refresh_button"
android:src="@drawable/ic_logout" android:src="@drawable/ic_logout"
app:elevation="0dp" android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent" app:elevation="0dp"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintBottom_toBottomOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/scan" android:id="@+id/scan"
style="@style/Theme.UiTemplate.FAB.AccentColor" style="@style/Theme.UiTemplate.FAB.AccentColor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/profile_scan_button" android:contentDescription="@string/profile_scan_button"
android:src="@drawable/ic_qr_code" android:src="@drawable/ic_qr_code"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/entry_list" android:id="@+id/entry_list"
style="@style/Theme.UiTemplate.FAB.AccentColor" style="@style/Theme.UiTemplate.FAB.AccentColor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="320dp" android:contentDescription="@string/profile_scan_button"
android:contentDescription="@string/profile_scan_button" android:src="@drawable/icon_list"
android:src="@drawable/icon_list" app:layout_constraintBottom_toBottomOf="parent"
app:maxImageSize="30dp" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:maxImageSize="30dp" />
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -3,7 +3,7 @@
<style name="Base.Theme.UiTemplate" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <style name="Base.Theme.UiTemplate" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your light theme here. --> <!-- Customize your light theme here. -->
<item name="colorPrimary">@color/AccentBlue</item> <item name="colorPrimary">@color/AccentBlue</item>
<item name="colorPrimaryDark">@color/white</item> <item name="colorPrimaryDark">@color/AccentBlue</item>
<item name="android:navigationBarColor">@color/white</item> <item name="android:navigationBarColor">@color/white</item>
<item name="android:colorBackground">@color/white</item> <item name="android:colorBackground">@color/white</item>
</style> </style>