public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            _navController = TabBarController != null ? TabBarController.NavigationController : NavigationController;

            collectionView.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            collectionView.RegisterClassForCell(typeof(NewFeedCollectionViewCell), nameof(NewFeedCollectionViewCell));
            collectionView.RegisterClassForCell(typeof(PhotoCollectionViewCell), nameof(PhotoCollectionViewCell));

            collectionView.SetCollectionViewLayout(new UICollectionViewFlowLayout()
            {
                MinimumLineSpacing      = 0,
                MinimumInteritemSpacing = 0,
            }, false);

            _gridDelegate                   = new CollectionViewFlowDelegate(collectionView, _presenter);
            _gridDelegate.IsGrid            = false;
            _gridDelegate.ScrolledToBottom += ScrolledToBottom;
            _gridDelegate.CellClicked      += CellAction;

            _collectionViewSource             = new ProfileCollectionViewSource(_presenter, _gridDelegate);
            _collectionViewSource.CellAction += CellAction;
            _collectionViewSource.TagAction  += TagAction;
            collectionView.Source             = _collectionViewSource;
            collectionView.Delegate           = _gridDelegate;

            _sliderGridDelegate = new SliderCollectionViewFlowDelegate(sliderCollection, _presenter);
            _sliderGridDelegate.ScrolledToBottom += ScrolledToBottom;

            var _sliderCollectionViewSource = new SliderCollectionViewSource(_presenter, _sliderGridDelegate);

            _sliderCollectionViewSource.CellAction         += CellAction;
            _sliderCollectionViewSource.TagAction          += TagAction;
            sliderCollection.DecelerationRate               = UIScrollView.DecelerationRateFast;
            sliderCollection.ShowsHorizontalScrollIndicator = false;

            sliderCollection.SetCollectionViewLayout(new SliderFlowLayout()
            {
                MinimumLineSpacing      = 10,
                MinimumInteritemSpacing = 0,
                ScrollDirection         = UICollectionViewScrollDirection.Horizontal,
                SectionInset            = new UIEdgeInsets(0, 15, 0, 15),
            }, false);

            sliderCollection.Source = _sliderCollectionViewSource;
            sliderCollection.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            sliderCollection.RegisterClassForCell(typeof(SliderFeedCollectionViewCell), nameof(SliderFeedCollectionViewCell));
            sliderCollection.Delegate = _sliderGridDelegate;

            _profileHeader = new ProfileHeaderViewController(ProfileHeaderLoaded);
            collectionView.ContentInset = new UIEdgeInsets(300, 0, 0, 0);
            collectionView.AddSubview(_profileHeader.View);

            _refreshControl = new UIRefreshControl();
            _refreshControl.ValueChanged += RefreshControl_ValueChanged;
            collectionView.Add(_refreshControl);

            if (TabBarController != null)
            {
                ((MainTabBarController)TabBarController).SameTabTapped += SameTabTapped;
            }
            SetBackButton();

            GetUserInfo();
            GetUserPosts();
        }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _navController = TabBarController.NavigationController;

            _gridDelegate = new CollectionViewFlowDelegate(feedCollection, _presenter);
            _gridDelegate.ScrolledToBottom   += ScrolledToBottom;
            _gridDelegate.IsGrid              = false;
            _collectionViewSource             = new ProfileCollectionViewSource(_presenter, _gridDelegate);
            _collectionViewSource.IsGrid      = false;
            _collectionViewSource.CellAction += CellAction;
            _collectionViewSource.TagAction  += TagAction;

            _refreshControl = new UIRefreshControl();
            _refreshControl.ValueChanged += OnRefresh;

            feedCollection.Source = _collectionViewSource;
            feedCollection.RegisterClassForCell(typeof(NewFeedCollectionViewCell), nameof(NewFeedCollectionViewCell));
            feedCollection.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            feedCollection.RegisterClassForCell(typeof(FeedCollectionViewCell), nameof(FeedCollectionViewCell));
            feedCollection.RegisterNibForCell(UINib.FromName(nameof(FeedCollectionViewCell), NSBundle.MainBundle), nameof(FeedCollectionViewCell));
            feedCollection.Add(_refreshControl);
            feedCollection.Delegate             = _gridDelegate;
            feedCollection.DelaysContentTouches = false;

            _sliderGridDelegate = new SliderCollectionViewFlowDelegate(sliderCollection, _presenter);
            _sliderGridDelegate.ScrolledToBottom += ScrolledToBottom;

            var _sliderCollectionViewSource = new SliderCollectionViewSource(_presenter, _sliderGridDelegate);

            sliderCollection.DecelerationRate = UIScrollView.DecelerationRateFast;
            sliderCollection.ShowsHorizontalScrollIndicator = false;

            sliderCollection.SetCollectionViewLayout(new SliderFlowLayout()
            {
                MinimumLineSpacing      = 10,
                MinimumInteritemSpacing = 0,
                ScrollDirection         = UICollectionViewScrollDirection.Horizontal,
                SectionInset            = new UIEdgeInsets(0, 15, 0, 15),
            }, false);

            sliderCollection.Source = _sliderCollectionViewSource;
            sliderCollection.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            sliderCollection.RegisterClassForCell(typeof(SliderFeedCollectionViewCell), nameof(SliderFeedCollectionViewCell));

            sliderCollection.DelaysContentTouches = false;

            _sliderCollectionViewSource.CellAction += CellAction;
            _sliderCollectionViewSource.TagAction  += TagAction;
            sliderCollection.Delegate = _sliderGridDelegate;

            SliderAction += (isOpening) =>
            {
                if (!sliderCollection.Hidden)
                {
                    sliderCollection.ScrollEnabled = !isOpening;
                }
            };

            if (TabBarController != null)
            {
                TabBarController.NavigationController.NavigationBar.TintColor    = Helpers.Constants.R15G24B30;
                TabBarController.NavigationController.NavigationBar.BarTintColor = UIColor.White;
                TabBarController.NavigationController.SetNavigationBarHidden(true, false);
            }

            ((MainTabBarController)TabBarController).SameTabTapped += SameTabTapped;

            SetNavBar();
            GetPosts();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _navController = TabBarController != null ? TabBarController.NavigationController : NavigationController;
            _navController.NavigationBar.Translucent = false;

            _gridDelegate                   = new CollectionViewFlowDelegate(collectionView, _presenter);
            _gridDelegate.IsGrid            = true;
            _gridDelegate.ScrolledToBottom += ScrolledToBottom;
            _gridDelegate.CellClicked      += CellAction;

            _collectionViewSource        = new FeedCollectionViewSource(_presenter, _gridDelegate);
            _collectionViewSource.IsGrid = true;
            collectionView.Source        = _collectionViewSource;
            collectionView.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            collectionView.RegisterClassForCell(typeof(PhotoCollectionViewCell), nameof(PhotoCollectionViewCell));
            collectionView.RegisterClassForCell(typeof(NewFeedCollectionViewCell), nameof(NewFeedCollectionViewCell));

            _sliderGridDelegate = new SliderCollectionViewFlowDelegate(sliderCollection, _presenter);
            _sliderGridDelegate.ScrolledToBottom += ScrolledToBottom;

            var _sliderCollectionViewSource = new SliderCollectionViewSource(_presenter, _sliderGridDelegate);

            sliderCollection.DecelerationRate = UIScrollView.DecelerationRateFast;
            sliderCollection.ShowsHorizontalScrollIndicator = false;

            sliderCollection.SetCollectionViewLayout(new SliderFlowLayout()
            {
                MinimumLineSpacing      = 10,
                MinimumInteritemSpacing = 0,
                ScrollDirection         = UICollectionViewScrollDirection.Horizontal,
                SectionInset            = new UIEdgeInsets(0, 15, 0, 15),
            }, false);

            sliderCollection.Source = _sliderCollectionViewSource;
            sliderCollection.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            sliderCollection.RegisterClassForCell(typeof(SliderFeedCollectionViewCell), nameof(SliderFeedCollectionViewCell));

            _refreshControl = new UIRefreshControl();
            _refreshControl.ValueChanged += async(sender, e) =>
            {
                await GetPosts(false, true);
            };
            collectionView.Add(_refreshControl);

            _collectionViewSource.CellAction += CellAction;
            _collectionViewSource.TagAction  += TagAction;

            _sliderCollectionViewSource.CellAction += CellAction;
            _sliderCollectionViewSource.TagAction  += TagAction;

            collectionView.SetCollectionViewLayout(new UICollectionViewFlowLayout()
            {
                MinimumLineSpacing      = 1,
                MinimumInteritemSpacing = 1,
            }, false);

            collectionView.Delegate   = _gridDelegate;
            sliderCollection.Delegate = _sliderGridDelegate;

            SliderAction += (isOpening) =>
            {
                if (!sliderCollection.Hidden)
                {
                    sliderCollection.ScrollEnabled = !isOpening;
                }
            };

            if (!AppSettings.User.HasPostingPermission && CurrentPostCategory == null)
            {
                loginButton.Hidden             = false;
                loginButton.Layer.CornerRadius = 25;
                loginButton.Layer.BorderWidth  = 0;
            }

            loginButton.TouchDown += LoginTapped;

            hotButton.TouchDown += (object sender, EventArgs e) =>
            {
                SwitchSearchType(PostType.Hot);
            };

            topButton.TouchDown += (object sender, EventArgs e) =>
            {
                SwitchSearchType(PostType.Top);
            };

            newButton.TouchDown += (object sender, EventArgs e) =>
            {
                SwitchSearchType(PostType.New);
            };

            switcher.TouchDown += SwitchLayout;

            var searchTap = new UITapGestureRecognizer(SearchTapped);

            searchButton.AddGestureRecognizer(searchTap);

            GetPosts();
        }
Beispiel #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            _presenter.UserName = Username;
            _navController      = TabBarController != null ? TabBarController.NavigationController : NavigationController;

            collectionView.RegisterClassForCell(typeof(ProfileHeaderViewCell), nameof(ProfileHeaderViewCell));
            collectionView.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            collectionView.RegisterClassForCell(typeof(NewFeedCollectionViewCell), nameof(NewFeedCollectionViewCell));
            collectionView.RegisterClassForCell(typeof(PhotoCollectionViewCell), nameof(PhotoCollectionViewCell));

            collectionView.SetCollectionViewLayout(new UICollectionViewFlowLayout()
            {
                MinimumLineSpacing      = 0,
                MinimumInteritemSpacing = 0,
            }, false);

            _gridDelegate                   = new ProfileCollectionViewFlowDelegate(collectionView, _presenter);
            _gridDelegate.IsGrid            = false;
            _gridDelegate.IsProfile         = true;
            _gridDelegate.ScrolledToBottom += ScrolledToBottom;
            _gridDelegate.CellClicked      += CellAction;

            _collectionViewSource                = new ProfileCollectionViewSource(_presenter, _gridDelegate);
            _collectionViewSource.CellAction    += CellAction;
            _collectionViewSource.TagAction     += TagAction;
            _collectionViewSource.ProfileAction += ProfileAction;
            collectionView.Source                = _collectionViewSource;
            collectionView.Delegate              = _gridDelegate;

            _sliderGridDelegate = new SliderCollectionViewFlowDelegate(sliderCollection, _presenter);
            _sliderGridDelegate.ScrolledToBottom += ScrolledToBottom;

            var _sliderCollectionViewSource = new SliderCollectionViewSource(_presenter, _sliderGridDelegate);

            _sliderCollectionViewSource.CellAction         += CellAction;
            _sliderCollectionViewSource.TagAction          += TagAction;
            sliderCollection.DecelerationRate               = UIScrollView.DecelerationRateFast;
            sliderCollection.ShowsHorizontalScrollIndicator = false;

            sliderCollection.SetCollectionViewLayout(new SliderFlowLayout()
            {
                MinimumLineSpacing      = 10,
                MinimumInteritemSpacing = 0,
                ScrollDirection         = UICollectionViewScrollDirection.Horizontal,
                SectionInset            = new UIEdgeInsets(0, 15, 0, 15),
            }, false);

            sliderCollection.Source = _sliderCollectionViewSource;
            sliderCollection.RegisterClassForCell(typeof(LoaderCollectionCell), nameof(LoaderCollectionCell));
            sliderCollection.RegisterClassForCell(typeof(SliderFeedCollectionViewCell), nameof(SliderFeedCollectionViewCell));
            sliderCollection.Delegate = _sliderGridDelegate;

            SliderAction += (isOpening) =>
            {
                if (!sliderCollection.Hidden)
                {
                    sliderCollection.ScrollEnabled = !isOpening;
                }
            };

            _refreshControl = new UIRefreshControl();
            _refreshControl.ValueChanged += RefreshControl_ValueChanged;
            collectionView.Add(_refreshControl);

            SetBackButton();

            if (Username == AppSettings.User.Login && AppSettings.User.HasPostingPermission)
            {
                SetVotePowerView();
            }
            GetUserInfo();
            GetPosts();
        }