Browse Source

feat: 商城

tongmengxiao 5 months ago
parent
commit
3974fd0f08

+ 1 - 0
baseswago/src/main/java/com/swago/baseswago/constant/ARouteConstant.kt

@@ -27,6 +27,7 @@ object ARouteConstant {
         const val coinTransfer = "$rootPath/CoinTransferActivity"
         const val transferDetail = "$rootPath/TransferDetailsActivity"
         const val modifyPwd = "$rootPath/ModifyPwdActivity"
+        const val storeList = "$rootPath/StoreListActivity"
     }
 
     object Home {

+ 5 - 0
baseswago/src/main/res/drawable/shape_d54941_circle.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+    <solid android:color="#d54941"/>
+</shape>

BIN
baseswago/src/main/res/mipmap-xxhdpi/bg_store.png


+ 12 - 0
home/src/main/java/com/swago/home/MineFragment.kt

@@ -156,6 +156,18 @@ class MineFragment : BaseXFragment<FragmentMineBinding>() {
             }
         })
 
+        binding.tvXStore.setOnClickListener(object :NoDoubleClickListener(){
+            override fun onClick() {
+                ARouter.getInstance().build(ARouteConstant.User.storeList).navigation()
+            }
+        })
+
+        binding.tvXoutfit.setOnClickListener(object :NoDoubleClickListener(){
+            override fun onClick() {
+                ARouter.getInstance().build(ARouteConstant.User.storeList).navigation()
+            }
+        })
+
         payVm.getBenefit()
     }
 

+ 16 - 0
home/src/main/res/layout/activity_home.xml

@@ -1,6 +1,7 @@
 <?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:layout_width="match_parent"
     android:layout_height="match_parent">
 
@@ -51,4 +52,19 @@
 
     </RadioGroup>
 
+    <TextView
+        android:id="@+id/tvMessageNum"
+        android:layout_width="12dp"
+        android:layout_height="12dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:layout_marginBottom="30dp"
+        android:layout_marginStart="20dp"
+        android:textColor="#fff"
+        tools:text="1"
+        android:textSize="8sp"
+        android:gravity="center"
+        android:background="@drawable/shape_d54941_circle"/>
+
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 35 - 6
home/src/main/res/layout/fragment_mine.xml

@@ -270,7 +270,7 @@
     <androidx.constraintlayout.widget.ConstraintLayout
         android:id="@+id/frameLayout"
         android:layout_width="match_parent"
-        android:layout_height="80dp"
+        android:layout_height="wrap_content"
         android:layout_marginStart="16dp"
         android:layout_marginTop="21dp"
         android:layout_marginEnd="16dp"
@@ -286,7 +286,7 @@
             android:text="@string/level"
             android:textColor="#131B23"
             android:textSize="12dp"
-            app:layout_constraintBottom_toBottomOf="parent"
+            android:layout_marginTop="12dp"
             app:layout_constraintEnd_toStartOf="@+id/tvXTopUp"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
@@ -300,7 +300,7 @@
             android:text="@string/top_up"
             android:textColor="#131B23"
             android:textSize="12dp"
-            app:layout_constraintBottom_toBottomOf="parent"
+            android:layout_marginTop="12dp"
             app:layout_constraintEnd_toStartOf="@+id/tvXWithdrawal"
             app:layout_constraintStart_toEndOf="@+id/tvXLevel"
             app:layout_constraintTop_toTopOf="parent" />
@@ -314,8 +314,8 @@
             android:text="@string/withdrawal"
             android:textColor="#131B23"
             android:textSize="12dp"
+            android:layout_marginTop="12dp"
             android:visibility="gone"
-            app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toStartOf="@+id/tvXTaskCenter"
             app:layout_constraintStart_toEndOf="@+id/tvXTopUp"
             app:layout_constraintTop_toTopOf="parent" />
@@ -329,11 +329,40 @@
             android:text="@string/task_center"
             android:textColor="#131B23"
             android:textSize="12dp"
-            app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintEnd_toEndOf="parent"
+            android:layout_marginTop="12dp"
             app:layout_constraintStart_toEndOf="@+id/tvXWithdrawal"
+            app:layout_constraintEnd_toStartOf="@+id/tvXStore"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <com.swago.baseswago.cusview.RegularTextView
+            android:id="@+id/tvXStore"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:drawableTop="@mipmap/icon_my_store"
+            android:drawablePadding="2dp"
+            android:text="@string/task_center"
+            android:textColor="#131B23"
+            android:textSize="12dp"
+            android:layout_marginTop="12dp"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toEndOf="@+id/tvXTaskCenter"
             app:layout_constraintTop_toTopOf="parent" />
 
