mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 21:28:26 +00:00
polish
This commit is contained in:
parent
76466e57de
commit
8b39c4e56a
@ -32,6 +32,12 @@ class BlockedContactsAdapter(val viewModel: BlockedContactsViewModel) : ListAdap
|
||||
holder.bind(selectable, viewModel::toggle)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int, payloads: MutableList<Any>) {
|
||||
val selectable = getItem(position)
|
||||
if (payloads.isEmpty()) holder.bind(selectable, viewModel::toggle)
|
||||
else holder.select(selectable.isSelected)
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
holder.binding.profilePictureView.root.recycle()
|
||||
@ -51,5 +57,9 @@ class BlockedContactsAdapter(val viewModel: BlockedContactsViewModel) : ListAdap
|
||||
binding.root.setOnClickListener { toggle(selectable) }
|
||||
binding.selectButton.isSelected = selectable.isSelected
|
||||
}
|
||||
|
||||
fun select(isSelected: Boolean) {
|
||||
binding.selectButton.isSelected = isSelected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class BlockedContactsViewModel @Inject constructor(private val storage: Storage)
|
||||
|
||||
fun toggle(selectable: SelectableItem<Recipient>) {
|
||||
_state.value = state.run {
|
||||
if (selectable.isSelected) copy(selectedItems = selectedItems - selectable.item)
|
||||
if (selectable.item in selectedItems) copy(selectedItems = selectedItems - selectable.item)
|
||||
else copy(selectedItems = selectedItems + selectable.item)
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/transparent" />
|
||||
|
||||
<corners android:radius="@dimen/medium_button_corner_radius" />
|
||||
|
||||
<stroke android:width="@dimen/border_thickness" android:color="@color/button_destructive" />
|
||||
</shape>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/button_destructive">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="?colorPrimary"/>
|
||||
<corners android:radius="@dimen/medium_button_corner_radius" />
|
||||
<stroke
|
||||
android:color="@color/button_destructive"
|
||||
android:width="@dimen/border_thickness" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/transparent" />
|
||||
|
||||
<corners android:radius="@dimen/medium_button_corner_radius" />
|
||||
|
||||
<stroke android:width="@dimen/border_thickness" android:color="?prominentButtonColor" />
|
||||
</shape>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?prominentButtonColor">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="?colorPrimary"/>
|
||||
<corners android:radius="@dimen/medium_button_corner_radius" />
|
||||
<stroke
|
||||
android:color="?prominentButtonColor"
|
||||
android:width="@dimen/border_thickness" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
|
@ -4,28 +4,37 @@
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/unblockButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/preference_single_no_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:cardCornerRadius="?preferenceCornerRadius"
|
||||
app:cardElevation="0dp"
|
||||
app:cardBackgroundColor="?colorSettingsBackground"
|
||||
android:layout_marginHorizontal="@dimen/medium_spacing"
|
||||
android:layout_marginVertical="@dimen/large_spacing"
|
||||
/>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
/>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/emptyStateMessageTextView"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="@+id/recyclerView"
|
||||
app:layout_constraintTop_toTopOf="@+id/cardView"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
app:layout_constraintStart_toStartOf="@+id/recyclerView"
|
||||
app:layout_constraintEnd_toEndOf="@+id/recyclerView"
|
||||
app:layout_constraintStart_toStartOf="@+id/cardView"
|
||||
app:layout_constraintEnd_toEndOf="@+id/cardView"
|
||||
android:text="@string/blocked_contacts_empty_state"
|
||||
/>
|
||||
|
||||
@ -38,7 +47,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/recyclerView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardView"
|
||||
android:id="@+id/unblockButton"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginVertical="@dimen/large_spacing"
|
||||
@ -49,6 +58,6 @@
|
||||
android:id="@+id/nonEmptyStateGroup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="unblockButton,recyclerView"/>
|
||||
app:constraint_referenced_ids="unblockButton,cardView"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
x
Reference in New Issue
Block a user