Esempio n. 1
0
        public static void Load()
        {
            long time   = Environment.TickCount;
            var  reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM scripted_cells");
            int  nbr    = 0;

            while (reader.Read())
            {
                var cell = new CellAction()
                {
                    MapID      = reader.GetInt32("MapID"),
                    CellID     = reader.GetInt32("CellID"),
                    ActionID   = reader.GetInt32("ActionID"),
                    EventID    = reader.GetInt32("EventID"),
                    Arguments  = reader.GetString("ActionsArgs"),
                    Conditions = reader.GetString("Conditions"),
                };
                Map mm = MapTable.Cache.FirstOrDefault(x => x.Key == cell.MapID).Value;
                if (mm != null)
                {
                    mm.CellActionsCache.Add(cell);
                    nbr++;
                }
            }
            reader.Close();
            Logger.Info("Loaded @'" + nbr + "'@ CellActions in @" + (Environment.TickCount - time) + "@ ms");
        }
Esempio n. 2
0
        private void UpdateCell(DependencyObject originalSource, CellAction cellAction)
        {
            var gameFinished = IsGameFinished;

            if (gameFinished)
            {
                return;
            }

            var currentCell = GetCurrentCell(originalSource);

            if (currentCell != null)
            {
                switch (cellAction)
                {
                case CellAction.Open:
                    OpenCell(currentCell);
                    break;

                case CellAction.Mark:
                    MarkCell(currentCell);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(cellAction));
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Function chosing the next action to be performed
        /// </summary>
        /// <returns>Returns one Action</returns>
        public override CellAction ChooseNextAction()
        {
            CellAction cellAction;

            SurroundingView surroundings = this.Cell.Sense();

            // Get offset to the closest enemy
            IList<ICell> allCells = surroundings.GetAllCells();

            // Remove friendly cells
            allCells = GetEnemyCells(this.Cell.GetTeam(), allCells);

            // Get closest cell
            ICell closestCell = GetClosestCell(allCells);
            
            if (closestCell == null)
                cellAction = new CellAction(GetRandomAction());
            else
            {
                // Get vector to this cell
                IOffsetVector offsetVector = new OffsetVector(this.Cell.Position, closestCell.Position);

                AvailableActions action;

                if (Math.Abs(offsetVector.X) <= 1 && Math.Abs(offsetVector.Y) <= 1)
                    action = AvailableActions.ATTACK;
                else
                    action = this.Cell.GetRelativeMovment(offsetVector);

                cellAction = new CellAction(action, offsetVector);
            }
        
            return cellAction;
        }
Esempio n. 4
0
        /// <summary>
        /// Function chosing the next action to be performed
        /// </summary>
        /// <returns>Returns one Action</returns>
        public override CellAction ChooseNextAction()
        {
            CellAction cellAction;
            
            SurroundingView surroundings = this.Cell.Sense();

            // Get the offset to the closest ressource pool
            IList<IOffsetVector> allOffsetsToRessources = surroundings.GetOffsetToAllRessourcesLocations();

            IOffsetVector closestRessourcePool = this.GetClosestMapTile(allOffsetsToRessources);

            if (closestRessourcePool == null)
                cellAction = new CellAction(GetRandomAction());
            else
            {
                AvailableActions action;

                if (Math.Abs(closestRessourcePool.X) <= 1 && Math.Abs(closestRessourcePool.Y) <= 1)
                    action = AvailableActions.EAT;
                else
                    action = this.Cell.GetRelativeMovment(closestRessourcePool);

                cellAction = new CellAction(action, closestRessourcePool);
            }

            return cellAction;
        }
 private void LikeTap()
 {
     if (!BasePostPresenter.IsEnableVote)
     {
         return;
     }
     CellAction?.Invoke(ActionType.Like, _currentPost);
 }
Esempio n. 6
0
    public void DoStep()
    {
        // We create a list of actions that will accumulate as the cellular automata resolves the step.
        // We do this because we do not want the state of the volume to change while we're checking all of the cells.
        // if that happens, then when we run CellRule to determine what to do to each cell, changes made to other cells
        // will affect the behavior of different cells in the same step.
        List <Action> actionList = new List <Action>();

        //for every cell of interest
        foreach (var cell in _interestingCells)
        {
            // We store the position
            Vector3 pos = cell.Key;

            //evaluate the point
            CellAction response = EvaluatePoint(pos);

            //then use the response to add an action to the list.
            switch (response.action)
            {
            case CellActionID.Create:
                actionList.Add(() => { AddCell(pos); });    //Notice that this list takes an anonymous function as an element.
                Debug.Log($"Cell CREATED at {pos}.");
                break;

            case CellActionID.Destroy:
                actionList.Add(() => { RemoveCell(pos); });
                Debug.Log($"Cell REMOVED at {pos}.");
                break;

            case CellActionID.IgnorePos:
                bool dump;
                actionList.Add(() =>
                {
                    _interestingCells.TryRemove(pos, out dump);
                    GameObject gameObj;
                    _cells.TryRemove(pos, out gameObj);
                    gameObj.Destroy();
                });
                Debug.Log($"Cell IGNORED at {pos}.");
                break;

            case CellActionID.Idle:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }

        foreach (var action in actionList)
        {
            // Now we execute every action that the list accumulated.
            action();
        }
    }
Esempio n. 7
0
 /// <summary>
 /// Stops action
 /// </summary>
 public void Stop()
 {
     if (ActionType == CellAction.None)
     {
         return;
     }
     actionType = CellAction.None;
     passedArguments.Disconnect();
     passedArguments = null;
 }
Esempio n. 8
0
        private void CreatePositionActions()
        {
            MapAction       = new CellAction();
            MapAction.Save += (object obj) =>
            {
                Position = (Position)obj;
            };

            MapAction.Delete += () =>
            {
                Position = new Position();
            };
        }
Esempio n. 9
0
 /// <summary>
 /// Starts action by setting parameters
 /// </summary>
 /// <param name="aActionType">
 /// Action type <see cref="CellAction"/>
 /// </param>
 /// <param name="aArguments">
 /// Arguments <see cref="CellExposeEventArgs"/>
 /// </param>
 public void Start(CellAction aActionType, CellExposeEventArgs aArguments)
 {
     if ((aActionType == CellAction.None) || (aArguments == null))
     {
         return;
     }
     if (ActionType != CellAction.None)
     {
         throw new Exception("Action is already in progress");
     }
     actionType      = aActionType;
     passedArguments = aArguments;
 }
Esempio n. 10
0
 private void LikeTap(object sender, EventArgs e)
 {
     if (_currentPost.VoteChanging)
     {
         return;
     }
     CellAction?.Invoke(ActionType.Like, _currentPost);
     if (!BasePresenter.User.IsAuthenticated)
     {
         return;
     }
     Animate();
 }
Esempio n. 11
0
        /// <summary>
        /// This function executes the action passed on by the brain
        /// (For gameplay perspective the brain should not be able to control the cell himself ;)
        /// </summary>
        /// <param name="action">The action to apply</param>
        public void Do(CellAction action)
        {
            if (this.GetLife() <= 0)
            {
                this.Die();
                return;
            }

            this.cellPreviousAction = action.GetAction();

            switch (action.GetAction())
            {
                case AvailableActions.MOVELEFT:
                    Move(-1,0);
                    break;
                case AvailableActions.MOVERIGHT:
                    Move(1, 0);
                    break;
                case AvailableActions.MOVEUP:
                    Move(0, -1);
                    break;
                case AvailableActions.MOVEDOWN:
                    Move(0, 1);
                    break;
                case AvailableActions.DROP:
                    DropEarth();
                    break;
                case AvailableActions.LIFT:
                    LiftEarth();
                    break;
                case AvailableActions.SPLIT:
                    Split();
                    break;
                case AvailableActions.DIE:
                    Die();
                    break;
                case AvailableActions.EAT:
                    Eat(action.GetOffsetToTarget());
                    break;
                case AvailableActions.ATTACK:
                    Attack(action.GetOffsetToTarget());
                    break;
                case AvailableActions.NONE:
                    break;
                default:
                    throw new NotImplementedException();
            }
            return;
        }
Esempio n. 12
0
        private void CreateImageActions()
        {
            ImageAction       = new CellAction();
            ImageAction.Save += (object obj) =>
            {
                MediaFile   = (MediaFile)obj;
                ImageSource = ImageSource.FromStream(() =>
                {
                    var stream = MediaFile.GetStreamWithImageRotatedForExternalStorage();
                    return(stream);
                });
                OnPropertyChanged(nameof(ImageSource));
            };

            ImageAction.Delete += () =>
            {
                MediaFile?.Dispose();
                ImageSource = null;
            };
        }
Esempio n. 13
0
        /// <summary>
        /// This function executes the action passed on by the brain
        /// (For gameplay perspective the brain should not be able to control the cell himself ;)
        /// </summary>
        /// <param name="action">The action to apply</param>
        public void Do(CellAction action)
        {
            _cellPreviousAction = action;

            switch (action)
            {
                case CellAction.MOVELEFT:
                    MoveLeft();
                    break;
                case CellAction.MOVERIGHT:
                    MoveRight();
                    break;
                case CellAction.MOVEUP:
                    MoveUp();
                    break;
                case CellAction.MOVEDOWN:
                    MoveDown();
                    break;
                //case CellAction.ATTACK: //Not yet implemented
                //    Attack();
                //    break;
                case CellAction.DROP:
                    DropEarth();
                    break;
                case CellAction.LIFT:
                    LiftEarth();
                    break;
                case CellAction.SPLIT:
                    Split();
                    break;
                case CellAction.DIE:
                    Die();
                    break;
                case CellAction.NONE:
                    break;
                default:
                    throw new NotImplementedException();
            }
            return;
        }
Esempio n. 14
0
        protected SliderFeedCollectionViewCell(IntPtr handle) : base(handle)
        {
            _contentView = ContentView;

            _closeButton       = new UIButton();
            _closeButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _closeButton.SetImage(UIImage.FromBundle("ic_close_black"), UIControlState.Normal);
            //_closeButton.BackgroundColor = UIColor.Yellow;
            _contentView.AddSubview(_closeButton);

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_closeButton.Frame.Left - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage       = new UIImageView();
            _avatarImage.Frame = new CGRect(leftMargin, 20, 30, 30);
            _contentView.AddSubview(_avatarImage);

            authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _closeButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _closeButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _contentScroll       = new UIScrollView();
            _contentScroll.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, _contentView.Frame.Width,
                                              _contentView.Frame.Height - (_avatarImage.Frame.Bottom + 20));
            _contentScroll.ShowsVerticalScrollIndicator = false;
            _contentScroll.Bounces = false;
            //_contentScroll.BackgroundColor = UIColor.LightGray;
            _contentView.AddSubview(_contentScroll);

            _photoScroll = new UIScrollView();
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            _photoScroll.Scrolled     += (sender, e) =>
            {
                var pageWidth = _photoScroll.Frame.Size.Width;
                _pageControl.CurrentPage = (int)Math.Floor((_photoScroll.ContentOffset.X - pageWidth / 2) / pageWidth) + 1;
            };
            _photoScroll.Layer.CornerRadius = 10;
            _contentScroll.AddSubview(_photoScroll);

            _pageControl        = new UIPageControl();
            _pageControl.Hidden = true;
            _pageControl.UserInteractionEnabled = false;
            _contentScroll.AddSubview(_pageControl);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likes);
            //_likes.BackgroundColor = UIColor.Purple;

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            //_like.BackgroundColor = UIColor.Orange;
            _contentScroll.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_topSeparator);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentScroll.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, _contentView.Frame.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            _sliderView          = new SliderView(_contentScroll.Frame.Width);
            _sliderView.LikeTap += () =>
            {
                LikeTap();
            };
            BaseViewController.SliderAction += (isOpening) =>
            {
                if (_sliderView.Superview != null && !isOpening)
                {
                    _sliderView.Close();
                }
            };

            var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) =>
            {
                if (AppSettings.User.IsAuthenticated && !_currentPost.Vote)
                {
                    if (obj.State == UIGestureRecognizerState.Began)
                    {
                        if (!BasePostPresenter.IsEnableVote)
                        {
                            return;
                        }
                        BaseViewController.IsSliderOpen = true;
                        _sliderView.Show(_contentScroll);
                    }
                }
            });

            _like.AddGestureRecognizer(likelongtap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown  += FlagButton_TouchDown;
            _closeButton.TouchDown += Close_TouchDown;
        }
