История посещений ui
This commit is contained in:
parent
c5147cb105
commit
afa43a9d97
@ -1,6 +1,6 @@
|
|||||||
package ru.myitschool.work.core
|
package ru.myitschool.work.core
|
||||||
|
|
||||||
object Constants {
|
object Constants {
|
||||||
// const val SERVER_ADDRESS = "http://10.0.2.2:8080"
|
// const val SERVER_ADDRESS = "http://10.0.2.2:8080"
|
||||||
const val SERVER_ADDRESS = "https://nto.den4iksop.org"
|
const val SERVER_ADDRESS = "https://nto.den4iksop.org"
|
||||||
}
|
}
|
@ -7,11 +7,15 @@ import androidx.fragment.app.Fragment
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import ru.myitschool.work.R
|
import ru.myitschool.work.R
|
||||||
import ru.myitschool.work.databinding.FragmentEntryListBinding
|
import ru.myitschool.work.databinding.FragmentEntryListBinding
|
||||||
import ru.myitschool.work.databinding.FragmentLoginBinding
|
import ru.myitschool.work.databinding.FragmentLoginBinding
|
||||||
|
import ru.myitschool.work.ui.entrylist.adapter.AdapterEntryHistory
|
||||||
|
import ru.myitschool.work.ui.entrylist.adapter.EntryHistoryEntity
|
||||||
import ru.myitschool.work.ui.login.LoginDestination
|
import ru.myitschool.work.ui.login.LoginDestination
|
||||||
import ru.myitschool.work.ui.login.LoginViewModel
|
import ru.myitschool.work.ui.login.LoginViewModel
|
||||||
import ru.myitschool.work.ui.profile.ProfileDestination
|
import ru.myitschool.work.ui.profile.ProfileDestination
|
||||||
@ -32,9 +36,13 @@ class EntryListFragment : Fragment(R.layout.fragment_entry_list) {
|
|||||||
subscribe()
|
subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initCallback (){
|
private fun initCallback() {
|
||||||
binding.floatingActionButton2.setOnClickListener { viewModel.closeEntryList() }
|
binding.floatingActionButton2.setOnClickListener { viewModel.closeEntryList() }
|
||||||
}
|
|
||||||
|
|
||||||
|
binding.recyclerView.adapter = AdapterEntryHistory(viewModel.getEntryList())
|
||||||
|
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
private fun subscribe() {
|
private fun subscribe() {
|
||||||
viewModel.action.collectWhenStarted(this) { action ->
|
viewModel.action.collectWhenStarted(this) { action ->
|
||||||
|
@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||||||
import kotlinx.coroutines.flow.asSharedFlow
|
import kotlinx.coroutines.flow.asSharedFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import ru.myitschool.work.ui.entrylist.adapter.EntryHistoryEntity
|
||||||
import ru.myitschool.work.ui.profile.ProfileViewModel
|
import ru.myitschool.work.ui.profile.ProfileViewModel
|
||||||
import ru.myitschool.work.ui.profile.ProfileViewModel.Action
|
import ru.myitschool.work.ui.profile.ProfileViewModel.Action
|
||||||
import ru.myitschool.work.ui.profile.ProfileViewModel.State
|
import ru.myitschool.work.ui.profile.ProfileViewModel.State
|
||||||
@ -25,8 +26,19 @@ class EntryListViewModel @Inject constructor(
|
|||||||
private val _action = MutablePublishFlow<Action>()
|
private val _action = MutablePublishFlow<Action>()
|
||||||
val action = _action.asSharedFlow()
|
val action = _action.asSharedFlow()
|
||||||
|
|
||||||
// private val _state = MutableStateFlow<State>(initialState)
|
// Новый список данных
|
||||||
// val state = _state.asStateFlow()
|
private val entryList = listOf(
|
||||||
|
EntryHistoryEntity("type1", "2023-10-01T12:00:00", "id001"),
|
||||||
|
EntryHistoryEntity("type2", "2023-10-02T13:00:00", "id002"),
|
||||||
|
EntryHistoryEntity("type3", "2023-10-03T14:00:00", "id003"),
|
||||||
|
EntryHistoryEntity("type4", "2023-10-04T15:00:00", "id004"),
|
||||||
|
EntryHistoryEntity("type5", "2023-10-05T16:00:00", "id005")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Функция для получения данных
|
||||||
|
fun getEntryList(): List<EntryHistoryEntity> {
|
||||||
|
return entryList
|
||||||
|
}
|
||||||
|
|
||||||
fun closeEntryList(){
|
fun closeEntryList(){
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
@ -34,13 +46,7 @@ class EntryListViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sealed interface Action {
|
sealed interface Action {
|
||||||
data object OpenProfile: Action
|
data object OpenProfile: Action
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
// val initialState = State.Loading
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package ru.myitschool.work.ui.entrylist.adapter
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.core.graphics.drawable.toDrawable
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import ru.myitschool.work.R
|
||||||
|
|
||||||
|
class AdapterEntryHistory(private val datas: List<EntryHistoryEntity>) : RecyclerView
|
||||||
|
.Adapter<AdapterEntryHistory.MyViewHolder>() {
|
||||||
|
|
||||||
|
class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
var dateText: TextView = itemView.findViewById(R.id.time)
|
||||||
|
val identificatorText: TextView = itemView.findViewById(R.id.identificator)
|
||||||
|
val typeText: TextView = itemView.findViewById(R.id.type)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
|
||||||
|
val itemView = LayoutInflater.from(parent.context)
|
||||||
|
.inflate(R.layout.card_view, parent, false)
|
||||||
|
return MyViewHolder(itemView)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
|
||||||
|
holder.dateText.text = datas[position].time.toString()
|
||||||
|
holder.identificatorText.text = datas[position].identificator.toString()
|
||||||
|
holder.typeText.text = datas[position].type.toString()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = datas.size
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.myitschool.work.ui.entrylist.adapter
|
||||||
|
|
||||||
|
class EntryHistoryEntity(
|
||||||
|
val type: String,
|
||||||
|
val time: String,
|
||||||
|
val identificator: String
|
||||||
|
)
|
9
app/src/main/res/drawable/ic_admin.xml
Normal file
9
app/src/main/res/drawable/ic_admin.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960">
|
||||||
|
<path
|
||||||
|
android:pathData="M222,705q63,-40 124.5,-60.5T480,624q72,0 134,20.5T739,705q44,-54 62.5,-109T820,480q0,-145 -97.5,-242.5T480,140q-145,0 -242.5,97.5T140,480q0,61 19,116t63,109ZM479.81,510q-57.81,0 -97.31,-39.69 -39.5,-39.68 -39.5,-97.5 0,-57.81 39.69,-97.31 39.68,-39.5 97.5,-39.5 57.81,0 97.31,39.69 39.5,39.68 39.5,97.5 0,57.81 -39.69,97.31 -39.68,39.5 -97.5,39.5ZM479.6,880q-83.15,0 -156.28,-31.5t-127.22,-86Q142,708 111,635.16 80,562.32 80,479.5t31.5,-155.66Q143,251 197.5,197t127.34,-85.5Q397.68,80 480.5,80t155.66,31.5Q709,143 763,197t85.5,127Q880,397 880,479.73q0,82.74 -31.5,155.5Q817,708 763,762.5t-127.13,86Q562.74,880 479.6,880Z"
|
||||||
|
android:fillColor="#5f6368"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable/ic_back.xml
Normal file
5
app/src/main/res/drawable/ic_back.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||||
|
|
||||||
|
</vector>
|
@ -10,20 +10,20 @@
|
|||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/floatingActionButton2"
|
android:id="@+id/floatingActionButton2"
|
||||||
|
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:clickable="true"
|
android:clickable="true"
|
||||||
style="@style/Theme.UiTemplate.FAB.Gray"
|
android:src="@drawable/ic_back"
|
||||||
android:src="@drawable/ic_close"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView5"
|
android:id="@+id/textView5"
|
||||||
|
style="@style/Theme.UiTemplate.TextH2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Entry History"
|
android:text="@string/entry_history"
|
||||||
style="@style/Theme.UiTemplate.TextH2"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/floatingActionButton2"
|
app:layout_constraintBottom_toBottomOf="@+id/floatingActionButton2"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/floatingActionButton2"
|
app:layout_constraintStart_toEndOf="@+id/floatingActionButton2"
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recyclerView"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="645dp"
|
android:layout_height="0dp"
|
||||||
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"
|
||||||
|
@ -140,6 +140,17 @@
|
|||||||
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
|
||||||
|
android:id="@+id/admin"
|
||||||
|
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_admin"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/scan"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/entry_list" />
|
||||||
|
|
||||||
<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"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="Theme.UiTemplate.CardView" parent="Widget.MaterialComponents.CardView">
|
<style name="Theme.UiTemplate.CardView" parent="Widget.MaterialComponents.CardView">
|
||||||
|
<item name="cardBackgroundColor">@color/BackgroundGray</item>
|
||||||
<item name="cardElevation">0dp</item>
|
<item name="cardElevation">0dp</item>
|
||||||
<item name="cardCornerRadius">120dp</item>
|
<item name="cardCornerRadius">30dp</item>
|
||||||
<item name="cornerSize">10dp</item>
|
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
@ -1,3 +1,4 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">NTO Pass</string>
|
<string name="app_name">NTO Pass</string>
|
||||||
|
<string name="entry_history">Entry History</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user