+        <com.swago.baseswago.cusview.RegularTextView
+            android:id="@+id/tvXoutfit"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:drawableTop="@mipmap/icon_my_outfit"
+            android:drawablePadding="2dp"
+            android:text="@string/level"
+            android:textColor="#131B23"
+            android:textSize="12dp"
+            android:layout_marginTop="12dp"
+            android:layout_marginBottom="12dp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toStartOf="@+id/tvXTopUp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvXLevel" />
 
     </androidx.constraintlayout.widget.ConstraintLayout>
 

BIN
home/src/main/res/mipmap-xxhdpi/icon_my_outfit.png


BIN
home/src/main/res/mipmap-xxhdpi/icon_my_store.png


+ 2 - 0
user/src/main/AndroidManifest.xml

@@ -31,6 +31,8 @@
             android:screenOrientation="portrait"/>
         <activity android:name=".ModifyPwdActivity"
             android:screenOrientation="portrait"/>
+        <activity android:name=".store.StoreListActivity"
+            android:screenOrientation="portrait"/>
     </application>
 
 </manifest>

BIN
user/src/main/assets/jojo_audio.svga


+ 74 - 0
user/src/main/java/com/swago/user/store/StoreBuyDialog.kt

@@ -0,0 +1,74 @@
+package com.swago.user.store
+
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import com.opensource.svgaplayer.SVGADrawable
+import com.opensource.svgaplayer.SVGAParser
+import com.opensource.svgaplayer.SVGAVideoEntity
+import com.swago.baseswago.dialog.BaseXDFragment
+import com.swago.user.databinding.DialogStoreDetailBinding
+import java.io.File
+import java.net.URL
+
+class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
+
+    private var svgaParser: SVGAParser? = null
+    var svgaString: String ?= null
+    init {
+        setGravity(Gravity.BOTTOM)
+        setDimAmount(0.5f)
+        setCanCancel(true)
+    }
+
+    companion object{
+        fun newInstance(): StoreBuyDialog {
+            val dialog = StoreBuyDialog()
+            val bundle = Bundle()
+//            bundle.putString("svgaString",svgaString)
+            dialog.arguments = bundle
+            return dialog
+        }
+    }
+
+
+    override fun initOther() {
+        svgaParser = SVGAParser(activity)
+//        arguments?.let {
+//            svgaString = it.getString("svgaString")
+//        }
+        svgaString?.let {
+            svgaParser?.let { svgaParser ->
+                svgaParser.decodeFromURL(URL(it), object : SVGAParser.ParseCompletion{
+                    override fun onComplete(videoItem: SVGAVideoEntity) {
+                        val drawable = SVGADrawable(videoItem)
+                        binding.svgContent.setImageDrawable(drawable)
+                        binding.svgContent.startAnimation()
+                    }
+
+                    override fun onError() {
+
+                    }
+                })
+
+            }
+        }
+        svgaParser?.let {
+            it.decodeFromAssets("jojo_audio.svga",object : SVGAParser.ParseCompletion{
+                override fun onComplete(videoItem: SVGAVideoEntity) {
+                    val drawable = SVGADrawable(videoItem)
+                    binding.svgContent.setImageDrawable(drawable)
+                    binding.svgContent.startAnimation()
+                }
+
+                override fun onError() {
+
+                }
+            })
+        }
+    }
+
+    override fun initLiveData() {
+
+    }
+}

+ 16 - 0
user/src/main/java/com/swago/user/store/StoreItemAdapter.kt

@@ -0,0 +1,16 @@
+package com.swago.user.store
+
+import com.chad.library.adapter.base.BaseQuickAdapter
+import com.chad.library.adapter.base.BaseViewHolder
+import com.swago.user.R
+
+class StoreItemAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_store, arrayListOf())  {
+    override fun convert(helper: BaseViewHolder?, item: String?) {
+        helper?.apply {
+            item?.let {
+                setText(R.id.tv_name ,item)
+            }
+
+        }
+    }
+}

+ 51 - 0
user/src/main/java/com/swago/user/store/StoreListActivity.kt

@@ -0,0 +1,51 @@
+package com.swago.user.store
+
+import android.graphics.Color
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.alibaba.android.arouter.facade.annotation.Route
+import com.swago.baseswago.activity.BaseXActivity
+import com.swago.baseswago.constant.ARouteConstant
+import com.swago.user.R
+import com.swago.user.databinding.ActivityStoreListBinding
+import com.swago.user.vm.TaskVm
+
+/**
+ *@date 2022/2/26 13:37
+ *description:
+ */
+@Route(path = ARouteConstant.User.storeList)
+class StoreListActivity : BaseXActivity<ActivityStoreListBinding>() {
+
+    val adapter by lazy {
+        StoreTypeAdapter()
+    }
+
+    override fun loadData() {
+    }
+
+    override fun initOther() {
+        setBackView(binding.toolbar.ivBack)
+        binding.toolbar.ivBack.setImageResource(R.mipmap.back_white)
+        binding.toolbar.tvTitle.setTextColor(Color.parseColor("#FFFFFF"))
+        binding.toolbar.tvTitle.text =
+            "Store"
+    }
+
+    override fun initLiveData() {
+        binding.swagoRv.layoutManager = LinearLayoutManager(this)
+        adapter.setNewData(arrayListOf(StoreListBean("dfg", false), StoreListBean("fsdfds", false)))
+        binding.swagoRv.adapter = adapter
+        adapter.setOnItemChildClickListener { _, view, positon ->
+            when (view?.id) {
+                R.id.clMore -> {
+                    adapter.data[positon].isExpanded = !adapter.data[positon].isExpanded
+                    adapter.notifyItemChanged(positon)
+                }
+            }
+        }
+        adapter.itemClickFun = { typeItem, position ->
+            StoreBuyDialog.newInstance().show(supportFragmentManager ,"StoreBuyDialog")
+        }
+    }
+
+}

+ 6 - 0
user/src/main/java/com/swago/user/store/StoreListBean.kt

@@ -0,0 +1,6 @@
+package com.swago.user.store
+
+data class StoreListBean(
+    val name: String,
+    var isExpanded: Boolean
+)

+ 39 - 0
user/src/main/java/com/swago/user/store/StoreTypeAdapter.kt

@@ -0,0 +1,39 @@
+package com.swago.user.store
+
+import androidx.recyclerview.widget.GridLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import com.chad.library.adapter.base.BaseQuickAdapter
+import com.chad.library.adapter.base.BaseViewHolder
+import com.swago.user.R
+
+class StoreTypeAdapter: BaseQuickAdapter<StoreListBean, BaseViewHolder>(R.layout.item_type_store, arrayListOf())  {
+    var itemClickFun: ((typeItem: StoreListBean , position:Int) -> Unit)? = null
+
+    override fun convert(helper: BaseViewHolder?, item: StoreListBean?) {
+        val itemAdapter = StoreItemAdapter()
+        val array = arrayListOf("ds", "ferg","dfdg","dfdg")
+        helper?.apply {
+            item?.let {
+                setText(R.id.tvType ,item.name)
+                if (item.isExpanded){
+                    itemAdapter.setNewData(array)
+                    setText(R.id.tvMore ,"Show Less")
+                    setImageResource(R.id.ivMore , R.mipmap.ic_show_less)
+                } else {
+                    itemAdapter.setNewData(array.subList(0 , array.size.coerceAtMost(3)))
+                    setText(R.id.tvMore ,"Show More")
+                    setImageResource(R.id.ivMore , R.mipmap.ic_show_more)
+                }
+                val recyclerView = itemView.findViewById<RecyclerView>(R.id.rvType)
+                recyclerView.layoutManager = GridLayoutManager(mContext, 3)
+                recyclerView.adapter = itemAdapter
+                addOnClickListener(R.id.clMore)
+                itemAdapter.setOnItemClickListener { _, _, postion ->
+                    itemClickFun?.invoke(item,postion)
+                }
+            }
+
+
+        }
+    }
+}

+ 5 - 0
user/src/main/res/drawable/shape_0fffffff_4.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="#0FFFFFFF"/>
+    <corners android:radius="4dp"/>
+</shape>

+ 36 - 0
user/src/main/res/layout/activity_store_list.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="#030417"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <ImageView
+        android:background="@mipmap/bg_store"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_width="match_parent"
+        android:layout_height="300dp"/>
+
+    <include
+        android:id="@+id/toolbar"
+        layout="@layout/layout_toolbar"
+        android:layout_width="match_parent"
+        android:layout_height="56dp"
+        android:layout_marginTop="25dp"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <FrameLayout
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_marginTop="81dp"
+        android:layout_width="match_parent"
+        android:layout_height="0dp">
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/swagoRv"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+
+    </FrameLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 69 - 0
user/src/main/res/layout/dialog_store_detail.xml

