feat:完成首页TabBarUI改版

This commit is contained in:
max
2024-02-28 16:52:05 +08:00
parent c37635d6d1
commit da86497b95
36 changed files with 127 additions and 109 deletions

View File

@@ -23,6 +23,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
import com.chwl.app.star.StarFragment;
import com.chwl.app.ui.login.LoginPasswordActivity;
import com.chwl.core.settings.SettingsModel;
import com.netease.nim.uikit.StatusBarUtil;
@@ -140,7 +141,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
private MainTabLayout mMainTabLayout;
private AnchorCardView anchorCardView;
private View viewClose;
private int mCurrentTabType = MainTabType.TAB_TYPE_HOME;
private int mCurrentTabType = MainTabType.TAB_TYPE_STAR;
/**
* 房间最小化动画换成属性动画原先的补间动画影响了activity的生命周期
*/
@@ -158,6 +159,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
private Runnable touchRunnable;
{
fragmentArray.put(MainTabType.TAB_TYPE_STAR, new StarFragment());
fragmentArray.put(MainTabType.TAB_TYPE_HOME, new HomeFragment());
fragmentArray.put(MainTabType.TAB_TYPE_MSG, new ContactsListFragment());
fragmentArray.put(MainTabType.TAB_TYPE_ME, new MeFragment());
@@ -345,10 +347,10 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
userLivingView.setColor(Color.WHITE);
mMainTabLayout.setOnTabClickListener(this);
anchorCardView = findViewById(R.id.vs_anchor_card);
mMainTabLayout.setDefaultTabType(mCurrentTabType);
}
private void updateDatas() {
mMainTabLayout.setDefaultTabType(mCurrentTabType);
handleNimIntent();
}

View File

@@ -229,7 +229,16 @@ class HomeViewModel : BaseViewModel() {
},
block = {
val result = HomeModel.getHotRoom()
_homeHotRoomLiveData.value = ListResult.success(result, 1)
val list = ArrayList<HomeRoomInfo>()
result?.let {
list.addAll(result)
list.addAll(list)
list.addAll(list)
list.addAll(list)
list.addAll(list)
list.addAll(list)
}
_homeHotRoomLiveData.value = ListResult.success(list, 1)
}
)
}

View File

@@ -41,22 +41,6 @@ class ContactsListFragment : BaseViewBindingFragment<FragmentContactListBinding>
private var pagerAdapter: UserInfoPagerAdapter? = null
override fun init() {
// //标记已读消息
// binding.ivContactTrash.setOnClickListener {
// if (NIMClient.getService(MsgService::class.java).totalUnreadCount > 0) {
// dialogManager.showOkCancelDialog(getString(R.string.tips_clear_unread_count),
// getString(R.string.text_canle), getString(R.string.tips_ok_label_clear),
// object : AbsOkDialogListener() {
// override fun onOk() {}
// override fun onCancel() {
// EventBus.getDefault().post(ContactTrashEvent())
// }
// })
// } else {
// toast(ResUtil.getString(R.string.home_fragment_contactslistfragment_01))
// }
// }
initViewPager()
}

View File

@@ -0,0 +1,9 @@
package com.chwl.app.star
import com.chwl.app.base.BaseViewBindingFragment
import com.chwl.app.databinding.StarFragmentBinding
class StarFragment : BaseViewBindingFragment<StarFragmentBinding>() {
override fun init() {
}
}

View File

