forked from organicmaps/organicmaps
Add button to close layer bottomsheet (#7083)
Signed-off-by: Jean-BaptisteC <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
parent
1e2158a004
commit
8f61df8223
2 changed files with 47 additions and 9 deletions
|
@ -16,13 +16,16 @@ import app.organicmaps.R;
|
|||
import app.organicmaps.maplayer.isolines.IsolinesManager;
|
||||
import app.organicmaps.util.SharedPropertiesUtils;
|
||||
import app.organicmaps.util.Utils;
|
||||
import app.organicmaps.util.bottomsheet.MenuBottomSheetFragment;
|
||||
import app.organicmaps.widget.recycler.SpanningLinearLayoutManager;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ToggleMapLayerFragment extends Fragment
|
||||
{
|
||||
private static final String LAYERS_MENU_ID = "LAYERS_MENU_BOTTOM_SHEET";
|
||||
@Nullable
|
||||
private LayersAdapter mAdapter;
|
||||
private MapButtonsViewModel mMapButtonsViewModel;
|
||||
|
@ -34,6 +37,8 @@ public class ToggleMapLayerFragment extends Fragment
|
|||
View mRoot = inflater.inflate(R.layout.fragment_toggle_map_layer, container, false);
|
||||
|
||||
mMapButtonsViewModel = new ViewModelProvider(requireActivity()).get(MapButtonsViewModel.class);
|
||||
MaterialButton mCloseButton = mRoot.findViewById(R.id.close_button);
|
||||
mCloseButton.setOnClickListener(view -> closeLayerBottomSheet());
|
||||
|
||||
initRecycler(mRoot);
|
||||
return mRoot;
|
||||
|
@ -72,4 +77,12 @@ public class ToggleMapLayerFragment extends Fragment
|
|||
if (IsolinesManager.from(context).shouldShowNotification())
|
||||
Utils.showSnackbar(context, v.getRootView(), R.string.isolines_toast_zooms_1_10);
|
||||
}
|
||||
|
||||
private void closeLayerBottomSheet()
|
||||
{
|
||||
MenuBottomSheetFragment bottomSheet =
|
||||
(MenuBottomSheetFragment) requireActivity().getSupportFragmentManager().findFragmentByTag(LAYERS_MENU_ID);
|
||||
if (bottomSheet != null)
|
||||
bottomSheet.dismiss();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
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="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/layers_text"
|
||||
android:layout_width="wrap_content"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_base"
|
||||
android:layout_marginTop="@dimen/margin_base"
|
||||
android:text="@string/layers_title"
|
||||
android:textAppearance="?fontHeadline6" />
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/layers_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_base"
|
||||
android:layout_marginTop="@dimen/margin_base"
|
||||
android:text="@string/layers_title"
|
||||
android:textAppearance="?fontHeadline6"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/close_button"
|
||||
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
|
||||
android:layout_width="@dimen/place_page_top_button"
|
||||
android:layout_height="@dimen/place_page_top_button"
|
||||
android:layout_marginEnd="@dimen/margin_half_plus"
|
||||
android:layout_marginTop="@dimen/margin_half_plus"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/close"
|
||||
app:icon="@drawable/ic_close"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?iconTint"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Button.Round" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler"
|
||||
|
|
Loading…
Add table
Reference in a new issue