Начало работы с бекендом
This commit is contained in:
parent
9925b37422
commit
5b5a0e643c
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Проект команды дроидо коты
|
||||
Открыть в студии и собрать как норм проект/n
|
||||
В файле ```Constants.kt``` есть параметр ```SERVER_ADDRESS``` который отвечает за адрес сервера
|
10
app/src/main/java/ru/myitschool/work/data/dto/LoginDto.kt
Normal file
10
app/src/main/java/ru/myitschool/work/data/dto/LoginDto.kt
Normal 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?
|
||||
)
|
@ -1,7 +1,9 @@
|
||||
package ru.myitschool.work.data.source
|
||||
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Path
|
||||
|
||||
interface AuthorizationApi {
|
||||
@ -9,4 +11,9 @@ interface AuthorizationApi {
|
||||
suspend fun checkLogin(
|
||||
@Path("username") username: String
|
||||
) : Response<Unit>
|
||||
|
||||
@GET("api/login")
|
||||
suspend fun login(
|
||||
@Body content: AccountApi
|
||||
): Response<Unit>
|
||||
}
|
@ -40,7 +40,7 @@ class EntryListFragment : Fragment(R.layout.fragment_entry_list) {
|
||||
viewModel.action.collectWhenStarted(this) { action ->
|
||||
when (action) {
|
||||
is EntryListViewModel.Action.OpenProfile -> {
|
||||
findNavController().navigate(LoginDestination) {
|
||||
findNavController().navigate(ProfileDestination) {
|
||||
popUpTo<ProfileDestination> { inclusive = true }
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,11 @@ class LoginFragment : Fragment(R.layout.fragment_login) {
|
||||
viewModel.inputLogin(s.toString())
|
||||
}
|
||||
})
|
||||
binding.password.addTextChangedListener(object : TextChangedListener() {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
viewModel.inputLogin(s.toString())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -1,151 +1,156 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
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">
|
||||
|
||||
<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" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
|
||||
<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
|
||||
android:id="@+id/textView"
|
||||
style="@style/Theme.UiTemplate.TextH1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/profile_main_textview"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/logout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
style="@style/Theme.UiTemplate.TextH1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/profile_main_textview"
|
||||
android:textAlignment="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="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"
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
app:layout_constraintBottom_toTopOf="@+id/scan"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
<TextView
|
||||
android:id="@+id/fullname"
|
||||
style="@style/Theme.UiTemplate.TextH3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
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" />
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/photo2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_margin="5dp"
|
||||
android:elevation="10dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/scan"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<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" />
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/photo"
|
||||
style="@style/roundedImageView"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:contentDescription="@null"
|
||||
|
||||
<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" />
|
||||
app:layout_constraintBottom_toTopOf="@+id/scan"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:textAlignment="center"
|
||||
android:visibility="gone"
|
||||
style="@style/Theme.UiTemplate.TextH5"
|
||||
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" />
|
||||
<TextView
|
||||
android:id="@+id/fullname"
|
||||
style="@style/Theme.UiTemplate.TextH3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
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
|
||||
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
|
||||
android:id="@+id/logout"
|
||||
style="@style/Theme.UiTemplate.FAB.Gray"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/profile_refresh_button"
|
||||
android:src="@drawable/ic_logout"
|
||||
app:elevation="0dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/logout"
|
||||
style="@style/Theme.UiTemplate.FAB.Gray"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/profile_refresh_button"
|
||||
android:src="@drawable/ic_logout"
|
||||
android:visibility="visible"
|
||||
app:elevation="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/scan"
|
||||
style="@style/Theme.UiTemplate.FAB.AccentColor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/profile_scan_button"
|
||||
android:src="@drawable/ic_qr_code"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/scan"
|
||||
style="@style/Theme.UiTemplate.FAB.AccentColor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/profile_scan_button"
|
||||
android:src="@drawable/ic_qr_code"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/entry_list"
|
||||
style="@style/Theme.UiTemplate.FAB.AccentColor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="320dp"
|
||||
android:contentDescription="@string/profile_scan_button"
|
||||
android:src="@drawable/icon_list"
|
||||
app:maxImageSize="30dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/entry_list"
|
||||
style="@style/Theme.UiTemplate.FAB.AccentColor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/profile_scan_button"
|
||||
android:src="@drawable/icon_list"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:maxImageSize="30dp" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
@ -3,7 +3,7 @@
|
||||
<style name="Base.Theme.UiTemplate" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<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:colorBackground">@color/white</item>
|
||||
</style>
|
||||
|
Loading…
x
Reference in New Issue
Block a user