@@ -137,13 +137,12 @@ public class MainRedPointTab extends RelativeLayout {
}
private int getDefaultRes(int tabType, boolean select) {
int resId = select ? R.drawable.ic_main_tab_game_pressed : R.drawable.ic_main_tab_game_home;
int resId = select ? R.drawable.ic_main_tab_home_pressed : R.drawable.ic_main_tab_home;
switch (tabType) {
case MainTabType.TAB_TYPE_SQUARE:
resId = select ? R.drawable.ic_main_tab_find_pressed : R.drawable.ic_main_tab_find;
break;
case MainTabType.TAB_TYPE_GAME:
resId = select ? R.mipmap.ic_main_tab_peace_pressed : R.mipmap.ic_main_tab_peace;
case MainTabType.TAB_TYPE_STAR:
resId = select ? R.drawable.ic_main_tab_star_pressed : R.drawable.ic_main_tab_star;
break;
case MainTabType.TAB_TYPE_MSG:
resId = select ? R.drawable.ic_main_tab_msg_pressed : R.drawable.ic_main_tab_msg;

View File

@@ -43,8 +43,8 @@ public class MainTab extends androidx.appcompat.widget.AppCompatTextView {
setCompoundDrawablePadding(ScreenUtil.dip2px(0));
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MainTab);
mTabIcon = typedArray.getResourceId(R.styleable.MainTab_tab_icon, R.drawable.ic_main_tab_game_home);
mTabIconSelect = typedArray.getResourceId(R.styleable.MainTab_tab_icon_select, R.drawable.ic_main_tab_game_pressed);
mTabIcon = typedArray.getResourceId(R.styleable.MainTab_tab_icon, R.drawable.ic_main_tab_home);
mTabIconSelect = typedArray.getResourceId(R.styleable.MainTab_tab_icon_select, R.drawable.ic_main_tab_home_pressed);
mTabtextColor = typedArray.getColor(R.styleable.MainTab_tab_text_color, DEFAULT_COLOR);
mTabTextSelectColor = typedArray.getColor(R.styleable.MainTab_tab_text_color_select, DEFAULT_COLOR);

View File

@@ -26,7 +26,7 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
private final List<MainRedPointTab> tabViewList = new ArrayList<>(5);
private MainRedPointTab homeTab;
private MainRedPointTab squareTab;
private MainRedPointTab gameTab;
private MainRedPointTab starTab;
private MainRedPointTab msgTab;
private MainRedPointTab meTab;
private int mLastPosition = -1;
@@ -58,19 +58,19 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
squareTab = findViewById(R.id.main_square_tab);
msgTab = findViewById(R.id.main_msg_tab);
gameTab = findViewById(R.id.main_game_tab);
starTab = findViewById(R.id.main_star_tab);
homeTab = findViewById(R.id.main_home_tab);
meTab = findViewById(R.id.main_me_tab);
homeTab.setOnClickListener(this);
meTab.setOnClickListener(this);
gameTab.setOnClickListener(this);
starTab.setOnClickListener(this);
squareTab.setOnClickListener(this);
msgTab.setOnClickListener(this);
tabViewList.add(homeTab);
tabViewList.add(squareTab);
tabViewList.add(gameTab);
tabViewList.add(starTab);
tabViewList.add(msgTab);
tabViewList.add(meTab);
}
@@ -107,19 +107,19 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
if (ListUtils.isListEmpty(mainTabInfoList)) return;
switch (v.getId()) {
case R.id.main_home_tab:
select(mainTabInfoList.get(0).getTabType());
select(MainTabType.TAB_TYPE_HOME);
break;
case R.id.main_square_tab:
select(mainTabInfoList.get(1).getTabType());
select(MainTabType.TAB_TYPE_SQUARE);
break;
case R.id.main_game_tab:
select(mainTabInfoList.get(2).getTabType());
case R.id.main_star_tab:
select(MainTabType.TAB_TYPE_STAR);
break;
case R.id.main_msg_tab:
select(mainTabInfoList.get(3).getTabType());
select(MainTabType.TAB_TYPE_MSG);
break;
case R.id.main_me_tab:
select(mainTabInfoList.get(4).getTabType());
select(MainTabType.TAB_TYPE_ME);
break;
}
}
@@ -129,7 +129,7 @@ public class MainTabLayout extends LinearLayout implements View.OnClickListener
if (mLastPosition == tabType) return;
squareTab.select(tabType == MainTabType.TAB_TYPE_SQUARE);
msgTab.select(tabType == MainTabType.TAB_TYPE_MSG);
gameTab.select(tabType == MainTabType.TAB_TYPE_GAME);
starTab.select(tabType == MainTabType.TAB_TYPE_STAR);
homeTab.select(tabType == MainTabType.TAB_TYPE_HOME);
meTab.select(tabType == MainTabType.TAB_TYPE_ME);
if (mOnTabClickListener != null) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white"/>
<corners android:topLeftRadius="@dimen/dp_24"
android:topRightRadius="@dimen/dp_24"/>
</shape>

View File