Esempio n. 15
0
        public override void UpdateCell(Post post)
        {
            _currentPost      = post;
            avatarImage.Image = null;
            _scheduledWorkAvatar?.Cancel();

            bodyImage.Image = null;
            _scheduledWorkBody?.Cancel();

            var media = _currentPost.Media[0];

            _scheduledWorkBody = ImageService.Instance.LoadUrl(media.Url, Helpers.Constants.ImageCacheDuration)
                                 //.Retry(5)
                                 .FadeAnimation(false)
                                 .WithCache(FFImageLoading.Cache.CacheType.All)
                                 .DownSample((int)UIScreen.MainScreen.Bounds.Width)
                                 .WithPriority(LoadingPriority.Highest)
                                 .Into(bodyImage);

            if (!string.IsNullOrEmpty(_currentPost.Avatar))
            {
                _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30))
                                       .WithCache(FFImageLoading.Cache.CacheType.All)
                                       .FadeAnimation(false)
                                       .DownSample(200)
                                       .LoadingPlaceholder("ic_noavatar.png")
                                       .ErrorPlaceholder("ic_noavatar.png")
                                       .WithPriority(LoadingPriority.Normal)
                                       .Into(avatarImage);
            }
            else
            {
                avatarImage.Image = UIImage.FromBundle("ic_noavatar");
            }

            topLikers.Hidden = true;
            if (_currentPost.TopLikersAvatars.Count() >= 1 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0]))
            {
                _scheduledWorkfirst?.Cancel();
                firstLiker.Image    = null;
                topLikers.Hidden    = false;
                firstLiker.Hidden   = false;
                _scheduledWorkfirst = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[0], TimeSpan.FromDays(30))
                                      .WithCache(FFImageLoading.Cache.CacheType.All)
                                      .LoadingPlaceholder("ic_noavatar.png")
                                      .ErrorPlaceholder("ic_noavatar.png")
                                      .DownSample(width: 100)
                                      .WithPriority(LoadingPriority.Lowest)
                                      .Into(firstLiker);
            }
            else
            {
                firstLiker.Hidden = true;
            }

            if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1]))
            {
                _scheduledWorksecond?.Cancel();
                secondLiker.Image    = null;
                secondLiker.Hidden   = false;
                _scheduledWorksecond = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[1], TimeSpan.FromDays(30))
                                       .WithCache(FFImageLoading.Cache.CacheType.All)
                                       .LoadingPlaceholder("ic_noavatar.png")
                                       .ErrorPlaceholder("ic_noavatar.png")
                                       .WithPriority(LoadingPriority.Lowest)
                                       .DownSample(width: 100)
                                       .Into(secondLiker);
            }
            else
            {
                secondLiker.Hidden = true;
            }

            if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2]))
            {
                _scheduledWorkthird?.Cancel();
                thirdLiker.Image    = null;
                thirdLiker.Hidden   = false;
                _scheduledWorkthird = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[2], TimeSpan.FromDays(30))
                                      .WithCache(FFImageLoading.Cache.CacheType.All)
                                      .LoadingPlaceholder("ic_noavatar.png")
                                      .ErrorPlaceholder("ic_noavatar.png")
                                      .WithPriority(LoadingPriority.Lowest)
                                      .DownSample(width: 100)
                                      .Into(thirdLiker);
            }
            else
            {
                thirdLiker.Hidden = true;
            }

            cellText.Text  = _currentPost.Author;
            rewards.Hidden = !BasePresenter.User.IsNeedRewards;
            //rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward);

            netVotes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Like, _currentPost.NetVotes);

            if (_currentPost.VoteChanging)
            {
                Animate();
            }
            else
            {
                likeButton.Transform = CGAffineTransform.MakeScale(1f, 1f);
                likeButton.Selected  = _currentPost.Vote;
            }

            flagButton.Selected  = _currentPost.Flag;
            viewCommentText.Text = _currentPost.Children == 0
                ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment)
                : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children);

            likeButton.Enabled = true;
            flagButton.Enabled = true;
            postTimeStamp.Text = _currentPost.Created.ToPostTime();

            imageHeight.Constant      = PhotoHeight.Get(media.Size);
            contentViewWidth.Constant = UIScreen.MainScreen.Bounds.Width;

            if (!_isButtonBinded)
            {
                cellText.Font        = Helpers.Constants.Semibold14;
                postTimeStamp.Font   = Helpers.Constants.Regular12;
                netVotes.Font        = Helpers.Constants.Semibold14;
                rewards.Font         = Helpers.Constants.Semibold14;
                viewCommentText.Font = Helpers.Constants.Regular14;

                avatarImage.Layer.CornerRadius = avatarImage.Frame.Size.Width / 2;
                firstLiker.Layer.CornerRadius  = firstLiker.Frame.Size.Width / 2;
                secondLiker.Layer.CornerRadius = secondLiker.Frame.Size.Width / 2;
                thirdLiker.Layer.CornerRadius  = thirdLiker.Frame.Size.Width / 2;

                attributedLabel = new TTTAttributedLabel();
                attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
                var prop = new NSDictionary();
                attributedLabel.LinkAttributes       = prop;
                attributedLabel.ActiveLinkAttributes = prop;

                commentView.AddSubview(attributedLabel);
                attributedLabel.Font  = Helpers.Constants.Regular14;
                attributedLabel.Lines = 0;
                attributedLabel.UserInteractionEnabled = true;
                attributedLabel.Enabled = true;
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 15f);
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 15f);
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 15f);
                viewCommentText.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, attributedLabel, 5f);
                attributedLabel.Delegate = new TTTAttributedLabelFeedDelegate(TagAction);

                UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Preview, _currentPost);
                });
                bodyImage.AddGestureRecognizer(tap);

                UITapGestureRecognizer imageTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                UITapGestureRecognizer textTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                UITapGestureRecognizer moneyTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                avatarImage.AddGestureRecognizer(imageTap);
                cellText.AddGestureRecognizer(textTap);
                rewards.AddGestureRecognizer(moneyTap);

                UITapGestureRecognizer commentTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Comments, _currentPost);
                });
                viewCommentText.AddGestureRecognizer(commentTap);

                UITapGestureRecognizer netVotesTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Voters, _currentPost);
                });
                netVotes.AddGestureRecognizer(netVotesTap);

                flagButton.TouchDown += FlagButton_TouchDown;
                likeButton.TouchDown += LikeTap;

                _isButtonBinded = true;

                Debug.WriteLine("Cell created");
            }

            var noLinkAttribute = new UIStringAttributes
            {
                Font            = Helpers.Constants.Regular14,
                ForegroundColor = Helpers.Constants.R15G24B30,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString(_currentPost.Title, noLinkAttribute));
            if (!string.IsNullOrEmpty(_currentPost.Description))
            {
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(_currentPost.Description, noLinkAttribute));
            }

            foreach (var tag in _currentPost.Tags)
            {
                if (tag == "steepshot")
                {
                    continue;
                }
                var linkAttribute = new UIStringAttributes
                {
                    Link            = new NSUrl(tag),
                    Font            = Helpers.Constants.Regular14,
                    ForegroundColor = Helpers.Constants.R231G72B0,
                };
                at.Append(new NSAttributedString($" #{tag}", linkAttribute));
            }
            attributedLabel.SetText(at);
        }
Esempio n. 16
0
 private void FlagButton_TouchDown(object sender, EventArgs e)
 {
     CellAction?.Invoke(ActionType.More, _currentPost);
 }
Esempio n. 17
0
 private void LikeTap(object sender, EventArgs e)
 {
     CellAction?.Invoke(ActionType.Like, _currentPost);
     Animate();
 }
        public FeedCellBuilder(UIView contentView)
        {
            _contentView = contentView;

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, 60);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage = new UIImageView(new CGRect(leftMargin, 15, 30, 30));
            _contentView.AddSubview(_avatarImage);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _photoScroll = new UIScrollView();
            _photoScroll.BackgroundColor = Constants.R244G244B246;
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            _photoScroll.Scrolled     += (sender, e) =>
            {
                var pageWidth = _photoScroll.Frame.Size.Width;
                _pageControl.CurrentPage = (int)Math.Floor((_photoScroll.ContentOffset.X - pageWidth / 2) / pageWidth) + 1;
            };
            contentView.AddSubview(_photoScroll);

            _pageControl        = new UIPageControl();
            _pageControl.Hidden = true;
            _pageControl.UserInteractionEnabled = false;
            contentView.AddSubview(_pageControl);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            _contentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_topSeparator);

            var _noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("...", _noLinkAttribute));

            _attributedLabel = new TTTAttributedLabel();
            _attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            _attributedLabel.LinkAttributes       = prop;
            _attributedLabel.ActiveLinkAttributes = prop;
            _attributedLabel.Font  = Constants.Regular14;
            _attributedLabel.Lines = 3;
            _attributedLabel.UserInteractionEnabled = true;
            _attributedLabel.Enabled = true;
            _attributedLabel.AttributedTruncationToken = at;
            //_attributedLabel.BackgroundColor = UIColor.Blue;
            _contentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            _sliderView          = new SliderView(UIScreen.MainScreen.Bounds.Width);
            _sliderView.LikeTap += () =>
            {
                LikeTap();
            };
            BaseViewController.SliderAction += (isSliderOpening) =>
            {
                if (_sliderView.Superview != null && !isSliderOpening)
                {
                    _sliderView.Close();
                }
            };

            var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) =>
            {
                if (AppSettings.User.HasPostingPermission && !_currentPost.Vote)
                {
                    if (obj.State == UIGestureRecognizerState.Began)
                    {
                        if (!BasePostPresenter.IsEnableVote || BaseViewController.IsSliderOpen)
                        {
                            return;
                        }
                        BaseViewController.IsSliderOpen = true;
                        _sliderView.Show(_contentView);
                    }
                }
            });

            _like.AddGestureRecognizer(likelongtap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
Esempio n. 19
0
        protected NewFeedCollectionViewCell(IntPtr handle) : base(handle)
        {
            //ContentView.BackgroundColor = UIColor.Cyan;

            _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30));
            _avatarImage.Layer.CornerRadius = _avatarImage.Frame.Size.Width / 2;
            _avatarImage.ClipsToBounds      = true;
            _avatarImage.ContentMode        = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_avatarImage);

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(ContentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            ContentView.AddSubview(_moreButton);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            ContentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            ContentView.AddSubview(_timestamp);

            _bodyImage = new UIImageView();
            _bodyImage.ClipsToBounds          = true;
            _bodyImage.UserInteractionEnabled = true;
            _bodyImage.ContentMode            = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_bodyImage);

            var likersCornerRadius = likersImageSide / 2;

            _firstLikerImage = new UIImageView();
            _firstLikerImage.Layer.CornerRadius = likersCornerRadius;
            _firstLikerImage.ClipsToBounds      = true;
            _firstLikerImage.ContentMode        = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_firstLikerImage);

            _secondLikerImage = new UIImageView();
            _secondLikerImage.Layer.CornerRadius = likersCornerRadius;
            _secondLikerImage.ClipsToBounds      = true;
            _secondLikerImage.ContentMode        = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_secondLikerImage);

            _thirdLikerImage = new UIImageView();
            _thirdLikerImage.Layer.CornerRadius = likersCornerRadius;
            _thirdLikerImage.ClipsToBounds      = true;
            _thirdLikerImage.ContentMode        = UIViewContentMode.ScaleAspectFill;
            ContentView.AddSubview(_thirdLikerImage);

            _likes      = new UILabel();
            _likes.Font = Constants.Semibold14;
            //_likes.BackgroundColor = UIColor.Magenta;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            ContentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            ContentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            ContentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            ContentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            ContentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            ContentView.AddSubview(_topSeparator);

            _attributedLabel = new TTTAttributedLabel();
            _attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            _attributedLabel.LinkAttributes       = prop;
            _attributedLabel.ActiveLinkAttributes = prop;
            _attributedLabel.Font  = Constants.Regular14;
            _attributedLabel.Lines = 0;
            _attributedLabel.UserInteractionEnabled = true;
            _attributedLabel.Enabled = true;
            //_attributedLabel.BackgroundColor = UIColor.Blue;
            ContentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            ContentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            ContentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            ContentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            ContentView.AddSubview(_likersTapView);

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            var tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _bodyImage.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
        public FeedCellBuilder(UIView contentView)
        {
            _contentView = contentView;

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30));
            _contentView.AddSubview(_avatarImage);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _photoScroll = new UIScrollView();
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            contentView.AddSubview(_photoScroll);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            _contentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_topSeparator);

            var _noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("...", _noLinkAttribute));

            _attributedLabel = new TTTAttributedLabel();
            _attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            _attributedLabel.LinkAttributes       = prop;
            _attributedLabel.ActiveLinkAttributes = prop;
            _attributedLabel.Font  = Constants.Regular14;
            _attributedLabel.Lines = 3;
            _attributedLabel.UserInteractionEnabled = true;
            _attributedLabel.Enabled = true;
            _attributedLabel.AttributedTruncationToken = at;
            //_attributedLabel.BackgroundColor = UIColor.Blue;
            _contentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
        protected SliderFeedCollectionViewCell(IntPtr handle) : base(handle)
        {
            _contentView = ContentView;

            _closeButton       = new UIButton();
            _closeButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _closeButton.SetImage(UIImage.FromBundle("ic_close_black"), UIControlState.Normal);
            //_closeButton.BackgroundColor = UIColor.Yellow;
            _contentView.AddSubview(_closeButton);

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_closeButton.Frame.Left - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage       = new UIImageView();
            _avatarImage.Frame = new CGRect(leftMargin, 20, 30, 30);
            _contentView.AddSubview(_avatarImage);

            authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _closeButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _closeButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _contentScroll       = new UIScrollView();
            _contentScroll.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, _contentView.Frame.Width,
                                              _contentView.Frame.Height - (_avatarImage.Frame.Bottom + 20));
            _contentScroll.ShowsVerticalScrollIndicator = false;
            _contentScroll.Bounces = false;
            //_contentScroll.BackgroundColor = UIColor.LightGray;
            _contentView.AddSubview(_contentScroll);

            _photoScroll = new UIScrollView();
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            _contentScroll.AddSubview(_photoScroll);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likes);
            //_likes.BackgroundColor = UIColor.Purple;

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            //_like.BackgroundColor = UIColor.Orange;
            _contentScroll.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_topSeparator);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentScroll.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, _contentView.Frame.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown  += FlagButton_TouchDown;
            _closeButton.TouchDown += Close_TouchDown;
        }
 private void Close_TouchDown(object sender, EventArgs e)
 {
     CellAction?.Invoke(ActionType.Close, _currentPost);
 }
Esempio n. 23
0
 public HexStep(HexagonCell cell, CellAction action)
 {
     Cell   = cell;
     Action = action;
 }