@@ -0,0 +1,69 @@
+<?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:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+        <com.opensource.svgaplayer.SVGAImageView
+            android:id="@+id/svg_content"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            app:autoPlay="true"
+            app:fillMode="Forward"
+            app:layout_constraintDimensionRatio="h,1:1"
+            app:layout_constraintBottom_toTopOf="@+id/cl_bottom"
+            app:layout_constraintTop_toTopOf="parent"
+            app:loopCount="1" />
+
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:id="@+id/cl_bottom"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="#0E0F26"
+            android:paddingBottom="24dp"
+            app:layout_constraintBottom_toBottomOf="parent">
+
+            <com.swago.baseswago.cusview.MediumTextView
+                android:id="@+id/tv_name"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="18dp"
+                android:maxWidth="120dp"
+                android:textColor="#ffffff"
+                android:textSize="16sp"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent"
+                tools:text="fgg" />
+
+            <com.swago.baseswago.cusview.MediumTextView
+                android:id="@+id/tv_coin"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="10dp"
+                android:drawableStart="@mipmap/ic_coin_store"
+                android:drawablePadding="2dp"
+                android:textColor="#A3FFFFFF"
+                android:textSize="14sp"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/tv_name"
+                tools:text="fgg" />
+
+            <com.swago.baseswago.cusview.MediumTextView
+                android:layout_width="match_parent"
+                android:layout_height="44dp"
+                android:layout_marginStart="17dp"
+                android:layout_marginTop="24dp"
+                android:layout_marginEnd="17dp"
+                android:background="@drawable/shape_9b20fc_20"
+                android:gravity="center"
+                android:text="Buy Now"
+                android:textColor="@color/_ffffff"
+                android:textSize="@dimen/sp_16"
+                app:layout_constraintTop_toBottomOf="@+id/tv_coin" />
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 55 - 0
user/src/main/res/layout/item_store.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp"
+        android:layout_marginTop="8dp"
+        android:background="@drawable/shape_0fffffff_4"
+        app:layout_constraintDimensionRatio="h,52:66"
+        app:layout_constraintTop_toTopOf="parent">
+
+        <ImageView
+            android:id="@+id/iv_svg"
+            android:layout_width="90dp"
+            android:layout_height="90dp"
+            android:src="@mipmap/bg_host_eight"
+            android:padding="@dimen/dp_4"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent"/>
+        <com.swago.baseswago.cusview.MediumTextView
+            android:id="@+id/tv_name"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="2dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/iv_svg"
+            tools:text="fgg"
+            android:textSize="12sp"
+            android:maxWidth="120dp"
+            android:textColor="#ffffff"/>
+        <com.swago.baseswago.cusview.MediumTextView
+            android:id="@+id/tv_coin"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="2dp"
+            android:drawablePadding="2dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_name"
+            tools:text="fgg"
+            android:drawableStart="@mipmap/ic_coin_store"
+            android:textSize="10sp"
+            android:textColor="#A3FFFFFF"/>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 57 - 0
user/src/main/res/layout/item_type_store.xml

@@ -0,0 +1,57 @@
+<?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:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/clMore"
+        android:layout_width="match_parent"
+        android:layout_height="43dp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
+
+        <com.swago.baseswago.cusview.BoldTextView
+            android:id="@+id/tvType"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="16dp"
+            android:textColor="#fff"
+            android:textSize="@dimen/sp_16"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            tools:text="Enter" />
+
+        <com.swago.baseswago.cusview.MediumTextView
+            android:id="@+id/tvMore"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="2dp"
+            android:drawablePadding="2dp"
+            android:textColor="#99ffffff"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toStartOf="@+id/ivMore"
+            app:layout_constraintTop_toTopOf="parent"
+            android:text="Show Less" />
+        <ImageView
+            android:id="@+id/ivMore"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            android:src="@mipmap/ic_show_more"
+            android:layout_marginEnd="16dp"/>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <androidx.recyclerview.widget.RecyclerView
+        android:id="@+id/rvType"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp"
+        app:layout_constraintTop_toBottomOf="@+id/clMore"/>
+</androidx.constraintlayout.widget.ConstraintLayout>

BIN
user/src/main/res/mipmap-xxhdpi/ic_coin_store.png


BIN
user/src/main/res/mipmap-xxhdpi/ic_show_less.png


BIN
user/src/main/res/mipmap-xxhdpi/ic_show_more.png