Skip to content

Commit

Permalink
todo: Order detail and user information
Browse files Browse the repository at this point in the history
  • Loading branch information
nqmgaming committed Jun 5, 2024
1 parent e14b08d commit 1ca6bde
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 22 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
android:usesCleartextTraffic="true"
tools:replace="android:label"
tools:targetApi="31">
<activity
android:name=".ui.activities.order_detail.OrderDetailActivity"
android:exported="false" />
<activity
android:name=".ui.activities.order.OrderActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.nqmgaming.shoseshop.ui.activities.order_detail

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.nqmgaming.shoseshop.R

class OrderDetailActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_order_detail)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,30 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.google.android.material.tabs.TabLayoutMediator
import com.nqmgaming.shoseshop.adapter.viewpagger2.OrderAdapter
import com.nqmgaming.shoseshop.databinding.FragmentOrderBinding
import com.nqmgaming.shoseshop.util.SharedPrefUtils
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class OrderFragment : Fragment() {
private var _binding: FragmentOrderBinding? = null
private val binding get() = _binding!!
private val viewModel by viewModels<OrderViewModel>()

private lateinit var orderAdapter: OrderAdapter

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
_binding = FragmentOrderBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val token = SharedPrefUtils.getString(requireContext(), "accessToken", "") ?: ""
val bearerToken = "Bearer $token"
val userId = SharedPrefUtils.getString(requireContext(), "id", "") ?: ""

orderAdapter = OrderAdapter(this)
binding.viewpager.adapter = orderAdapter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package com.nqmgaming.shoseshop.ui.fragments.order
import android.app.Application
import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.nqmgaming.shoseshop.data.model.order.Order
import com.nqmgaming.shoseshop.data.repository.ShoesRepository
import com.nqmgaming.shoseshop.util.SharedPrefUtils
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.nqmgaming.shoseshop.ui.fragments.order.fragments

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.nqmgaming.shoseshop.R
import com.nqmgaming.shoseshop.adapter.order.OrderTotalAdapter
import com.nqmgaming.shoseshop.databinding.FragmentCancelBinding
import com.nqmgaming.shoseshop.ui.activities.order_detail.OrderDetailActivity
import com.nqmgaming.shoseshop.ui.fragments.cart.CartViewModel
import com.nqmgaming.shoseshop.ui.fragments.order.OrderViewModel
import com.nqmgaming.shoseshop.util.SharedPrefUtils
Expand Down Expand Up @@ -57,7 +58,11 @@ class CancelFragment : Fragment() {
token = bearerToken
).apply {
differ.submitList(orders.reversed())

setOnItemClickListener {
val intent = Intent(requireContext(), OrderDetailActivity::class.java)
intent.putExtra("orderId", it.id)
startActivity(intent)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.nqmgaming.shoseshop.ui.fragments.order.fragments

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.nqmgaming.shoseshop.R
import com.nqmgaming.shoseshop.adapter.order.OrderTotalAdapter
import com.nqmgaming.shoseshop.databinding.FragmentDeliveredBinding
import com.nqmgaming.shoseshop.ui.activities.order_detail.OrderDetailActivity
import com.nqmgaming.shoseshop.ui.fragments.cart.CartViewModel
import com.nqmgaming.shoseshop.ui.fragments.order.OrderViewModel
import com.nqmgaming.shoseshop.util.SharedPrefUtils
Expand Down Expand Up @@ -60,8 +61,11 @@ class DeliveredFragment : Fragment() {
token = bearerToken
).apply {
differ.submitList(orders.reversed())

}
setOnItemClickListener {
val intent = Intent(requireContext(), OrderDetailActivity::class.java)
intent.putExtra("orderId", it.id)
startActivity(intent)
} }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.nqmgaming.shoseshop.ui.fragments.order.fragments

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.nqmgaming.shoseshop.R
import com.nqmgaming.shoseshop.adapter.order.OrderTotalAdapter
import com.nqmgaming.shoseshop.databinding.FragmentPendingBinding
import com.nqmgaming.shoseshop.ui.activities.order_detail.OrderDetailActivity
import com.nqmgaming.shoseshop.ui.fragments.cart.CartViewModel
import com.nqmgaming.shoseshop.ui.fragments.order.OrderViewModel
import com.nqmgaming.shoseshop.util.SharedPrefUtils
Expand Down Expand Up @@ -62,7 +63,11 @@ class PendingFragment : Fragment() {
token = bearerToken
).apply {
differ.submitList(orders.reversed())

setOnItemClickListener {
val intent = Intent(requireContext(), OrderDetailActivity::class.java)
intent.putExtra("orderId", it.id)
startActivity(intent)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.nqmgaming.shoseshop.ui.fragments.order.fragments

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.nqmgaming.shoseshop.R
import com.nqmgaming.shoseshop.adapter.order.OrderTotalAdapter
import com.nqmgaming.shoseshop.databinding.FragmentProgressBinding
import com.nqmgaming.shoseshop.ui.activities.order_detail.OrderDetailActivity
import com.nqmgaming.shoseshop.ui.fragments.cart.CartViewModel
import com.nqmgaming.shoseshop.ui.fragments.order.OrderViewModel
import com.nqmgaming.shoseshop.util.SharedPrefUtils
Expand All @@ -33,7 +34,7 @@ class ProgressFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
_binding = FragmentProgressBinding.inflate(inflater, container, false)
return binding.root
}
Expand All @@ -56,7 +57,11 @@ class ProgressFragment : Fragment() {
token = bearerToken
).apply {
differ.submitList(orders.reversed())

setOnItemClickListener {
val intent = Intent(requireContext(), OrderDetailActivity::class.java)
intent.putExtra("orderId", it.id)
startActivity(intent)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.nqmgaming.shoseshop.ui.fragments.order.fragments

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.nqmgaming.shoseshop.R
import com.nqmgaming.shoseshop.adapter.order.OrderTotalAdapter
import com.nqmgaming.shoseshop.databinding.FragmentShipBinding
import com.nqmgaming.shoseshop.ui.activities.order_detail.OrderDetailActivity
import com.nqmgaming.shoseshop.ui.fragments.cart.CartViewModel
import com.nqmgaming.shoseshop.ui.fragments.order.OrderViewModel
import com.nqmgaming.shoseshop.util.SharedPrefUtils
Expand Down Expand Up @@ -58,7 +59,11 @@ class ShipFragment : Fragment() {
token = bearerToken
).apply {
differ.submitList(orders.reversed())

setOnItemClickListener {
val intent = Intent(requireContext(), OrderDetailActivity::class.java)
intent.putExtra("orderId", it.id)
startActivity(intent)
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_order_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activities.order_detail.OrderDetailActivity">

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 1ca6bde

Please sign in to comment.