MainActivity: Move search FAB to fragment_apps_games layout

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-02-27 16:44:15 +05:30
parent 7e4e4c0bd3
commit 804d37a579
5 changed files with 23 additions and 26 deletions

View File

@@ -130,7 +130,6 @@ class MainActivity : AppCompatActivity() {
attachNavigation()
attachDrawer()
attachSearch()
/*Check only if download to external storage is enabled*/
if (Preferences.getBoolean(this, Preferences.PREFERENCE_DOWNLOAD_EXTERNAL)) {
@@ -183,7 +182,6 @@ class MainActivity : AppCompatActivity() {
if (navDestination !is FloatingWindow) {
when (navDestination.id) {
in topLevelFrags -> {
B.searchFab.visibility = View.VISIBLE
B.navView.visibility = View.VISIBLE
B.toolbar.visibility = View.VISIBLE
B.drawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED)
@@ -223,18 +221,11 @@ class MainActivity : AppCompatActivity() {
}
private fun hideTopLevelOnlyViews() {
B.searchFab.visibility = View.GONE
B.navView.visibility = View.GONE
B.toolbar.visibility = View.GONE
B.drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED)
}
private fun attachSearch() {
B.searchFab.setOnClickListener {
navController.navigate(R.id.searchSuggestionFragment)
}
}
private fun attachNavigation() {
val bottomNavigationView: BottomNavigationView = B.navView
bottomNavigationView.setupWithNavController(navController)

View File

@@ -24,6 +24,7 @@ import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.navigation.fragment.findNavController
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.aurora.store.R
import com.aurora.store.data.providers.AuthProvider
@@ -85,6 +86,10 @@ class AppsContainerFragment : Fragment(R.layout.fragment_apps_games) {
) { tab: TabLayout.Tab, position: Int ->
tab.text = tabTitles[position]
}.attach()
binding.searchFab.setOnClickListener {
findNavController().navigate(R.id.searchSuggestionFragment)
}
}
override fun onDestroyView() {

View File

@@ -24,6 +24,7 @@ import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.navigation.fragment.findNavController
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.aurora.store.R
import com.aurora.store.data.providers.AuthProvider
@@ -84,6 +85,10 @@ class GamesContainerFragment : Fragment(R.layout.fragment_apps_games) {
) { tab: TabLayout.Tab, position: Int ->
tab.text = tabTitles[position]
}.attach()
binding.searchFab.setOnClickListener {
findNavController().navigate(R.id.searchSuggestionFragment)
}
}
override fun onDestroyView() {

View File

@@ -19,7 +19,6 @@
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -58,21 +57,6 @@
android:layout_alignParentBottom="true"
app:menu="@menu/menu_bottom_nav" />
</RelativeLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/search_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginStart="@dimen/margin_normal"
android:layout_marginTop="@dimen/height_bottom_adj"
android:layout_marginEnd="@dimen/margin_normal"
android:layout_marginBottom="@dimen/height_bottom_adj"
android:contentDescription="@string/action_search"
app:backgroundTint="?colorAccent"
app:srcCompat="@drawable/ic_round_search"
app:tint="@color/colorWhite"
tools:ignore="ContentDescription" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView

View File

@@ -44,4 +44,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tab_layout" />
</RelativeLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/search_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/margin_large"
android:contentDescription="@string/action_search"
app:backgroundTint="?colorAccent"
app:srcCompat="@drawable/ic_round_search"
app:tint="@color/colorWhite" />
</RelativeLayout>