mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Fix issue with too big icons
This commit is contained in:
parent
cce4d7d4d9
commit
14c71d6c07
4 changed files with 56 additions and 19 deletions
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2020 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.core.extensions
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
|
||||
fun ConstraintLayout.updateConstraintSet(block: (ConstraintSet) -> Unit) {
|
||||
ConstraintSet().let {
|
||||
it.clone(this)
|
||||
block.invoke(it)
|
||||
it.applyTo(this)
|
||||
}
|
||||
}
|
|
@ -21,8 +21,10 @@ import android.graphics.drawable.Drawable
|
|||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.updateConstraintSet
|
||||
import kotlinx.android.synthetic.main.view_state.view.*
|
||||
|
||||
class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
||||
|
@ -31,7 +33,12 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||
sealed class State {
|
||||
object Content : State()
|
||||
object Loading : State()
|
||||
data class Empty(val title: CharSequence? = null, val image: Drawable? = null, val message: CharSequence? = null) : State()
|
||||
data class Empty(
|
||||
val title: CharSequence? = null,
|
||||
val image: Drawable? = null,
|
||||
val isBigImage: Boolean = false,
|
||||
val message: CharSequence? = null
|
||||
) : State()
|
||||
|
||||
data class Error(val message: CharSequence? = null) : State()
|
||||
}
|
||||
|
@ -71,6 +78,9 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||
is State.Loading -> Unit
|
||||
is State.Empty -> {
|
||||
emptyImageView.setImageDrawable(newState.image)
|
||||
emptyView.updateConstraintSet {
|
||||
it.constrainPercentHeight(R.id.emptyImageView, if (newState.isBigImage) 0.5f else 0.1f)
|
||||
}
|
||||
emptyMessageView.text = newState.message
|
||||
emptyTitleView.text = newState.title
|
||||
}
|
||||
|
|
|
@ -295,28 +295,30 @@ class RoomListFragment @Inject constructor(
|
|||
RoomListDisplayMode.NOTIFICATIONS -> {
|
||||
if (hasNoRoom) {
|
||||
StateView.State.Empty(
|
||||
getString(R.string.room_list_catchup_welcome_title),
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_catchup),
|
||||
getString(R.string.room_list_catchup_welcome_body)
|
||||
title = getString(R.string.room_list_catchup_welcome_title),
|
||||
image = ContextCompat.getDrawable(requireContext(), R.drawable.ic_home_bottom_catchup),
|
||||
message = getString(R.string.room_list_catchup_welcome_body)
|
||||
)
|
||||
} else {
|
||||
StateView.State.Empty(
|
||||
getString(R.string.room_list_catchup_empty_title),
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.ic_noun_party_popper),
|
||||
getString(R.string.room_list_catchup_empty_body))
|
||||
title = getString(R.string.room_list_catchup_empty_title),
|
||||
image = ContextCompat.getDrawable(requireContext(), R.drawable.ic_noun_party_popper),
|
||||
message = getString(R.string.room_list_catchup_empty_body))
|
||||
}
|
||||
}
|
||||
RoomListDisplayMode.PEOPLE ->
|
||||
StateView.State.Empty(
|
||||
getString(R.string.room_list_people_empty_title),
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_dm),
|
||||
getString(R.string.room_list_people_empty_body)
|
||||
title = getString(R.string.room_list_people_empty_title),
|
||||
image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_dm),
|
||||
isBigImage = true,
|
||||
message = getString(R.string.room_list_people_empty_body)
|
||||
)
|
||||
RoomListDisplayMode.ROOMS ->
|
||||
StateView.State.Empty(
|
||||
getString(R.string.room_list_rooms_empty_title),
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_room),
|
||||
getString(R.string.room_list_rooms_empty_body)
|
||||
title = getString(R.string.room_list_rooms_empty_title),
|
||||
image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_room),
|
||||
isBigImage = true,
|
||||
message = getString(R.string.room_list_rooms_empty_body)
|
||||
)
|
||||
else ->
|
||||
// Always display the content in this mode, because if the footer
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
android:textSize="16sp"
|
||||
tools:text="Une erreur est survenue" />
|
||||
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/errorRetryView"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -46,7 +45,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/emptyView"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -63,22 +61,22 @@
|
|||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:maxHeight="350dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/emptyTitleView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHeight_percent="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:src="@drawable/empty_state_dm" />
|
||||
tools:layout_constraintHeight_percent="0.5"
|
||||
tools:src="@drawable/ic_search_no_results" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/emptyTitleView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="30dp"
|
||||
android:gravity="center"
|
||||
android:textColor="?riotx_text_primary"
|
||||
android:textSize="15sp"
|
||||
|
@ -90,7 +88,6 @@
|
|||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="@string/room_list_people_empty_title" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/emptyMessageView"
|
||||
android:layout_width="220dp"
|
||||
|
|
Loading…
Reference in a new issue