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