public AcquaintanceDetailViewModel(Acquaintance acquaintance = null)
        {
            _CapabilityService = DependencyService.Get<ICapabilityService>();

            _Geocoder = new Geocoder();

            if (acquaintance == null)
            {
                _IsNewAcquaintance = true;
                Acquaintance = new Acquaintance();
            }
            else
            {
                _IsNewAcquaintance = false;
                Acquaintance = acquaintance;
            }

			Title = _IsNewAcquaintance ? "New Acquaintance" : _Acquaintance.DisplayLastNameFirst;

            _AddressString = Acquaintance.AddressString;

            SubscribeToSaveAcquaintanceMessages();

            SubscribeToAcquaintanceLocationUpdatedMessages();
        }
        /// <summary>
        /// Update the cell's child views' values and presentation.
        /// </summary>
        /// <param name="acquaintance">Acquaintance.</param>
        public void Update(Acquaintance acquaintance)
        {
            // use FFImageLoading library to:
            ImageService
                .LoadFileFromApplicationBundle(String.Format(acquaintance.PhotoUrl)) 	// get the image from the app bundle
                .LoadingPlaceholder("placeholderProfileImage.png") 						// specify a placeholder image
                .Transform(new CircleTransformation()) 									// transform the image to a circle
                .Into(ProfilePhotoImageView); 											// load the image into the UIImageView

            // use FFImageLoading library to asynchronously:
            //	ImageService
            //		.LoadUrl(acquaintance.SmallPhotoUrl) 				// get the image from a URL
            //		.LoadingPlaceholder("placeholderProfileImage.png") 	// specify a placeholder image
            //		.Transform(new CircleTransformation()) 				// transform the image to a circle
            //		.IntoAsync(ProfilePhotoImageView); 					// load the image into the UIImageView

                NameLabel.Text = acquaintance.DisplayLastNameFirst;
                CompanyLabel.Text = acquaintance.Company;
                JobTitleLabel.Text = acquaintance.JobTitle;

                // set disclousure indicator accessory for the cell
                Accessory = UITableViewCellAccessory.DisclosureIndicator;

                // add the colored border to the image
                double min = Math.Min(ProfilePhotoImageView.Frame.Height, ProfilePhotoImageView.Frame.Height);
                ProfilePhotoImageView.Layer.CornerRadius = (float)(min / 2.0);
                ProfilePhotoImageView.Layer.MasksToBounds = false;
                ProfilePhotoImageView.Layer.BorderColor = UIColor.FromRGB(84, 119, 153).CGColor;
                ProfilePhotoImageView.Layer.BorderWidth = 3;
                ProfilePhotoImageView.BackgroundColor = UIColor.Clear;
                ProfilePhotoImageView.ClipsToBounds = true;
        }
		protected override async void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			var acquaintanceDetailLayout = LayoutInflater.Inflate(Resource.Layout.AcquaintanceDetail, null);

			SetContentView(acquaintanceDetailLayout);

			SetSupportActionBar(FindViewById<Toolbar>(Resource.Id.toolbar));

			// ensure that the system bar color gets drawn
			Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

			// enable the back button in the action bar
			SupportActionBar.SetDisplayHomeAsUpEnabled(true);
			SupportActionBar.SetHomeButtonEnabled(true);

			// extract the acquaintance id fomr the intent
			var acquaintanceId = Intent.GetStringExtra(GetString(Resource.String.acquaintanceDetailIntentKey));

			// fetch the acquaintance based on the id
			_Acquaintance = await _AcquaintanceDataSource.GetItem(acquaintanceId);

			// set the activity title and action bar title
			Title = SupportActionBar.Title = _Acquaintance.DisplayName;

			SetupViews(acquaintanceDetailLayout, savedInstanceState);

			SetupAnimations();
		}
Beispiel #4
0
 static int MatchScore(Acquaintance c, string query)
 {
     return(new[]
     {
         $"{c.FirstName} {c.LastName}",
         c.Email,
         c.Company,
     }.Sum(label => MatchScore(label, query)));
 }
		public AcquaintanceDetailViewModel(Acquaintance acquaintance)
		{
			_CapabilityService = DependencyService.Get<ICapabilityService>();

			_Geocoder = new Geocoder();

			Acquaintance = acquaintance;

			SubscribeToSaveAcquaintanceMessages();
		}
		public AcquaintanceEditViewModel(Acquaintance acquaintance = null)
		{
			if (acquaintance == null)
			{
				Acquaintance = new Acquaintance()
				{ 
					Id = Guid.NewGuid().ToString(),
					PhotoUrl = "placeholderProfileImage.png"
				};
			}
			else
			{
				Mapper.Initialize(cfg => cfg.CreateMap<Acquaintance, Acquaintance>());

				// Use AutoMapper to make a copy of the Acquaintance.
				// On the edit screen, we want to only deal with this copy until we're ready to save.
				// If we didn't make this copy, then the item would be updated instantaneously without saving, 
				// by virtue of the ObservableObject type that the Acquaint model inherits from.
				Acquaintance = Mapper.Map<Acquaintance>(acquaintance);
			}
		}