Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ProjectsInstructions.Text = StringResources.projects_ui_instructions;
            TabBarController.Title    = StringResources.projects_ui_title;

            // Have to set this here for now as the default page for TabBar is this and ViewLoad
            // is where the titles are set within each controler of the tabbar.
            TabBarController.TabBar.Items[0].Title = StringResources.common_menu_projects;
            TabBarController.TabBar.Items[1].Title = StringResources.common_menu_gabbers;
            TabBarController.TabBar.Items[2].Title = StringResources.common_menu_about;

            var es = new CoreGraphics.CGSize(UIScreen.MainScreen.Bounds.Width - 36, 70);

            (ProjectsCollectionView.CollectionViewLayout as UICollectionViewFlowLayout).EstimatedItemSize = es;

            var refreshControl = new UIRefreshControl
            {
                AttributedTitle = new NSAttributedString(StringResources.projects_ui_fetching),
                TintColor       = UIColor.FromRGB(.43f, .80f, .79f)
            };

            refreshControl.AddTarget(async delegate {
                Logger.LOG_EVENT_WITH_ACTION("SWIPE_REFRESH", _projects.Count.ToString(), "PROJECT_COUNT");
                await LoadData();
                refreshControl.EndRefreshing();
            }, UIControlEvent.AllEvents);

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                ProjectsCollectionView.RefreshControl = refreshControl;
            }
            else
            {
                ProjectsCollectionView.AddSubview(refreshControl);
            }

            if (Session.ActiveUser == null)
            {
                var email   = NSUserDefaults.StandardUserDefaults.StringForKey("username");
                var user    = Queries.UserByEmail(email);
                var _tokens = NSUserDefaults.StandardUserDefaults.StringForKey("tokens");
                var tokens  = JsonConvert.DeserializeObject <JWToken>(_tokens);
                Queries.SetActiveUser(new DataUserTokens {
                    User = user, Tokens = tokens
                });
                Firebase.Analytics.Analytics.SetUserID(Session.ActiveUser.Id.ToString());
            }
            _projects = Queries.AllProjects();
            ProjectsCollectionView.Source = new ProjectsCollectionViewSource(_projects);
            if (_projects.Count <= 0)
            {
                LoadDataIfNotLoading(true);
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (ProjectsActivityIndicator != null)
            {
                ProjectsActivityIndicator.Dispose();
                ProjectsActivityIndicator = null;
            }

            if (ProjectsCollectionView != null)
            {
                ProjectsCollectionView.Dispose();
                ProjectsCollectionView = null;
            }

            if (ProjectsInstructions != null)
            {
                ProjectsInstructions.Dispose();
                ProjectsInstructions = null;
            }
        }