コード例 #1
0
		public async void ConformToRecord(Activity theActivity)
		{
			linkedActivity = theActivity;
			var curType = LettuceServer.Instance.ActivityType (theActivity.type);

			if (!String.IsNullOrEmpty(curType.icon))
				this.ActivityTypeImage.SetImage (new NSUrl(curType.icon));
			this.ActivityTypeLabel.Text = curType.typename;
			this.ActivityDescription.Text = linkedActivity.description;
			this.ActivityDurationLabel.Text = String.Format("{0} minutes", linkedActivity.duration);
			// fetch the venue
			var curVenue = LettuceServer.Instance.Venue(theActivity.venueid);

			if (curVenue == null) {
				curVenue = await LettuceServer.Instance.LoadVenue(theActivity.venueid);
				InvokeOnMainThread (() => {
					this.VenueNameLabel.Text = curVenue.title;
					if (!String.IsNullOrEmpty(curVenue.image))
						this.VenueImage.SetImage (new NSUrl(curVenue.image));
				});
			} else {
				this.VenueNameLabel.Text = curVenue.title;
				if (!String.IsNullOrEmpty(curVenue.image))
					this.VenueImage.SetImage (new NSUrl(curVenue.image));
			}

		}
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            newActivity = new Lettuce.Core.Activity ();

            // Perform any additional setup after loading the view, typically from a nib.
            ChooseTypeBtn.TouchUpInside += (object sender, EventArgs e) => {
                // to do - show new touch'
                UIAlertController actionSheet = UIAlertController.Create ("Activity Type", "What do you feel like doing?", UIAlertControllerStyle.ActionSheet);
                foreach (int curTypeId in LettuceServer.Instance.ActivityTypes.Keys) {
                    ActivityType curType = LettuceServer.Instance.ActivityType(curTypeId);
                    actionSheet.AddAction (UIAlertAction.Create (curType.typename, UIAlertActionStyle.Default, (action) => SetActivityType (curType.id)));
                }
                actionSheet.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Cancel, null));

                this.PresentViewController (actionSheet, true, null);
            };

            CancelBtn.TouchUpInside += (object sender, EventArgs e) => {
                DismissViewController (true, null);
            };

            ChooseBtn.TouchUpInside += (object sender, EventArgs e) => {
                DismissViewController (true, null);
                if (ActivityCreated != null)
                    ActivityCreated(newActivity);
            };

            SearchBtn.TouchUpInside += (object sender, EventArgs e) => { DoYelpSearch(); };

            SearchField.ShouldReturn = (theField) => {
                theField.ResignFirstResponder();
                DoYelpSearch();
                return false;
            };

            keyWatcher = NSNotificationCenter.DefaultCenter.AddObserver (UITextView.TextDidChangeNotification, (notification) => {
                newActivity.description = ActivityDescription.Text;
                ActivityChanged();
            });

            ResultTable.RegisterNibForCellReuse (UINib.FromName (YelpResultCell.Key, NSBundle.MainBundle), YelpResultCell.Key);
            dataSource = new YelpResultTableSource (this);
            ResultTable.Source = dataSource;

            ActivityChanged ();
        }