コード例 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            collectionView.RegisterNibForCell(ActivityCollectionCell.Nib, ActivityCollectionCell.Key);
            collectionView.RegisterNibForSupplementaryView(FeedSectionHeader.Nib, UICollectionElementKindSectionKey.Header, FeedSectionHeader.Key);

            locationManager = new CLLocationManager();
            locationManager.DesiredAccuracy   = CLLocation.AccuracyHundredMeters;
            locationManager.LocationsUpdated += LocationUpdated;

            source = new ActivityViewSource();

            refreshControl               = new UIRefreshControl();
            refreshControl.TintColor     = AppUtils.AppMainColour;
            refreshControl.ValueChanged += (sender, e) =>
            {
                RefreshFeed();
            };

            collectionView.ShowsHorizontalScrollIndicator = false;
            collectionView.RefreshControl  = refreshControl;
            collectionView.Source          = source;
            collectionView.AllowsSelection = true;
            collectionView.Delegate        = new SectionedClickableDelegate((section, index) => {
                var suppressAsync = AppUtils.OpenActivity(source.Rows[section]?.Activities[index], Storyboard, NavigationController);
            });
        }
コード例 #2
0
        private void RemoteActivityTapped(LearningActivity activity)
        {
            UIAlertController alert = UIAlertController.Create("What do you want to do?", "This activity's share code: " + activity.InviteCode, UIAlertControllerStyle.ActionSheet);

            alert.AddAction(UIAlertAction.Create("Open", UIAlertActionStyle.Default, (a) =>
            {
                var suppress = AppUtils.OpenActivity(activity, Storyboard, NavigationController);
            }));
            alert.AddAction(UIAlertAction.Create("Copy Share Code", UIAlertActionStyle.Default, (a) =>
            {
                UIPasteboard clipboard = UIPasteboard.General;
                clipboard.String       = activity.InviteCode;
                Toast.ShowToast("Copied Code");
            }));
            alert.AddAction(UIAlertAction.Create("Edit", UIAlertActionStyle.Default, (a) =>
            {
                activityToEdit = activity;
                PerformSegue("CreateActivitySegue", this);
            }));
            alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));

            // On iPad, it's a pop up. Stick it in the center of the screen
            UIPopoverPresentationController popCont = alert.PopoverPresentationController;

            if (popCont != null)
            {
                popCont.SourceView = View;
                popCont.SourceRect = new CGRect(View.Bounds.GetMidX(), View.Bounds.GetMidY(), 0, 0);
                popCont.PermittedArrowDirections = 0;
            }

            PresentViewController(alert, true, null);
        }
コード例 #3
0
        private async Task GetAndOpenActivity(string code)
        {
            LoadingOverlay loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds);

            View.Add(loadPop);

            Common.ServerResponse <LearningActivity> result =
                await Common.ServerUtils.Get <LearningActivity>("/api/LearningActivities/GetWithCode?code=" + code);

            loadPop.Hide();

            if (result == null)
            {
                var suppress = AppUtils.SignOut(this);
            }

            if (result.Success)
            {
                var suppress = AppUtils.OpenActivity(result.Data, Storyboard, NavigationController);
            }
            else
            {
                if (result.Message.StartsWith("404"))
                {
                    AppUtils.ShowSimpleDialog(this, "Not found", "No activity was found with that share code.", "Got it");
                }
                else
                {
                    AppUtils.ShowSimpleDialog(this, "Connection Error", "Something went wrong! Please try again later.", "Got it");
                }
            }
        }