mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 03:49:04 +03:00
Update button design
This commit is contained in:
parent
c4c62acdaa
commit
9929d6a4eb
3 changed files with 91 additions and 12 deletions
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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.ui.list
|
||||
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence
|
||||
|
||||
/**
|
||||
* A generic button list item.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.item_positive_destrutive_buttons)
|
||||
abstract class ButtonPositiveDestructiveButtonBarItem : VectorEpoxyModel<ButtonPositiveDestructiveButtonBarItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute
|
||||
var positiveText: EpoxyCharSequence? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var destructiveText: EpoxyCharSequence? = null
|
||||
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var positiveButtonClickAction: ClickListener? = null
|
||||
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var destructiveButtonClickAction: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
positiveText?.charSequence?.let { holder.positiveButton.text = it }
|
||||
destructiveText?.charSequence?.let { holder.destructiveButton.text = it }
|
||||
|
||||
holder.positiveButton.onClick(positiveButtonClickAction)
|
||||
holder.destructiveButton.onClick(destructiveButtonClickAction)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val destructiveButton by bind<MaterialButton>(R.id.destructive_button)
|
||||
val positiveButton by bind<MaterialButton>(R.id.positive_button)
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.epoxy.bottomSheetDividerItem
|
||||
import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.ui.list.genericButtonItem
|
||||
import im.vector.app.core.ui.list.buttonPositiveDestructiveButtonBarItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem
|
||||
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationQrCodeItem
|
||||
|
@ -111,17 +111,12 @@ class VerificationChooseMethodController @Inject constructor(
|
|||
}
|
||||
} else if (!state.isReadied) {
|
||||
// a bit of a special case, if you tapped on the timeline cell but not on a button
|
||||
genericButtonItem {
|
||||
id("accept_request")
|
||||
textColor(host.colorProvider.getColorFromAttribute(R.attr.colorPrimary))
|
||||
text(host.stringProvider.getString(R.string.action_accept))
|
||||
buttonClickAction { host.listener?.acceptRequest() }
|
||||
}
|
||||
genericButtonItem {
|
||||
id("decline_request")
|
||||
textColor(host.colorProvider.getColorFromAttribute(R.attr.colorError))
|
||||
text(host.stringProvider.getString(R.string.action_decline))
|
||||
buttonClickAction { host.listener?.declineRequest() }
|
||||
buttonPositiveDestructiveButtonBarItem {
|
||||
id("accept_decline")
|
||||
positiveText(host.stringProvider.getString(R.string.action_accept).toEpoxyCharSequence())
|
||||
destructiveText(host.stringProvider.getString(R.string.action_decline).toEpoxyCharSequence())
|
||||
positiveButtonClickAction { host.listener?.acceptRequest() }
|
||||
destructiveButtonClickAction { host.listener?.declineRequest() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
tools:visibility="visible">
|
||||
|
||||
<Button
|
||||
android:id="@+id/destructive_button"
|
||||
style="@style/Widget.Vector.Button.Destructive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/action_decline" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/positive_button"
|
||||
style="@style/Widget.Vector.Button.Positive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_accept" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue