forked from organicmaps/organicmaps
[android] Implemented base logic for showing the guests/romms bottom sheet by clicking on rooms chip in toolbar
This commit is contained in:
parent
fc1ac24b99
commit
1157bf5fa1
6 changed files with 131 additions and 2 deletions
|
@ -99,6 +99,7 @@
|
|||
<include layout="@layout/elevation_profile_bottom_sheet" />
|
||||
<include layout="@layout/main_menu_bottom_sheet" />
|
||||
<include layout="@layout/guides_gallery_bottom_sheet" />
|
||||
<include layout="@layout/guests_and_rooms_menu_bottom_sheet" />
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
app:layout_behavior="@string/placepage_toolbar_behavior"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
@ -85,6 +86,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
<include layout="@layout/guests_and_rooms_menu_bottom_sheet" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</FrameLayout>
|
||||
|
||||
|
|
67
android/res/layout/guests_and_rooms_menu_bottom_sheet.xml
Normal file
67
android/res/layout/guests_and_rooms_menu_bottom_sheet.xml
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/guests_and_rooms_menu_sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?windowBackgroundForced"
|
||||
android:clickable="true"
|
||||
android:fillViewport="true"
|
||||
android:focusable="true"
|
||||
app:behavior_defaultState="hidden"
|
||||
app:behavior_hideable="true"
|
||||
app:behavior_peekHeight="0dp"
|
||||
app:behavior_skipAnchored="true"
|
||||
app:behavior_skipCollapsed="true"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?cardBackground"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingTop="@dimen/margin_half_plus"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingBottom="@dimen/margin_half_plus"
|
||||
android:text="@string/guests_picker_rooms_title"
|
||||
android:textAppearance="?fontSubtitle2" />
|
||||
<com.mapswithme.maps.widget.InteractiveCounterView
|
||||
android:id="@+id/rooms"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@android:drawable/star_on"
|
||||
app:maxValue="30"
|
||||
app:minValue="1"
|
||||
app:title="@string/guests_picker_rooms" />
|
||||
<com.mapswithme.maps.widget.InteractiveCounterView
|
||||
android:id="@+id/adults"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@android:drawable/star_on"
|
||||
app:maxValue="30"
|
||||
app:minValue="1"
|
||||
app:title="@string/guests_picker_adults" />
|
||||
<com.mapswithme.maps.widget.InteractiveCounterView
|
||||
android:id="@+id/children"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@android:drawable/star_on"
|
||||
app:maxValue="10"
|
||||
app:minValue="0"
|
||||
app:subtitle="@string/guests_picker_children_subtitle"
|
||||
app:title="@string/guests_picker_children_title" />
|
||||
<com.mapswithme.maps.widget.InteractiveCounterView
|
||||
android:id="@+id/infants"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@android:drawable/star_on"
|
||||
app:maxValue="10"
|
||||
app:minValue="0"
|
||||
app:subtitle="@string/guests_picker_infants_subtitle"
|
||||
app:title="@string/guests_picker_infants_title" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -23,6 +23,8 @@ import com.google.android.material.datepicker.MaterialPickerOnPositiveButtonClic
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.search.BookingFilterParams;
|
||||
import com.mapswithme.maps.search.FilterUtils;
|
||||
import com.mapswithme.maps.widget.menu.MenuController;
|
||||
import com.mapswithme.maps.widget.menu.MenuControllerFactory;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.InputUtils;
|
||||
import com.mapswithme.util.StringUtils;
|
||||
|
@ -66,7 +68,6 @@ public class SearchToolbarController extends ToolbarController
|
|||
};
|
||||
@Nullable
|
||||
private Pair<Long, Long> mChosenDates;
|
||||
|
||||
@NonNull
|
||||
private final View.OnClickListener mChooseDatesClickListener = v -> {
|
||||
if (!ConnectionState.isConnected())
|
||||
|
@ -85,15 +86,30 @@ public class SearchToolbarController extends ToolbarController
|
|||
picker.addOnPositiveButtonClickListener(new DatePickerPositiveClickListener(picker));
|
||||
picker.show(((AppCompatActivity) getActivity()).getSupportFragmentManager(), picker.toString());
|
||||
};
|
||||
|
||||
@NonNull
|
||||
private List<FilterParamsChangedListener> mFilterParamsChangedListeners = new ArrayList<>();
|
||||
@NonNull
|
||||
private MenuController mGuiestsRoomsMenuController;
|
||||
@NonNull
|
||||
private final View.OnClickListener mRoomsClickListener = v -> {
|
||||
if (!ConnectionState.isConnected())
|
||||
{
|
||||
FilterUtils.showNoNetworkConnectionDialog((AppCompatActivity) getActivity());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mGuiestsRoomsMenuController.isClosed())
|
||||
return;
|
||||
|
||||
mGuiestsRoomsMenuController.open();
|
||||
};
|
||||
|
||||
public interface Container
|
||||
{
|
||||
SearchToolbarController getController();
|
||||
}
|
||||
|
||||
|
||||
public SearchToolbarController(View root, Activity activity)
|
||||
{
|
||||
super(root, activity);
|
||||
|
@ -125,10 +141,14 @@ public class SearchToolbarController extends ToolbarController
|
|||
//noinspection ConstantConditions
|
||||
mChooseDatesChip.setOnClickListener(mChooseDatesClickListener);
|
||||
mChooseDatesChip.setOnCloseIconClickListener(mChooseDatesClickListener);
|
||||
mRooms.setOnClickListener(mRoomsClickListener);
|
||||
mRooms.setOnCloseIconClickListener(mRoomsClickListener);
|
||||
}
|
||||
|
||||
showProgress(false);
|
||||
updateButtons(true);
|
||||
mGuiestsRoomsMenuController = MenuControllerFactory.createGuestsRoomsMenuController();
|
||||
mGuiestsRoomsMenuController.initialize(getActivity().findViewById(R.id.coordinator));
|
||||
}
|
||||
|
||||
public void setFilterParams(@NonNull BookingFilterParams params)
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.mapswithme.maps.widget.menu;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class GuestsRoomsMenuRenderer implements MenuRenderer
|
||||
{
|
||||
@Override
|
||||
public void render()
|
||||
{
|
||||
// TODO: coming soon.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHide()
|
||||
{
|
||||
// TODO: coming soon.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(@Nullable View view)
|
||||
{
|
||||
// TODO: coming soon.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
// TODO: coming soon.
|
||||
}
|
||||
}
|
|
@ -16,4 +16,11 @@ public class MenuControllerFactory
|
|||
noConnectionListener),
|
||||
stateObserver);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static MenuController createGuestsRoomsMenuController()
|
||||
{
|
||||
return new BottomSheetMenuController(R.id.guests_and_rooms_menu_sheet,
|
||||
new GuestsRoomsMenuRenderer(), null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue