Added more ui content(views, handlers, progress) to All pass screen

This commit is contained in:
Dmitry Donskoy 2019-10-31 11:36:42 +03:00 committed by Aleksandr Zatsepin
parent 5a77f4fe8c
commit b1182d43fe
8 changed files with 322 additions and 109 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/yellow" />
<corners android:radius="@dimen/button_small_corner_radius" />
</shape>

View file

@ -1,63 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<layout
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="match_parent">
xmlns:bind="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import
alias="v"
type="android.view.View" />
<import
alias="listener"
type="android.view.View.OnClickListener" />
<import
alias="btn"
type="com.mapswithme.maps.purchase.SubsButtonEntity" />
<import type="java.util.List" />
<variable
name="buttons"
type="List&lt;btn&gt;" />
<variable
name="annualClickListener"
type="listener" />
<variable
name="monthClickListener"
type="listener" />
<variable
name="restoreClickListener"
type="listener" />
<variable
name="termOfUseClickListener"
type="listener" />
<variable
name="privacyPolicyClickListener"
type="listener" />
</data>
<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/img1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img1"/>
<ImageView
android:id="@+id/img2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img2"/>
<ImageView
android:id="@+id/img3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img3"/>
<LinearLayout
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/status_bar_placeholder"
<ImageView
android:id="@+id/img1"
android:layout_width="match_parent"
android:background="@android:color/transparent"
android:layout_height="wrap_content"/>
<com.mapswithme.maps.widget.ParallaxBackgroundViewPager
android:id="@+id/pager"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img1"/>
<ImageView
android:id="@+id/img2"
android:layout_width="match_parent"
android:layout_height="@dimen/subscription_view_pager_height"
android:overScrollMode="never"
app:autoScroll="true"
app:scrollPeriod="4000"/>
<LinearLayout
android:id="@+id/bottom_container"
android:gravity="center_horizontal"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img2"/>
<ImageView
android:id="@+id/img3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img3"/>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/margin_base_plus"/>
</LinearLayout>
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
</RelativeLayout>
<View
android:id="@+id/status_bar_placeholder"
android:layout_width="match_parent"
android:background="@android:color/transparent"
android:layout_height="wrap_content"/>
<com.mapswithme.maps.widget.ParallaxBackgroundViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/subscription_view_pager_margin"
android:layout_height="@dimen/subscription_view_pager_height"
android:overScrollMode="never"
app:autoScroll="true"
app:scrollPeriod="4000"/>
<LinearLayout
android:id="@+id/bottom_container"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/margin_base_plus"/>
<FrameLayout
android:layout_marginTop="@dimen/nav_street_height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<LinearLayout
android:id="@+id/sub_buttons_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="@{buttons == null || buttons.isEmpty() ? v.GONE : v.VISIBLE}"
android:orientation="vertical">
<include
bind:entity="@{buttons[0]}"
bind:clickListener="@{annualClickListener}"
bind:saleTextColor="@{@color/tips_and_triks_primary_text_night}"
bind:saleBackground="@{@drawable/all_pass_sale_bg}"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginStart="@dimen/margin_base_plus"
android:layout_marginEnd="@dimen/margin_base_plus"
layout="@layout/subscription_button" />
<include
bind:entity="@{buttons[1]}"
bind:clickListener="@{monthClickListener}"
bind:buttonBackground="@{@drawable/button_accent}"
bind:buttonTextColor="@{@color/black_primary}"
android:layout_marginTop="@dimen/margin_base"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginStart="@dimen/margin_base_plus"
android:layout_marginEnd="@dimen/margin_base_plus"
layout="@layout/subscription_button" />
</LinearLayout>
<ProgressBar
android:id="@+id/progress"
android:visibility="@{buttons == null || buttons.isEmpty() ? v.VISIBLE : v.GONE}"
android:layout_width="@dimen/primary_button_min_height"
android:layout_height="@dimen/primary_button_min_height"
android:layout_gravity="center"
tools:visibility="visible"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</layout>

View file

@ -1,63 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:id="@+id/button_container"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import
alias="v"
type="android.view.View" />
<import type="androidx.core.content.ContextCompat" />
<import type="android.text.TextUtils" />
<import type="com.mapswithme.maps.R" />
<import
alias="listener"
type="android.view.View.OnClickListener" />
<variable
name="entity"
type="com.mapswithme.maps.purchase.SubsButtonEntity" />
<variable
name="clickListener"
type="listener" />
<variable
name="buttonBackground"
type="android.graphics.drawable.Drawable" />
<variable
name="buttonTextColor"
type="java.lang.Integer" />
<variable
name="saleBackground"
type="android.graphics.drawable.Drawable" />
<variable
name="saleTextColor"
type="java.lang.Integer" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/margin_base"
android:minHeight="@dimen/height_block_base"
android:layout_marginTop="@dimen/margin_base_plus_quarter"
tools:background="?primaryButtonBackground">
<TextView
android:id="@+id/name"
android:layout_toStartOf="@id/price"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:id="@+id/button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:textColor="@color/white_primary"
android:fontFamily="@string/robotoMedium"
android:textSize="@dimen/text_size_body_3"
android:textAllCaps="true"
android:letterSpacing="0.04"
tools:text="ANNUAL"
tools:targetApi="lollipop" />
android:minHeight="@dimen/height_block_base"
android:orientation="horizontal"
android:padding="@dimen/margin_base"
android:onClick="@{(view) -> clickListener.onClick(view)}"
android:background="@{buttonBackground ?? @drawable/button_accent}"
app:layout_marginTop_subs_button="@{TextUtils.isEmpty(entity.sale) ? @dimen/zero : @dimen/margin_base_plus_quarter}"
tools:background="?primaryButtonBackground">
<TextView
android:id="@+id/name"
android:layout_toStartOf="@id/price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:textColor="@{buttonTextColor ?? @color/white_primary}"
android:fontFamily="@string/robotoMedium"
android:textSize="@dimen/text_size_body_3"
android:textAllCaps="true"
android:letterSpacing="0.04"
android:text="@{entity.name}"
tools:text="ANNUAL"
tools:targetApi="lollipop" />
<TextView
android:id="@id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:textColor="@{buttonTextColor ?? @color/white_primary}"
android:fontFamily="@string/robotoMedium"
android:textSize="@dimen/text_size_body_3"
android:textAllCaps="true"
android:text="@{entity.price}"
android:letterSpacing="0.04"
tools:text="VNG 29000 / MO"
tools:targetApi="lollipop" />
</RelativeLayout>
<TextView
android:id="@id/price"
android:id="@+id/sale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:textColor="@color/white_primary"
android:layout_marginStart="@dimen/margin_quarter"
android:paddingLeft="@dimen/margin_half_plus"
android:paddingStart="@dimen/margin_half_plus"
android:paddingRight="@dimen/margin_half_plus"
android:paddingEnd="@dimen/margin_half_plus"
android:paddingTop="@dimen/margin_quarter"
android:paddingBottom="@dimen/margin_quarter"
android:layout_gravity="top|start"
android:gravity="center_horizontal|top"
android:textSize="@dimen/text_size_toolbar"
android:textColor="@{saleTextColor ?? @color/white_primary}"
android:fontFamily="@string/robotoMedium"
android:textSize="@dimen/text_size_body_3"
android:textAllCaps="true"
android:letterSpacing="0.04"
tools:text="VNG 29000 / MO"
android:background="@{saleBackground ?? @drawable/button_accent}"
android:visibility="@{TextUtils.isEmpty(entity.sale) ? v.GONE : v.VISIBLE}"
android:text="@{entity.sale}"
android:letterSpacing="0.15"
android:elevation="@dimen/margin_eighth"
tools:text="-30%"
tools:background="@color/sale_view_bg"
tools:targetApi="lollipop" />
</RelativeLayout>
<TextView
android:id="@+id/sale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_quarter"
android:paddingLeft="@dimen/margin_half_plus"
android:paddingStart="@dimen/margin_half_plus"
android:paddingRight="@dimen/margin_half_plus"
android:paddingEnd="@dimen/margin_half_plus"
android:paddingTop="@dimen/margin_quarter"
android:paddingBottom="@dimen/margin_quarter"
android:layout_gravity="top|start"
android:gravity="center_horizontal|top"
android:textSize="@dimen/text_size_toolbar"
android:textColor="@color/white_primary"
android:fontFamily="@string/robotoMedium"
android:letterSpacing="0.15"
android:elevation="@dimen/margin_eighth"
tools:text="-30%"
tools:background="@color/sale_view_bg"
tools:targetApi="lollipop" />
</FrameLayout>
</FrameLayout>
</layout>

View file

@ -211,4 +211,5 @@
<color name="bg_sightseeing_subs">#F0FCFF</color>
<color name="notification">#82E510</color>
<color name="yellow">#FFC800</color>
</resources>

View file

@ -278,4 +278,6 @@
<dimen name="pro_label_margin">52dp</dimen>
<dimen name="promo_single_place_container_height">194dp</dimen>
<dimen name="subscription_view_pager_height">144dp</dimen>
<dimen name="zero">0dp</dimen>
<dimen name="subscription_view_pager_margin">28dp</dimen>
</resources>

View file

@ -7,6 +7,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
@ -14,27 +15,42 @@ import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.maps.databinding.PagerFragmentAllPassPremiumBinding;
import com.mapswithme.maps.widget.DotPager;
import com.mapswithme.maps.widget.ParallaxBackgroundPageListener;
import com.mapswithme.maps.widget.ParallaxBackgroundViewPager;
import com.mapswithme.util.UiUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AllPassPremiumPagerFragment extends BaseMwmFragment
{
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState)
{
View root = inflater.inflate(R.layout.pager_fragment_all_pass_premium, container, false);
PagerFragmentAllPassPremiumBinding dataBinding
= DataBindingUtil.inflate(inflater, R.layout.pager_fragment_all_pass_premium, container, false);
View root = dataBinding.getRoot();
dataBinding.setButtons(makeButtons());
dataBinding.setAnnualClickListener(v -> {});
dataBinding.setMonthClickListener(v -> {});
initStatusBarPlaceholder(root);
initViewPager(root);
return root;
}
@NonNull
private static List<SubsButtonEntity> makeButtons()
{
return Arrays.asList(new SubsButtonEntity("sadasdasdsd", "20usd", "-20%"),
new SubsButtonEntity("sadasdasdsd", "30usd"));
}
private void initStatusBarPlaceholder(@NonNull View root)
{
View statusBarPlaceholder = root.findViewById(R.id.status_bar_placeholder);

View file

@ -0,0 +1,16 @@
package com.mapswithme.maps.purchase;
import android.view.View;
import android.view.ViewGroup;
import androidx.databinding.BindingAdapter;
public class DataBindings
{
@BindingAdapter("layout_marginTop_subs_button")
public static void setTopMargin(View view, float margin) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
layoutParams.topMargin = Math.round(margin);
view.setLayoutParams(layoutParams);
}
}

View file

@ -0,0 +1,46 @@
package com.mapswithme.maps.purchase;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class SubsButtonEntity
{
@NonNull
private final String mName;
@NonNull
private final String mPrice;
@Nullable
private final String mSale;
SubsButtonEntity(@NonNull String name, @NonNull String price, @Nullable String sale)
{
mName = name;
mPrice = price;
mSale = sale;
}
SubsButtonEntity(@NonNull String name, @NonNull String price)
{
this(name, price, null);
}
@NonNull
public String getName()
{
return mName;
}
@NonNull
public String getPrice()
{
return mPrice;
}
@Nullable
public String getSale()
{
return mSale;
}
}