Начало работы с бекендом
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
|
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>
|
||||||
}
|
}
|
@ -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 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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() {
|
||||||
|
@ -1,16 +1,30 @@
|
|||||||
<?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
|
<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">
|
||||||
|
|
||||||
|
<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
|
<androidx.constraintlayout.widget.Group
|
||||||
android:id="@+id/showState"
|
android:id="@+id/showState"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
@ -23,8 +37,9 @@
|
|||||||
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:layout_marginTop="8dp"
|
||||||
android:text="@string/profile_main_textview"
|
android:text="@string/profile_main_textview"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/logout"
|
android:textAlignment="center"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
@ -37,24 +52,26 @@
|
|||||||
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
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/photo2"
|
android:id="@+id/photo2"
|
||||||
android:layout_width="120dp"
|
android:layout_width="120dp"
|
||||||
android:layout_height="120dp"
|
android:layout_height="120dp"
|
||||||
app:cardCornerRadius="12dp"
|
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
|
android:elevation="10dp"
|
||||||
|
app:cardCornerRadius="12dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/scan"
|
app:layout_constraintBottom_toTopOf="@+id/scan"
|
||||||
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">
|
||||||
android:elevation="10dp">
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:id="@+id/photo"
|
android:id="@+id/photo"
|
||||||
|
style="@style/roundedImageView"
|
||||||
android:layout_width="120dp"
|
android:layout_width="120dp"
|
||||||
android:layout_height="120dp"
|
android:layout_height="120dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
style="@style/roundedImageView"
|
|
||||||
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/scan"
|
app:layout_constraintBottom_toTopOf="@+id/scan"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -62,6 +79,7 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:src="@tools:sample/avatars" />
|
tools:src="@tools:sample/avatars" />
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/fullname"
|
android:id="@+id/fullname"
|
||||||
style="@style/Theme.UiTemplate.TextH3"
|
style="@style/Theme.UiTemplate.TextH3"
|
||||||
@ -98,20 +116,6 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/position"
|
app:layout_constraintTop_toBottomOf="@+id/position"
|
||||||
tools:text="@tools:sample/date/hhmm" />
|
tools:text="@tools:sample/date/hhmm" />
|
||||||
|
|
||||||
<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" />
|
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/logout"
|
android:id="@+id/logout"
|
||||||
@ -120,9 +124,11 @@
|
|||||||
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"
|
||||||
|
android:visibility="visible"
|
||||||
app:elevation="0dp"
|
app:elevation="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/textView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="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"
|
||||||
@ -139,12 +145,11 @@
|
|||||||
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:maxImageSize="30dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:maxImageSize="30dp" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user