Skip to content

Commit

Permalink
Add search button
Browse files Browse the repository at this point in the history
  • Loading branch information
tien-awair committed May 11, 2022
1 parent 8830654 commit 524b331
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.sendbird.uikit.SendBirdUIKit;
import com.sendbird.uikit.activities.ChannelSettingsActivity;
import com.sendbird.uikit.activities.MembersActivity;
import com.sendbird.uikit.activities.MessageSearchActivity;
import com.sendbird.uikit.activities.PhotoViewActivity;
import com.sendbird.uikit.activities.adapter.MessageListAdapter;
import com.sendbird.uikit.activities.viewholder.MessageType;
Expand Down Expand Up @@ -311,6 +312,11 @@ private void initHeaderOnCreated() {
binding.chvChannelHeader.setRightImageButtonTint(headerRightButtonIconTint);
}
binding.chvChannelHeader.setLeftImageButtonClickListener(v -> finish());
binding.chvChannelHeader.setSearchListener(v -> {
if (getContext() != null) {
startActivity(MessageSearchActivity.newIntent(getContext(), channel.getUrl()));
}
});
}

private void initHeaderOnReady(GroupChannel channel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.TextView;
Expand Down Expand Up @@ -142,6 +143,13 @@ public void setLeftImageButtonClickListener(OnClickListener listener) {
}
}

public void setSearchListener(OnClickListener listener) {
if (binding != null) {
binding.btnSearch.setVisibility(View.VISIBLE);
binding.btnSearch.setOnClickListener(listener);
}
}

public void setUseLeftImageButton(boolean useLeftImageButton) {
this.useLeftImageButton = useLeftImageButton;
if (binding != null) {
Expand Down
64 changes: 37 additions & 27 deletions uikit/src/main/res/layout/sb_view_app_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.constraintlayout.widget.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="@dimen/sb_size_56"
android:orientation="vertical"
android:paddingLeft="@dimen/sb_size_16"
android:paddingRight="@dimen/sb_size_16">

Expand All @@ -20,36 +20,34 @@
android:layout_height="@dimen/sb_size_34"
android:translationX="@dimen/sb_size_negative_8"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/titlePanel"
app:layout_constraintStart_toEndOf="@id/emptyLeft"
app:layout_constraintEnd_toStartOf="@id/titlePanel"/>
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:id="@+id/titlePanel"
android:layout_width="@dimen/sb_size_0"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/flRightPanel"
app:layout_constraintStart_toEndOf="@id/ccvProfileView"
app:layout_constraintEnd_toStartOf="@id/flRightPanel">
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvAppBarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
/>
android:maxLines="1" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvAppBarDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="middle"
/>
android:singleLine="true" />

</LinearLayout>

Expand All @@ -58,74 +56,86 @@
android:layout_width="@dimen/sb_size_8"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/ccvProfileView"
app:layout_constraintStart_toEndOf="@id/flLeftPanel"
app:layout_constraintEnd_toStartOf="@id/ccvProfileView"/>
app:layout_constraintTop_toTopOf="parent" />

<FrameLayout
android:id="@+id/flLeftPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/sb_size_20"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/emptyLeft"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/emptyLeft">
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/ibtnLeft"
android:layout_width="@dimen/sb_size_40"
android:layout_height="@dimen/sb_size_40"
android:layout_gravity="center"
android:padding="@dimen/sb_size_8"
android:scaleType="centerCrop"
android:layout_gravity="center" />
android:scaleType="centerCrop" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/btnLeft"
android:layout_width="wrap_content"
android:layout_height="@dimen/sb_size_40"
android:layout_gravity="center"
android:gravity="center"
android:paddingRight="@dimen/sb_size_4"
android:paddingLeft="@dimen/sb_size_4"/>
android:paddingLeft="@dimen/sb_size_4"
android:paddingRight="@dimen/sb_size_4" />

</FrameLayout>

<FrameLayout
android:id="@+id/flRightPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/titlePanel">
app:layout_constraintEnd_toStartOf="@id/btnSearch"
app:layout_constraintStart_toEndOf="@id/titlePanel"
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/ibtnRight"
android:layout_width="@dimen/sb_size_40"
android:layout_height="@dimen/sb_size_40"
android:layout_gravity="center"
android:padding="@dimen/sb_size_8"
android:scaleType="centerCrop"
android:layout_gravity="center"/>
android:scaleType="centerCrop" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/btnRight"
android:layout_width="wrap_content"
android:layout_height="@dimen/sb_size_40"
android:layout_gravity="center"
android:gravity="center"
android:paddingRight="@dimen/sb_size_4"
android:paddingLeft="@dimen/sb_size_4"/>
android:paddingLeft="@dimen/sb_size_4"
android:paddingRight="@dimen/sb_size_4" />

</FrameLayout>

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btnSearch"
android:layout_width="@dimen/sb_size_40"
android:layout_height="@dimen/sb_size_40"
android:padding="@dimen/sb_size_8"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/icon_search"
android:visibility="gone"
app:tint="@color/primary_400" />

</androidx.constraintlayout.widget.ConstraintLayout>

<View
android:id="@+id/elevationView"
android:layout_width="match_parent"
android:layout_height="@dimen/sb_size_1"/>
android:layout_height="@dimen/sb_size_1" />

</LinearLayout>

Expand Down

0 comments on commit 524b331

Please sign in to comment.