加入抽屉侧滑菜单1
This commit is contained in:
		
							parent
							
								
									2e51ad024d
								
							
						
					
					
						commit
						7948a130a8
					
				|  | @ -3,6 +3,7 @@ package com.remax.visualnovel.ui.chat | |||
| 
 | ||||
| import android.graphics.Point | ||||
| import androidx.activity.viewModels | ||||
| import androidx.core.view.GravityCompat | ||||
| import androidx.core.view.marginTop | ||||
| import androidx.lifecycle.Observer | ||||
| import androidx.lifecycle.lifecycleScope | ||||
|  | @ -52,7 +53,9 @@ class ChatActivity : BaseBindingActivity<ActivityActorChat2Binding>() { | |||
|         StatusBarUtils.setStatusBarAndNavBarIsLight(this, false) | ||||
|         StatusBarUtils.setTransparent(this) | ||||
|         binding.root.setMargin(topMargin = StatusBarUtils.statusBarHeight) | ||||
|         binding.toolbar.addRightIcon(R.mipmap.chat_title_setting) | ||||
|         binding.toolbar.addRightIcon(R.mipmap.chat_title_setting) { | ||||
|             binding.drawerMenu.openDrawer(GravityCompat.END) | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         with(binding) { | ||||
|  |  | |||
|  | @ -0,0 +1,25 @@ | |||
| package com.remax.visualnovel.ui.chat.ui | ||||
| 
 | ||||
| 
 | ||||
| import android.content.Context | ||||
| import android.util.AttributeSet | ||||
| import android.view.LayoutInflater | ||||
| import android.widget.LinearLayout | ||||
| import com.remax.visualnovel.R | ||||
| import com.remax.visualnovel.databinding.LayoutChatMenuViewBinding | ||||
| 
 | ||||
| class ChatSettingView @JvmOverloads constructor( | ||||
|     context: Context, | ||||
|     attrs: AttributeSet? = null, | ||||
|     defStyleAttr: Int = 0 | ||||
| ) : LinearLayout(context, attrs, defStyleAttr) { | ||||
| 
 | ||||
|     private lateinit var mBinding: LayoutChatMenuViewBinding | ||||
| 
 | ||||
| 
 | ||||
|     init { | ||||
|         mBinding = LayoutChatMenuViewBinding.inflate(LayoutInflater.from(context)) | ||||
|         LayoutInflater.from(context).inflate(R.layout.base_toolbar_layout, this, true) | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -91,6 +91,25 @@ class BaseToolbar @JvmOverloads constructor( | |||
|         return imageView | ||||
|     } | ||||
| 
 | ||||
|     fun addRightIcon(@DrawableRes resId: Int, onClick: ()->Unit) { | ||||
|         val imageView = ImageView(context).apply { | ||||
|             setImageResource(resId) | ||||
|             scaleType = ImageView.ScaleType.CENTER_INSIDE | ||||
|             layoutParams = LinearLayout.LayoutParams( | ||||
|                 LayoutParams.WRAP_CONTENT, | ||||
|                 LayoutParams.WRAP_CONTENT | ||||
|             ).apply { | ||||
|                 setMargins(16, 0, 16, 0) | ||||
|                 setOnClickListener { | ||||
|                     onClick.invoke() | ||||
|                 } | ||||
|             } | ||||
|             this.tag = tag | ||||
|         } | ||||
|         llRight.addView(imageView) | ||||
|         setupClickListener(imageView) | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 向右侧区域添加自定义视图 | ||||
|      */ | ||||
|  |  | |||
|  | @ -1,7 +1,14 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.constraintlayout.widget.ConstraintLayout | ||||
| <androidx.drawerlayout.widget.DrawerLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:id="@+id/drawer_menu" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     android:fitsSystemWindows="true" > | ||||
| 
 | ||||
|       <!--  页面内容  --> | ||||
|     <androidx.constraintlayout.widget.ConstraintLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:background="@mipmap/bg_level_1_page" | ||||
|  | @ -15,8 +22,6 @@ | |||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent" | ||||
|             /> | ||||
| 
 | ||||
| 
 | ||||
|         <androidx.constraintlayout.widget.ConstraintLayout | ||||
|             android:id="@+id/content" | ||||
|             android:layout_width="match_parent" | ||||
|  | @ -35,26 +40,6 @@ | |||
|                 android:src="@mipmap/splash_bg" | ||||
|                 /> | ||||
| 
 | ||||
|         <com.remax.visualnovel.widget.uitoken.view.UITokenTextView | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:gravity="center" | ||||
|             android:textSize="@dimen/sp_18" | ||||
|             android:padding="@dimen/dp_10" | ||||
|             android:text="Chat" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
| 
 | ||||
|             app:backgroundColorToken="@string/color_surface_element_normal" | ||||
|             app:radiusToken="@string/radius_pill" | ||||
|             app:strokeColorToken="@string/color_surface_top_normal" | ||||
|             app:strokeWidthToken="@string/border_divider" | ||||
|             app:textColorToken="@string/color_txt_secondary_press" | ||||
|             /> | ||||
| 
 | ||||
| 
 | ||||
|             <com.remax.visualnovel.ui.chat.InputPanel | ||||
|                 android:id="@+id/input_panel" | ||||
|                 android:layout_width="match_parent" | ||||
|  | @ -65,7 +50,23 @@ | |||
|                 app:layout_constraintBottom_toBottomOf="parent" | ||||
|                 /> | ||||
|         </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|     </androidx.constraintlayout.widget.ConstraintLayout> | ||||
| 
 | ||||
| 
 | ||||
|     <!--  drawer 菜单view  --> | ||||
|     <!-- 右侧抽屉菜单 --> | ||||
|     <LinearLayout | ||||
|         android:layout_width="240dp" | ||||
|         android:layout_height="match_parent" | ||||
|         android:layout_gravity="end" | ||||
|         android:background="#FFFFFF" | ||||
|         android:orientation="vertical"> | ||||
|         <com.remax.visualnovel.ui.chat.ui.ChatSettingView | ||||
|             android:id="@+id/setting_view" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             /> | ||||
|     </LinearLayout> | ||||
| 
 | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
| 
 | ||||
| </androidx.drawerlayout.widget.DrawerLayout> | ||||
|  | @ -12,7 +12,7 @@ | |||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="0dp" | ||||
|         android:scaleType="centerInside" | ||||
|         android:src="@mipmap/icon_checked" | ||||
|         android:src="@mipmap/icon_back_white" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|  |  | |||
|  | @ -6,34 +6,26 @@ | |||
|     android:layout_height="wrap_content" | ||||
|     android:padding="@dimen/dp_20" > | ||||
| 
 | ||||
| 
 | ||||
|     <com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout | ||||
|         android:id="@+id/cl_most_bottom_container" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         > | ||||
|     <com.remax.visualnovel.ui.chat.PopMenuIconView | ||||
|         android:id="@+id/chat_pop_menu" | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         android:layout_marginBottom="@dimen/dp_2" | ||||
|         /> | ||||
| 
 | ||||
|     <com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout | ||||
|         android:id="@+id/cl_most_bottom_container" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="wrap_content" | ||||
|             app:layout_constraintStart_toEndOf="@id/chat_pop_menu" | ||||
|         app:layout_constraintStart_toEndOf="@+id/chat_pop_menu" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         android:layout_marginStart="@dimen/dp_10" | ||||
|         app:radiusToken="@string/radius_40" | ||||
|         app:backgroundColorToken="@string/color_surface_element_normal" | ||||
|         > | ||||
| 
 | ||||
|         <RelativeLayout | ||||
|             android:id="@+id/iv_hold2talk" | ||||
|             android:layout_width="0dp" | ||||
|  | @ -64,7 +56,6 @@ | |||
|             android:src="@mipmap/chat_voice_b" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent" | ||||
|             android:paddingHorizontal="@dimen/dp_12" | ||||
|             android:padding="@dimen/dp_12" | ||||
|             /> | ||||
|  | @ -78,7 +69,6 @@ | |||
|             android:layout_margin="@dimen/dp_3" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent" | ||||
|             app:radiusToken="@string/radius_xxl" | ||||
|             app:backgroundColorToken="@string/color_surface_float_hover" | ||||
|             /> | ||||
|  | @ -105,7 +95,6 @@ | |||
|             /> | ||||
| 
 | ||||
|     </com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout> | ||||
|     </com.remax.visualnovel.widget.uitoken.view.UITokenConstraintLayout> | ||||
| 
 | ||||
| 
 | ||||
|     <com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout | ||||
|  | @ -115,7 +104,6 @@ | |||
|         android:orientation="horizontal" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintBottom_toTopOf="@id/cl_most_bottom_container" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         android:layout_marginBottom="@dimen/dp_20" | ||||
|         > | ||||
| 
 | ||||
|  |  | |||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 758 B | 
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 770 B | 
|  | @ -38,6 +38,8 @@ android.nonFinalResIds=false | |||
| 
 | ||||
| # Test flags for improve compile speed | ||||
| org.gradle.configureondemand=true | ||||
| org.gradle.workers.max=16 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue