Added shipping address and payment checkout options on design
This commit is contained in:
parent
0bb4360564
commit
9136c6c337
@ -13,6 +13,11 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
|
<activity
|
||||||
|
android:name=".ui.checkout.CheckoutActivity"
|
||||||
|
android:label="@string/title_activity_checkout"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.product.CartActivity"
|
android:name=".ui.product.CartActivity"
|
||||||
android:label="@string/title_activity_cart"
|
android:label="@string/title_activity_cart"
|
||||||
|
|||||||
23
app/src/main/java/me/gilo/wc/ui/checkout/CheckoutActivity.kt
Normal file
23
app/src/main/java/me/gilo/wc/ui/checkout/CheckoutActivity.kt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package me.gilo.wc.ui.checkout
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.design.widget.Snackbar
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
import me.gilo.wc.R
|
||||||
|
|
||||||
|
import kotlinx.android.synthetic.main.activity_checkout.*
|
||||||
|
|
||||||
|
class CheckoutActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_checkout)
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
|
||||||
|
fab.setOnClickListener { view ->
|
||||||
|
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Action", null).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package me.gilo.wc.viewmodels;
|
package me.gilo.wc.viewmodels;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.MutableLiveData;
|
||||||
import android.arch.lifecycle.ViewModel;
|
import android.arch.lifecycle.ViewModel;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import com.google.firebase.firestore.DocumentReference;
|
import com.google.firebase.firestore.DocumentReference;
|
||||||
@ -10,6 +11,7 @@ import me.gilo.wc.models.CartLineItem;
|
|||||||
import me.gilo.wc.repo.CartRepository;
|
import me.gilo.wc.repo.CartRepository;
|
||||||
import me.gilo.wc.repo.OrderRepository;
|
import me.gilo.wc.repo.OrderRepository;
|
||||||
import me.gilo.wc.repo.ProductRepository;
|
import me.gilo.wc.repo.ProductRepository;
|
||||||
|
import me.gilo.wc.repo.ReviewRepository;
|
||||||
import me.gilo.woodroid.models.LineItem;
|
import me.gilo.woodroid.models.LineItem;
|
||||||
import me.gilo.woodroid.models.Product;
|
import me.gilo.woodroid.models.Product;
|
||||||
import me.gilo.woodroid.models.ProductReview;
|
import me.gilo.woodroid.models.ProductReview;
|
||||||
@ -25,16 +27,25 @@ public final class ProductViewModel extends ViewModel {
|
|||||||
private final OrderRepository orderRepository;
|
private final OrderRepository orderRepository;
|
||||||
private final CartRepository cartRepository;
|
private final CartRepository cartRepository;
|
||||||
|
|
||||||
|
private final MutableLiveData<Integer> selectedProductId = new MutableLiveData();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ProductViewModel(ProductRepository productRepository,
|
ProductViewModel(ProductRepository productRepository,
|
||||||
OrderRepository orderRepository,
|
OrderRepository orderRepository,
|
||||||
CartRepository cartRepository
|
CartRepository cartRepository) {
|
||||||
) {
|
|
||||||
this.productRepository = productRepository;
|
this.productRepository = productRepository;
|
||||||
this.orderRepository = orderRepository;
|
this.orderRepository = orderRepository;
|
||||||
this.cartRepository = cartRepository;
|
this.cartRepository = cartRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getSelectedProduct() {
|
||||||
|
return selectedProductId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectProduct(int productId) {
|
||||||
|
selectedProductId.setValue(productId);
|
||||||
|
}
|
||||||
|
|
||||||
public WooLiveData<List<Product>> products() {
|
public WooLiveData<List<Product>> products() {
|
||||||
return productRepository.products();
|
return productRepository.products();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package me.gilo.wc.viewmodels;
|
package me.gilo.wc.viewmodels;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.MutableLiveData;
|
||||||
import android.arch.lifecycle.ViewModel;
|
import android.arch.lifecycle.ViewModel;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import me.gilo.wc.common.WooLiveData;
|
import me.gilo.wc.common.WooLiveData;
|
||||||
|
|||||||
34
app/src/main/res/layout/activity_checkout.xml
Normal file
34
app/src/main/res/layout/activity_checkout.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
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:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.checkout.CheckoutActivity">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/content_checkout"/>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
app:srcCompat="@android:drawable/ic_dialog_email"/>
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
@ -165,8 +165,85 @@
|
|||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
fontPath="@string/font_medium"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:text="Shipping To"
|
||||||
|
android:textColor="@color/text_black_2"
|
||||||
|
android:textSize="20sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/rect_white"
|
||||||
|
android:elevation="2dp"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvShippingAddress"
|
||||||
|
fontPath="@string/font_regular"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="left"
|
||||||
|
android:text="@string/dummy_address"
|
||||||
|
android:maxLines="6"
|
||||||
|
android:lineSpacingMultiplier="1.2"
|
||||||
|
android:textColor="@color/text_black_5"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvShippingAddressEdit"
|
||||||
|
fontPath="@string/font_regular"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="right"
|
||||||
|
android:text="Edit"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:lineSpacingMultiplier="1.2"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
fontPath="@string/font_medium"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:text="Pay with"
|
||||||
|
android:textColor="@color/text_black_2"
|
||||||
|
android:textSize="20sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/rect_white"
|
||||||
|
android:elevation="2dp"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</android.support.v4.widget.NestedScrollView>
|
</android.support.v4.widget.NestedScrollView>
|
||||||
143
app/src/main/res/layout/content_checkout.xml
Normal file
143
app/src/main/res/layout/content_checkout.xml
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.NestedScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:attrs="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@color/bg"
|
||||||
|
tools:ignore="MissingPrefix"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:background="#d8d8d8"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTotalItemCountTitle"
|
||||||
|
fontPath="@string/font_regular"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="left"
|
||||||
|
android:text="Item (1)"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textColor="@color/text_black_9"
|
||||||
|
android:textSize="14sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTotalItemCost"
|
||||||
|
fontPath="@string/font_medium"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="right"
|
||||||
|
android:text="$0"
|
||||||
|
android:textColor="@color/text_black_9"
|
||||||
|
android:textSize="14sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvShippingTitle"
|
||||||
|
fontPath="@string/font_regular"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="left"
|
||||||
|
android:text="Shipping within San Fransisco"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textColor="@color/text_black_9"
|
||||||
|
android:textSize="14sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvShippingCost"
|
||||||
|
fontPath="@string/font_medium"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="right"
|
||||||
|
android:text="$0"
|
||||||
|
android:textColor="@color/text_black_9"
|
||||||
|
android:textSize="14sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:background="#d8d8d8"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="16dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
fontPath="@string/font_medium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="left"
|
||||||
|
android:text="Total"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textColor="@color/text_black_2"
|
||||||
|
android:textSize="20sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTotal"
|
||||||
|
fontPath="@string/font_medium"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="right"
|
||||||
|
android:text="$0"
|
||||||
|
android:textColor="@color/text_black_2"
|
||||||
|
android:textSize="20sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</android.support.v4.widget.NestedScrollView>
|
||||||
@ -44,5 +44,6 @@
|
|||||||
(555) 555 555
|
(555) 555 555
|
||||||
</string>
|
</string>
|
||||||
<string name="title_activity_cart">CartActivity</string>
|
<string name="title_activity_cart">CartActivity</string>
|
||||||
|
<string name="title_activity_checkout">CheckoutActivity</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user