Added profile page
This commit is contained in:
parent
6977c0fc85
commit
b395c4e6e0
@ -101,6 +101,7 @@ dependencies {
|
||||
implementation 'net.danlew:android.joda:2.9.9.4'
|
||||
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation 'android.arch.lifecycle:livedata:1.1.1'
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,11 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name=".ui.customer.ProfileActivity"
|
||||
android:label="@string/title_activity_profile"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.customer.ShippingAddressActivity"
|
||||
android:label="@string/title_activity_shipping_address"
|
||||
|
||||
@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
startActivity(Intent(baseContext, ShippingAddressActivity::class.java))
|
||||
startActivity(Intent(baseContext, HomeActivity::class.java))
|
||||
|
||||
// val intent = Intent(baseContext, ProductActivity::class.java)
|
||||
// intent.putExtra("productId", 63)
|
||||
|
||||
70
app/src/main/java/me/gilo/wc/ui/customer/ProfileActivity.kt
Normal file
70
app/src/main/java/me/gilo/wc/ui/customer/ProfileActivity.kt
Normal file
@ -0,0 +1,70 @@
|
||||
package me.gilo.wc.ui.customer
|
||||
|
||||
import android.arch.lifecycle.Observer
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.widget.Toast
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper
|
||||
import me.gilo.wc.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_profile.*
|
||||
import kotlinx.android.synthetic.main.customer_basic_details.*
|
||||
import me.gilo.wc.common.Status
|
||||
import me.gilo.wc.ui.WooDroidActivity
|
||||
import me.gilo.wc.viewmodels.CustomerViewModel
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class ProfileActivity : WooDroidActivity<CustomerViewModel>() {
|
||||
|
||||
override lateinit var viewModel : CustomerViewModel
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase))
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_profile)
|
||||
|
||||
viewModel = getViewModel(CustomerViewModel::class.java)
|
||||
title = "Profile"
|
||||
|
||||
customer()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun customer() {
|
||||
viewModel.currentCustomer().observe(this, Observer {
|
||||
response->
|
||||
when (response!!.status()){
|
||||
Status.LOADING ->{
|
||||
showLoading("Retrieve customer details", "This will only take a short while")
|
||||
}
|
||||
|
||||
Status.SUCCESS ->{
|
||||
stopShowingLoading()
|
||||
var customer = response.data()[0]
|
||||
|
||||
|
||||
}
|
||||
|
||||
Status.ERROR ->{
|
||||
stopShowingLoading()
|
||||
Toast.makeText(baseContext, response.error().message.toString(), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
Status.EMPTY ->{
|
||||
stopShowingLoading()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
26
app/src/main/res/layout/activity_profile.xml
Normal file
26
app/src/main/res/layout/activity_profile.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?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.customer.ProfileActivity">
|
||||
|
||||
<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_profile"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
204
app/src/main/res/layout/content_profile.xml
Normal file
204
app/src/main/res/layout/content_profile.xml
Normal file
@ -0,0 +1,204 @@
|
||||
<?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"
|
||||
>
|
||||
|
||||
<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="Basic details"
|
||||
android:textColor="@color/text_black_2"
|
||||
android:textSize="20sp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="Basic info about you"
|
||||
android:maxLines="6"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_9"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<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
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:text="John Doe"
|
||||
android:maxLines="6"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_2"
|
||||
android:textSize="16sp"/>
|
||||
<TextView
|
||||
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"/>
|
||||
|
||||
</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="Billing Address"
|
||||
android:textColor="@color/text_black_2"
|
||||
android:textSize="20sp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="Your billing address"
|
||||
android:maxLines="6"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_9"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
|
||||
<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
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:text="Gilbert Kimutai"
|
||||
android:maxLines="6"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_2"
|
||||
android:textSize="16sp"/>
|
||||
<TextView
|
||||
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"/>
|
||||
|
||||
</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="Shipping Address"
|
||||
android:textColor="@color/text_black_2"
|
||||
android:textSize="20sp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="Your shipping address"
|
||||
android:maxLines="6"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_9"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
|
||||
<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
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:text="Gilbert Kimutai"
|
||||
android:maxLines="6"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_2"
|
||||
android:textSize="16sp"/>
|
||||
<TextView
|
||||
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"/>
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
@ -36,5 +36,12 @@
|
||||
<string name="title_activity_basic_customer_details">BasicCustomerDetailsActivity</string>
|
||||
<string name="title_activity_billing_address">BillingAddressActivity</string>
|
||||
<string name="title_activity_shipping_address">ShippingAddressActivity</string>
|
||||
<string name="title_activity_profile">ProfileActivity</string>
|
||||
<string name="dummy_address">
|
||||
953 Market\n
|
||||
San Fransisco, CA 90248 \n
|
||||
United States \n
|
||||
(555) 555 555
|
||||
</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user