-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7c5007
commit a6e5186
Showing
6 changed files
with
243 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/src/main/java/one/mixin/android/ui/wallet/Web3ReceiveSelectionFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package one.mixin.android.ui.wallet | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.viewModels | ||
import androidx.lifecycle.lifecycleScope | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.launch | ||
import one.mixin.android.Constants | ||
import one.mixin.android.Constants.Web3ChainIds | ||
import one.mixin.android.R | ||
import one.mixin.android.databinding.FragmentWeb3ReceiveSelectionBinding | ||
import one.mixin.android.extension.navTo | ||
import one.mixin.android.session.Session | ||
import one.mixin.android.ui.common.BaseFragment | ||
import one.mixin.android.ui.home.web3.Web3ViewModel | ||
import one.mixin.android.ui.wallet.InputFragment | ||
import one.mixin.android.web3.send.TokenListBottomSheetDialogFragment | ||
|
||
@AndroidEntryPoint | ||
class Web3ReceiveSelectionFragment : BaseFragment() { | ||
companion object { | ||
const val TAG = "Web3ReceiveSelectionFragment" | ||
private const val ARGS_ADDRESS = "args_address" | ||
private const val ARGS_CHAIN_ID = "args_chain_id" | ||
|
||
fun newInstance(address: String, chainId: String) = Web3ReceiveSelectionFragment().apply { | ||
arguments = Bundle().apply { | ||
putString(ARGS_ADDRESS, address) | ||
putString(ARGS_CHAIN_ID, chainId) | ||
} | ||
} | ||
} | ||
|
||
private var _binding: FragmentWeb3ReceiveSelectionBinding? = null | ||
private val binding get() = requireNotNull(_binding) | ||
private val web3ViewModel by viewModels<Web3ViewModel>() | ||
|
||
private val address by lazy { requireArguments().getString(ARGS_ADDRESS, "") } | ||
private val chainId by lazy { requireArguments().getString(ARGS_CHAIN_ID, "") } | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
_binding = FragmentWeb3ReceiveSelectionBinding.inflate(inflater, container, false).apply { this.root.setOnClickListener { } } | ||
binding.root.setOnClickListener { } | ||
binding.title.setOnClickListener { } | ||
binding.title.leftIb.setOnClickListener { activity?.onBackPressedDispatcher?.onBackPressed() } | ||
binding.walletTv.text = getString(R.string.contact_mixin_id, Session.getAccount()?.identityNumber) | ||
binding.walletRl.setOnClickListener { | ||
lifecycleScope.launch { | ||
if (address.isEmpty()) { | ||
return@launch | ||
} | ||
val chainIds = if (chainId.isNotEmpty()) { | ||
listOf(chainId) | ||
} else { | ||
Web3ChainIds | ||
} | ||
val list = web3ViewModel.web3TokenItems(chainIds) | ||
TokenListBottomSheetDialogFragment.newInstance(ArrayList(list)).apply { | ||
setOnClickListener { token -> | ||
navTo(InputFragment.newInstance(token, address, null, true), InputFragment.TAG) | ||
dismissNow() | ||
} | ||
}.show(parentFragmentManager, TokenListBottomSheetDialogFragment.TAG) | ||
} | ||
} | ||
binding.addressRl.setOnClickListener { | ||
WalletActivity.showWithAddress(this.requireActivity(), address, WalletActivity.Destination.Address) | ||
} | ||
return binding.root | ||
} | ||
|
||
@SuppressLint("SetTextI18n") | ||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
app/src/main/res/layout/fragment_web3_receive_selection.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="?attr/bg_white" | ||
android:orientation="vertical"> | ||
|
||
<one.mixin.android.widget.TitleView | ||
android:id="@+id/title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:need_divider="false" | ||
app:titleText="@string/Receive" /> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/wallet_rl" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginBottom="10dp" | ||
android:background="@drawable/ripple_round_window"> | ||
|
||
<ImageView | ||
android:id="@+id/avatar" | ||
android:src="@drawable/ic_web3_deposit_wallet" | ||
android:layout_centerVertical="true" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="20dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent"/> | ||
|
||
<ImageView | ||
android:src="@drawable/ic_web3_arrow" | ||
android:layout_centerVertical="true" | ||
android:layout_alignParentEnd="true" | ||
android:layout_marginEnd="10dp" | ||
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"/> | ||
|
||
<TextView | ||
android:id="@+id/wallet_title_tv" | ||
android:text="@string/My_Wallet" | ||
android:textColor="?attr/text_primary" | ||
android:textSize="16sp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginTop="12dp" | ||
android:layout_marginBottom="2dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toTopOf="@id/wallet_tv" | ||
app:layout_constraintStart_toEndOf="@id/avatar" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/wallet_tv" | ||
android:text="@string/My_Wallet_desc" | ||
android:textColor="?attr/text_subtitle" | ||
android:textSize="13sp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="2dp" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginBottom="12dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/wallet_title_tv" | ||
app:layout_constraintStart_toEndOf="@id/avatar" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/address_rl" | ||
android:layout_width="match_parent" | ||
android:layout_height="64dp" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginBottom="10dp" | ||
android:background="@drawable/ripple_round_window"> | ||
|
||
<ImageView | ||
android:id="@+id/avatar_address" | ||
android:src="@drawable/ic_web3_deposit_address" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="20dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent"/> | ||
|
||
<ImageView | ||
android:src="@drawable/ic_web3_arrow" | ||
android:layout_marginEnd="10dp" | ||
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"/> | ||
|
||
<TextView | ||
android:id="@+id/wallet_address_tv" | ||
android:text="@string/Exchanges_or_Wallets" | ||
android:textColor="?attr/text_primary" | ||
android:textSize="16sp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
android:layout_marginBottom="2dp" | ||
android:layout_marginStart="12dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toTopOf="@id/address_tv" | ||
app:layout_constraintStart_toEndOf="@id/avatar_address"/> | ||
|
||
<TextView | ||
android:id="@+id/address_tv" | ||
android:text="@string/Exchanges_or_Wallets_desc" | ||
android:textColor="?attr/text_subtitle" | ||
android:textSize="13sp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="2dp" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginBottom="12dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/wallet_address_tv" | ||
app:layout_constraintStart_toEndOf="@id/avatar_address"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</LinearLayout> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters