Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。
Kotlin高仿微信-项目实践58篇,点击查看详情
效果图:
实现代码:
<?xml version="1.0" encoding="utf-8"?> <layout> <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" android:background="@drawable/wc_base_bg"> <include layout="@layout/wc_base_top_title"/> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/payment_item" android:layout_width="match_parent" android:layout_height="160dp" android:layout_marginTop="20dp" android:layout_marginHorizontal="12dp" app:layout_constraintStart_toStartOf="parent" android:background="#48d17a" app:layout_constraintTop_toBottomOf="@+id/base_top_root_layout"> <LinearLayout android:id="@+id/payment_collection_layout" android:layout_width="150dp" android:layout_height="120dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@+id/payment_wallet_layout" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/payment_collection" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/wc_payment_collection"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="收付款" android:textColor="@color/white" android:textSize="20sp"/> </LinearLayout> <LinearLayout android:id="@+id/payment_wallet_layout" android:layout_width="150dp" android:layout_height="120dp" app:layout_constraintStart_toEndOf="@+id/payment_collection_layout" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/payment_wallet_icon" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/wc_payment_wallet"/> <TextView android:id="@+id/payment_wallet" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="钱包" android:textColor="@color/white" android:textSize="20sp"/> <androidx.appcompat.widget.AppCompatTextView android:id="@+id/payment_balance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="¥123456789.00" android:textColor="#E8E8E8" android:textSize="16sp"/> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout> </layout>
/** * author : wangning * email : maoning20080809@163.com * Date : 2022/4/7 16:22 * description : 服务页面 */ class PaymentFragment : BaseDataBindingFragment<WcMeFragmentPaymentBinding>() { override fun getLayoutRes() = R.layout.wc_me_fragment_payment private val userViewModel : UserViewModel by viewModels() private var resultBalance : Float = 0f override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) super.builder().setTitleContent(R.string.wc_base_top_payment) //先判断是否已经注册 if(!EventBus.getDefault().isRegistered(this)){ EventBus.getDefault().register(this) } //收付款 payment_collection_layout.setOnClickListener { Navigation.findNavController(it).navigate(R.id.action_receive_payment) } //钱包 payment_wallet_layout.setOnClickListener { Navigation.findNavController(it).navigate(R.id.action_small_change) } TagUtils.d(" PaymentFragment主页 resultBalance = ${resultBalance}"); var account = DataStoreUtils.getAccount() userViewModel.getUserLocal(account) userViewModel.userBeanLocal.observe(viewLifecycleOwner){ it?.let { TagUtils.d("2 PaymentFragment主页 resultBalance = ${it.balance}"); payment_balance.text = CommonUtils.Base.getFormatBalanceUnit(it.balance) } } } @Subscribe(threadMode = ThreadMode.MAIN) fun onMessageCallback(rechargeBalanceBean: RechargeBalanceBean) { TagUtils.d(" EventBus 返回的值:${rechargeBalanceBean.balance}"); resultBalance = rechargeBalanceBean.balance payment_balance.text = CommonUtils.Base.getFormatBalanceUnit(rechargeBalanceBean.balance) } override fun onDestroy() { super.onDestroy() EventBus.getDefault().unregister(this) } }