Browse Source

Merge branch 'master' into landscape_main

wbspool 1 năm trước cách đây
mục cha
commit
ad25dc32dc

+ 26 - 0
BusinessCommon/src/main/java/com/develop/common/widget/HomeFilterSortSearchView.kt

@@ -9,6 +9,8 @@ import com.blankj.utilcode.util.KeyboardUtils
 import com.develop.base.ext.isFrLanguage
 import com.develop.base.ext.isNightTheme
 import com.develop.base.ext.resId2Dimension
+import com.develop.base.ext.setGone
+import com.develop.base.ext.setVisible
 import com.develop.common.R
 
 import com.develop.common.databinding.HomeSortFilterSearchViewBinding
@@ -58,8 +60,16 @@ class HomeFilterSortSearchView : RelativeLayout {
         }
 
         binding.onlineLayout.setOnClickListener {
+            binding.onlineLayout.setGone()
+            binding.recipesLayout.setVisible()
             onFunctionCallback?.onOnlineRecipesClick()
         }
+
+
+        binding.recipesLayout.setOnClickListener {
+            binding.recipesLayout.setGone()
+            onFunctionCallback?.onLocalRecipesClick()
+        }
     }
 
     fun resetView() {
@@ -67,6 +77,16 @@ class HomeFilterSortSearchView : RelativeLayout {
         binding.searchLayout.visibility = View.GONE
     }
 
+
+    fun checkOnlineOrLocalRecipesView(showOnline:Boolean){
+        if (showOnline){
+            binding.recipesLayout.setGone()
+        } else {
+            binding.recipesLayout.setVisible()
+            binding.onlineLayout.setGone()
+        }
+    }
+
     interface OnFunctionCallback {
         fun onFilterClick(filterView: View)
         fun onSortClick(sortView: View)
@@ -74,6 +94,8 @@ class HomeFilterSortSearchView : RelativeLayout {
         fun onInputSearch(searchContent: String)
         fun onDownloadClick()
         fun onOnlineRecipesClick()
+
+        fun onLocalRecipesClick()
     }
 
     fun updateFilterName(filterName: String) {
@@ -99,5 +121,9 @@ class HomeFilterSortSearchView : RelativeLayout {
     fun getOnlineLayoutVisible(): Boolean {
         return binding.onlineLayout.visibility == View.VISIBLE
     }
+
+    fun getLocalLayoutVisible(): Boolean {
+        return binding.recipesLayout.visibility == View.VISIBLE
+    }
 }
 

+ 6 - 1
BusinessCommon/src/main/java/com/develop/common/widget/HomeFunctionTopBar.kt

@@ -58,7 +58,12 @@ class HomeFunctionTopBar : RelativeLayout, View.OnClickListener {
             binding.ivFunction.background_drawable = R.drawable.ic_home
             binding.functionName.text = resources.getString(R.string.home)
         } else {
-            binding.ivFunction.background_drawable = R.drawable.ic_white_back
+            if (isNightTheme()){
+                binding.ivFunction.background_drawable = R.drawable.ic_night_white_back
+            } else {
+                binding.ivFunction.background_drawable = R.drawable.ic_white_back
+            }
+
             binding.functionName.text = resources.getString(R.string.back)
         }
     }

BIN
BusinessCommon/src/main/res/drawable-xxxhdpi/ic_night_white_back.png


+ 27 - 0
BusinessCommon/src/main/res/layout/home_sort_filter_search_view.xml

@@ -127,6 +127,33 @@
                 android:textSize="@dimen/convert_26px" />
         </FrameLayout>
 
+        <FrameLayout
+            android:visibility="gone"
+            android:id="@+id/recipes_layout"
+            android:layout_width="@dimen/convert_213px"
+            android:layout_height="@dimen/convert_60px"
+            android:layout_centerVertical="true"
+            android:layout_toStartOf="@+id/download_layout"
+            android:background="@drawable/shape_100px6fb1fb_corners">
+
+            <ImageView
+                android:layout_width="@dimen/convert_46px"
+                android:layout_height="@dimen/convert_46px"
+                android:layout_gravity="center_vertical"
+                android:layout_marginStart="@dimen/convert_19px"
+                android:background="@drawable/ic_recipes" />
+
+            <androidx.appcompat.widget.AppCompatTextView
+                android:id="@+id/tv_recipes"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center|end"
+                android:layout_marginEnd="@dimen/convert_23px"
+                android:text="@string/recipes"
+                android:textColor="@color/white"
+                android:textSize="@dimen/convert_26px" />
+        </FrameLayout>
+
         <FrameLayout
             android:id="@+id/download_layout"
             android:layout_width="@dimen/convert_240px"

+ 21 - 0
BusinessMain/src/main/java/com/develop/main/ui/HomeActivity.kt

@@ -33,6 +33,8 @@ import com.develop.common.widget.NewsLayout
 import com.develop.main.R
 import com.develop.main.databinding.ActivityHomeBinding
 import com.develop.main.viewmodel.HomeViewModel
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
 
 @Route(path = Screens.Main.HOME)
 class HomeActivity : CommonBVMActivity<ActivityHomeBinding, HomeViewModel>() {
@@ -147,6 +149,7 @@ class HomeActivity : CommonBVMActivity<ActivityHomeBinding, HomeViewModel>() {
                         navigateTo(Screens.Main.ENTRANCE_CHOSEN)
                         finish()
                     } else {
+                        EventBus.getDefault().post(HomeBackClickEvent(true))
                         //搜索后,返回后当前还是onLine的菜谱,还是显示返回,可以返回本地菜谱
                         if (viewModel.recipesType == RecipesType.ONLINE && viewModel.isSearch
                             && !viewModel.isFromDownloadNewRecipesEntrance
@@ -303,6 +306,24 @@ class HomeActivity : CommonBVMActivity<ActivityHomeBinding, HomeViewModel>() {
         updateUserInfoUi(userInfo)
     }
 
+    @Subscribe
+    fun onLocalRecipesClickEvent(event: RecipesFragment.OnLocalRecipesEvent) {
+        //搜索后,返回后当前还是onLine的菜谱,还是显示返回,可以返回本地菜谱
+        if (viewModel.recipesType == RecipesType.ONLINE && viewModel.isSearch
+            && !viewModel.isFromDownloadNewRecipesEntrance
+        ) {
+            binding.functionTopBar.setHomeOrBack(HomeOrBack.Back)
+        } else {
+            binding.functionTopBar.setHomeOrBack(HomeOrBack.Home)
+        }
+        viewModel.apply {
+            refreshRecipesLiveData.postValue(true)
+            isSearch = false
+        }
+
+    }
+
+    class HomeBackClickEvent(showOnline:Boolean)
     override fun onDestroy() {
         super.onDestroy()
         wifiHelp.destroy()

+ 21 - 16
BusinessMain/src/main/java/com/develop/main/ui/RecipesFragment.kt

@@ -87,11 +87,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                         onBind {
                             val model = getModel<DevRecipeCategory>()
                             bindFilterSortView(
-                                adapter,
-                                this,
-                                model.name ?: "",
-                                true,
-                                model.number ?: "0"
+                                adapter, this, model.name ?: "", true, model.number ?: "0"
                             )
                         }
                     }
@@ -193,8 +189,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                                 findView<HomeFilterSortSearchView>(R.id.function_view)
                             if (filterSortModel != null) {
                                 filterSortSearchView?.apply {
-                                    var size =
-                                        viewModel.categorySizeList[viewModel.categoryCode]
+                                    var size = viewModel.categorySizeList[viewModel.categoryCode]
                                     if (size == null) {
                                         size = "0"
                                     }
@@ -265,8 +260,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
                         }
 
-                        com.develop.common.R.layout.food_content_night_provider,
-                        com.develop.common.R.layout.food_content_provider -> {
+                        com.develop.common.R.layout.food_content_night_provider, com.develop.common.R.layout.food_content_provider -> {
                             findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
                                 getModel()
                             )
@@ -308,8 +302,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                 if (viewModel.isSearch) {
                     if (viewModel.recipesType == RecipesType.ONLINE) {
                         if (!viewModel.loadMoreOnLineSearchRecipeList(
-                                currentHotWord,
-                                viewModel.lastSearchCategoryType
+                                currentHotWord, viewModel.lastSearchCategoryType
                             )
                         ) {
                             finishLoadMoreWithNoMoreData()
@@ -406,8 +399,14 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             }
         }
 
+        override fun onLocalRecipesClick() {
+            EventBus.getDefault().post(OnLocalRecipesEvent())
+        }
+
     }
 
+    class OnLocalRecipesEvent {}
+
     /**热词选择回调 */
     private var hotWordsSelectedCallback = object : CommonSearchLayout.OnHotWordsSelectedListener {
         override fun onHotWordsSelected(hotWord: String) {
@@ -666,11 +665,11 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             }
 
             errorCallback.observe(viewLifecycleOwner) {
-             if (!NetworkUtils.isWifiConnected()){
-                 GlobalToast.showToast(getString(com.develop.common.R.string.network_error))
-             } else {
-                 GlobalToast.showToast(it)
-             }
+                if (!NetworkUtils.isWifiConnected()) {
+                    GlobalToast.showToast(getString(com.develop.common.R.string.network_error))
+                } else {
+                    GlobalToast.showToast(it)
+                }
                 loadingDialog.removeSelf()
             }
         }
@@ -825,4 +824,10 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
         }
 
     }
+
+
+    @Subscribe
+    fun onHomeBackClickEvent(event: HomeActivity.HomeBackClickEvent) {
+        filterSortSearchView?.checkOnlineOrLocalRecipesView(true)
+    }
 }

BIN
app/src/main/assets/skins/night.skin


BIN
skin-support/src/main/res/drawable/ic_white_back.png