@@ -10,32 +10,32 @@
android:id="@+id/main_fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/view_bottom"
android:layout_marginBottom="@dimen/main_bottom_bar_top_height"
app:layout_constraintBottom_toTopOf="@id/layout_bottom"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view_bottom"
android:background="@color/color_F7F7F7"
<FrameLayout
android:id="@+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="0.5dp"
app:layout_constraintBottom_toTopOf="@+id/main_tab_layout"/>
<com.chwl.app.ui.widget.MainTabLayout
android:id="@+id/main_tab_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/dp_6"
android:paddingTop="@dimen/dp_5"
android:elevation="0.5dp"
android:background="@color/color_white"
android:background="@drawable/shape_white_top_24dp"
android:paddingBottom="@dimen/dp_10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent">
<com.chwl.app.ui.widget.MainTabLayout
android:id="@+id/main_tab_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_55"
android:elevation="0.5dp" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/main_tab_layout"
app:layout_constraintBottom_toTopOf="@+id/layout_bottom"
app:layout_constraintTop_toTopOf="parent">
<com.chwl.app.common.widget.DragLayout
@@ -58,20 +58,20 @@
android:layout_alignParentEnd="true"
android:src="@drawable/ic_room_exit_close"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />
<com.chwl.app.common.widget.CircleImageView
android:id="@+id/avatar_image"
android:layout_width="60dp"
android:layout_height="60dp"
tools:src="@drawable/default_avatar"
android:layout_marginTop="@dimen/dp_14"
android:layout_marginEnd="6dp"
app:civ_border_width="2dp"
app:cborder_color="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:civ_border_width="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/default_avatar" />
<com.chwl.app.ui.widget.LivingIconView
android:id="@+id/liv_user"
@@ -79,10 +79,10 @@
android:layout_height="10dp"
android:layout_gravity="center"
android:background="@color/transparent"
app:layout_constraintStart_toStartOf="@+id/avatar_image"
app:layout_constraintBottom_toBottomOf="@+id/avatar_image"
app:layout_constraintEnd_toEndOf="@+id/avatar_image"
app:layout_constraintTop_toTopOf="@+id/avatar_image"
app:layout_constraintBottom_toBottomOf="@+id/avatar_image"/>
app:layout_constraintStart_toStartOf="@+id/avatar_image"
app:layout_constraintTop_toTopOf="@+id/avatar_image" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/color_F7F7F7">
<View
@@ -14,11 +14,11 @@
<LinearLayout
android:id="@+id/ll_title"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_44"
android:layout_marginTop="@dimen/dp_44"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/dp_15"
android:paddingEnd="@dimen/dp_15"
app:layout_constraintStart_toStartOf="parent"
@@ -29,28 +29,16 @@
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<!-- <View-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_weight="1"-->
<!-- android:layout_height="wrap_content"/>-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_contact_trash"-->
<!-- android:layout_width="30dp"-->
<!-- android:layout_height="30dp"-->
<!-- android:scaleType="center"-->
<!-- android:src="@mipmap/ic_contact_trash"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="@+id/magic_indicator"-->
<!-- app:layout_constraintBottom_toBottomOf="@+id/magic_indicator"/>-->
</LinearLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/ll_title"
app:layout_constraintBottom_toBottomOf="parent"/>
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="@dimen/main_bottom_bar_top_margin"
android:background="@drawable/shape_white_top_12dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_title" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -69,6 +69,7 @@
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/main_bottom_bar_top_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_indicator" />

View File

@@ -9,7 +9,5 @@
<FrameLayout
android:id="@+id/recent_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:background="@drawable/base_shape_ffffff_top_12dp" />
android:layout_height="match_parent"/>
</LinearLayout>

View File

@@ -2,31 +2,29 @@
<merge 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:background="@color/color_white"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:parentTag="LinearLayout">
<com.chwl.app.ui.widget.MainRedPointTab
android:id="@+id/main_star_tab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<com.chwl.app.ui.widget.MainRedPointTab
android:id="@+id/main_home_tab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<com.chwl.app.ui.widget.MainRedPointTab
android:id="@+id/main_square_tab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="gone"
android:layout_weight="1" />
<com.chwl.app.ui.widget.MainRedPointTab
android:id="@+id/main_game_tab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:visibility="gone" />
@@ -34,14 +32,14 @@
android:id="@+id/main_msg_tab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<com.chwl.app.ui.widget.MainRedPointTab
android:id="@+id/main_me_tab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
</merge>

View File

@@ -2,7 +2,7 @@
<merge 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:layout_height="match_parent"
tools:parentTag="android.widget.RelativeLayout">
<LinearLayout
@@ -15,11 +15,12 @@
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/iv_tab_icon"
android:layout_width="@dimen/dp_28"
android:layout_height="@dimen/dp_28"
android:layout_width="@dimen/dp_34"
android:layout_height="@dimen/dp_34"
android:src="@drawable/default_cover" />
<TextView
android:visibility="gone"
android:id="@+id/tv_tab_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STAR"
android:textSize="40sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -6,8 +6,10 @@
<dimen name="big_fnt">17sp</dimen>
<!--首页底部Bar顶部间距多出的高度-->
<dimen name="main_bottom_bar_top_height">-24dp</dimen>
<dimen name="main_bottom_bar_top_margin">27dp</dimen>
<!--对话框信息文字-->
<!--对话框按钮文字-->
<dimen name="dialog_btn_text_fnt">18sp</dimen>
<!--对话框标题文字-->