コード例 #1
0
 public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
 {
     if (_presenter.Balances.Count == 0)
     {
         var cell = (CardShimmerCollectionView)collectionView.DequeueReusableCell(nameof(CardShimmerCollectionView), indexPath);
         return(cell);
     }
     else
     {
         var cell         = (CardCollectionViewCell)collectionView.DequeueReusableCell(nameof(CardCollectionViewCell), indexPath);
         var currencyRate = _presenter.GetCurrencyRate(_presenter.Balances[indexPath.Row].CurrencyType);
         cell.UpdateCard(_presenter.Balances[indexPath.Row], currencyRate, indexPath.Row);
         return(cell);
     }
 }
コード例 #2
0
        public override Object InstantiateItem(ViewGroup container, int position)
        {
            position %= CachedPagesCount;

            if (position == _presenter.Balances.Count)
            {
                if (_shimmerLoading == null)
                {
                    _shimmerLoading = LayoutInflater.From(_pager.Context).Inflate(Resource.Layout.lyt_wallet_card_shimmer, container, false);

                    var shimmerContainer = _shimmerLoading.FindViewById <ShimmerLayout>(Resource.Id.shimmer_container);
                    shimmerContainer.SetShimmerColor(Color.Argb(80, 255, 255, 255));
                    shimmerContainer.SetMaskWidth(0.8f);
                    shimmerContainer.StartShimmerAnimation();

                    var shimmerBalanceTitle = _shimmerLoading.FindViewById <ShimmerLayout>(Resource.Id.shimmer_balance_title);
                    shimmerBalanceTitle.SetShimmerColor(Color.White);
                    shimmerBalanceTitle.SetMaskWidth(0.8f);
                    shimmerBalanceTitle.StartShimmerAnimation();

                    var shimmerBalance = _shimmerLoading.FindViewById <ShimmerLayout>(Resource.Id.shimmer_balance);
                    shimmerBalance.SetShimmerColor(Color.White);
                    shimmerBalance.SetMaskWidth(0.8f);
                    shimmerBalance.StartShimmerAnimation();

                    var shimmerTokenBalanceTitle1 = _shimmerLoading.FindViewById <ShimmerLayout>(Resource.Id.shimmer_token_balance_title1);
                    shimmerTokenBalanceTitle1.SetShimmerColor(Color.White);
                    shimmerTokenBalanceTitle1.SetMaskWidth(0.8f);
                    shimmerTokenBalanceTitle1.StartShimmerAnimation();

                    var shimmerTokenBalance1 = _shimmerLoading.FindViewById <ShimmerLayout>(Resource.Id.shimmer_token_balance1);
                    shimmerTokenBalance1.SetShimmerColor(Color.White);
                    shimmerTokenBalance1.SetMaskWidth(0.8f);
                    shimmerTokenBalance1.StartShimmerAnimation();

                    var shimmerTokenBalanceTitle2 = _shimmerLoading.FindViewById <ShimmerLayout>(Resource.Id.shimmer_token_balance_title2);
                    shimmerTokenBalanceTitle2.SetShimmerColor(Color.White);
                    shimmerTokenBalanceTitle2.SetMaskWidth(0.8f);
                    shimmerTokenBalanceTitle2.StartShimmerAnimation();

                    var shimmerTokenBalance2 = _shimmerLoading.FindViewById <ShimmerLayout>(Resource.Id.shimmer_token_balance2);
                    shimmerTokenBalance2.SetShimmerColor(Color.White);
                    shimmerTokenBalance2.SetMaskWidth(0.8f);
                    shimmerTokenBalance2.StartShimmerAnimation();

                    container.AddView(_shimmerLoading);
                }

                return(_shimmerLoading);
            }

            if (_tokenCards[position] == null)
            {
                var itemView = LayoutInflater.From(_pager.Context).Inflate(Resource.Layout.lyt_wallet_card, container, false);
                _tokenCards[position] = new TokenCardHolder(itemView);
                container.AddView(itemView);
            }
            if (_presenter.Balances?.Count > 0)
            {
                _tokenCards[position].UpdateData(_presenter.Balances[position], _presenter.GetCurrencyRate(_presenter.Balances[position].CurrencyType), position);
            }

            return(_tokenCards[position].ItemView);
        }