Ejemplo n.º 1
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                var cell = tableView.DequeueReusableCell(cellIdentifier);

                if (cell == null)
                {
                    cell           = new UITableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier);
                    cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                    cell.ImageView.Layer.CornerRadius  = 21.0F;
                    cell.ImageView.Layer.MasksToBounds = false;
                    cell.ImageView.Layer.BorderColor   = new CGColor(1, 1, 1);
                    cell.ImageView.Layer.BorderWidth   = 2;
                    cell.ImageView.ClipsToBounds       = true;
                    //cell.ImageView.Image = UIImage.FromBundle("missing.png");
                }

                var contact = viewModel.ContactsGrouped[indexPath.Section][indexPath.Row];

                cell.TextLabel.Text       = contact.GivenName + " " + contact.Surname;
                cell.DetailTextLabel.Text = contact.BusinessPhones.Count > 0 ? contact.BusinessPhones[0] : contact.MobilePhone1;
                cell.ImageView.SetImage(
                    url: new NSUrl(Gravatar.GetURL(contact.EmailAddresses[0].Address, 44)),
                    placeholder: UIImage.FromBundle("missing.png")
                    );
                return(cell);
            }
        public async Task GetContactsAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Contacts.Clear();
                var contacts = await ContactsAPI.GetContacts();

                foreach (var contact in contacts)
                {
#if NETFX_CORE
                    contact.CompanyName = Gravatar.GetURL(contact.EmailAddresses[0].Address, 88);
#endif
                    Contacts.Add(contact);
                }

                SortContacts();
            }
            catch (Exception ex)
            {
                //add pop up here for error
            }
            finally
            {
                IsBusy = false;
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            if (ViewModel == null)
            {
                ViewModel = new DetailsViewModel();
                NavigationItem.RightBarButtonItem = save;
            }
            else
            {
                this.Title     = ViewModel.FirstName;
                TextEmail.Text = ViewModel.Email;
                TextFirst.Text = ViewModel.FirstName;
                TextLast.Text  = ViewModel.LastName;
                TextPhone.Text = ViewModel.Phone;

                ImagePhoto.SetImage(
                    url: new NSUrl(Gravatar.GetURL(ViewModel.Contact.EmailAddresses[0].Address, 172)),
                    placeholder: UIImage.FromBundle("missing.png")
                    );


                NavigationItem.RightBarButtonItem = null;
            }
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ContactWrapper wrapper = null;
            var            view    = convertView;

            if (convertView == null)
            {
                view          = context.LayoutInflater.Inflate(Resource.Layout.item_contact, null);
                wrapper       = new ContactWrapper();
                wrapper.Name  = view.FindViewById <TextView>(Resource.Id.name);
                wrapper.Phone = view.FindViewById <TextView>(Resource.Id.phone);
                wrapper.Photo = view.FindViewById <ImageView>(Resource.Id.photo);
                view.Tag      = wrapper;
            }
            else
            {
                wrapper = convertView.Tag as ContactWrapper;
            }

            var contact = viewModel.Contacts[position];

            wrapper.Name.Text  = contact.GivenName + " " + contact.Surname;
            wrapper.Phone.Text = contact.BusinessPhones.Count > 0 ? contact.BusinessPhones[0] : contact.MobilePhone1;
            Koush.UrlImageViewHelper.SetUrlDrawable(wrapper.Photo, Gravatar.GetURL(contact.EmailAddresses[0].Address, 88), Resource.Drawable.missing);

            return(view);
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            email     = FindViewById <EditText>(Resource.Id.email);
            phone     = FindViewById <EditText>(Resource.Id.phone);
            firstName = FindViewById <EditText>(Resource.Id.first_name);
            lastName  = FindViewById <EditText>(Resource.Id.last_name);
            photo     = FindViewById <ImageView>(Resource.Id.photo2);

            email.TextChanged += (sender, args) =>
            {
                Koush.UrlImageViewHelper.SetUrlDrawable(photo, Gravatar.GetURL(email.Text, 88), Resource.Drawable.missing);
            };

            if (ViewModel == null)
            {
                ViewModel = new DetailsViewModel();
            }
            else
            {
                SupportActionBar.Title = ViewModel.FirstName + " " + ViewModel.LastName;
                email.Text             = ViewModel.Email;
                firstName.Text         = ViewModel.FirstName;
                lastName.Text          = ViewModel.LastName;
                phone.Text             = ViewModel.Phone;
            }

            var bottomToolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar_bottom);

            bottomToolbar.InflateMenu(Resource.Menu.detail_bottom);
            bottomToolbar.MenuItemClick += (sender, args) =>
            {
                switch (args.Item.ItemId)
                {
                case Resource.Id.calendar:
                    App.NewEventViewModel.Email     = ViewModel.Email;
                    App.NewEventViewModel.FirstName = ViewModel.FirstName;
                    App.NewEventViewModel.LastName  = ViewModel.LastName;
                    StartActivity(typeof(NewEventActivity));
                    //ViewModel.AddEvent(new[] { ViewModel.Email }, new[] { ViewModel.FirstName });
                    break;

                case Resource.Id.phone:
                    var uri    = Android.Net.Uri.Parse("tel:" + ViewModel.Phone);
                    var intent = new Intent(Intent.ActionView, uri);
                    StartActivity(intent);
                    break;

                case Resource.Id.email:
                    App.SendEmailViewModel.Email     = ViewModel.Email;
                    App.SendEmailViewModel.FirstName = ViewModel.FirstName;
                    App.SendEmailViewModel.LastName  = ViewModel.LastName;

                    StartActivity(typeof(SendEmailActivity));
                    break;
                }
            };
        }
Ejemplo n.º 6
0
 protected override void OnResume()
 {
     base.OnResume();
     if (!string.IsNullOrWhiteSpace(ViewModel.Email))
     {
         Koush.UrlImageViewHelper.SetUrlDrawable(photo, Gravatar.GetURL(ViewModel.Email, 88), Resource.Drawable.missing);
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationController.NavigationBar.BarStyle = UIBarStyle.Black;

            save = new UIBarButtonItem(UIBarButtonSystemItem.Save,
                                       async(sender, args) =>
            {
                ViewModel.FirstName = TextFirst.Text.Trim();
                ViewModel.LastName  = TextLast.Text.Trim();
                ViewModel.Email     = TextEmail.Text.Trim();
                ViewModel.Phone     = TextPhone.Text.Trim();
                BigTed.BTProgressHUD.Show("Saving contact...");
                await ViewModel.SaveContact();
                BigTed.BTProgressHUD.Dismiss();
                NavigationController.PopToRootViewController(true);
            });


            TextEmail.ShouldReturn += ShouldReturn;
            TextFirst.ShouldReturn += ShouldReturn;
            TextPhone.ShouldReturn += ShouldReturn;
            TextLast.ShouldReturn  += ShouldReturn;

            TextEmail.ValueChanged += (sender, args) =>
            {
                ImagePhoto.SetImage(
                    url: new NSUrl(Gravatar.GetURL(TextEmail.Text, 172)),
                    placeholder: UIImage.FromBundle("missing.png")
                    );
            };

            var color = new CGColor(17.0F / 255.0F, 113.0F / 255.0F, 197.0F / 255F);

            TextEmail.Layer.BorderColor = color;
            TextFirst.Layer.BorderColor = color;
            TextPhone.Layer.BorderColor = color;
            TextLast.Layer.BorderColor  = color;


            ButtonCall.Clicked += (sender, args) => PlaceCall();

            NSNotificationCenter.DefaultCenter.AddObserver
                (UIKeyboard.DidShowNotification, KeyBoardUpNotification);

            // Keyboard Down
            NSNotificationCenter.DefaultCenter.AddObserver
                (UIKeyboard.WillHideNotification, KeyBoardDownNotification);

            double min = Math.Min((float)ImagePhoto.Frame.Width, (float)ImagePhoto.Frame.Height);

            ImagePhoto.Layer.CornerRadius  = (float)(min / 2.0);
            ImagePhoto.Layer.MasksToBounds = false;
            ImagePhoto.Layer.BorderColor   = new CGColor(1, 1, 1);
            ImagePhoto.Layer.BorderWidth   = 3;
            ImagePhoto.ClipsToBounds       = true;
        }
Ejemplo n.º 8
0
 public User(IDictionary <string, string> userClaims)
 {
     UserClaims = userClaims;
     userClaims.TryGetValue(JwtClaimNames.Subject, out _email);
     userClaims.TryGetValue(JwtClaimNames.GivenName, out _firstName);
     userClaims.TryGetValue(JwtClaimNames.FamilyName, out _lastName);
     if (!string.IsNullOrWhiteSpace(_email))
     {
         _gravatarUrl = Gravatar.GetURL(_email);
     }
 }
Ejemplo n.º 9
0
 public Master(User user)
 {
     Intialize(user);
     _viewModel.User        = user;
     _viewModel.ProfilePath = ImageSource.FromUri(new Uri(Gravatar.GetURL(user.Email)));
 }
Ejemplo n.º 10
0
        public LoginPage()
        {
            InitializeComponent();
            BindingContext = vm = new LoginViewModel(Navigation);

            if (!Settings.Current.FirstRun)
            {
                Title = "My Account";
                var cancel = new ToolbarItem
                {
                    Text    = "Cancel",
                    Command = new Command(async() =>
                    {
                        if (vm.IsBusy)
                        {
                            return;
                        }
                        await Navigation.PopModalAsync();
                    })
                };
                ToolbarItems.Add(cancel);

                if (Device.OS != TargetPlatform.iOS)
                {
                    cancel.Icon = "toolbar_close.png";
                }
            }

            CircleImageAvatar.Source = placeholder = ImageSource.FromFile("profile_generic_big.png");
            EntryEmail.TextChanged  += (sender, e) =>
            {
                var isValid = (Regex.IsMatch(e.NewTextValue, emailRegex, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)));
                if (isValid)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        CircleImageAvatar.BorderThickness = 3;
                        CircleImageAvatar.Source          = ImageSource.FromUri(new Uri(Gravatar.GetURL(EntryEmail.Text)));
                    });
                }
                else if (CircleImageAvatar.Source != placeholder)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        CircleImageAvatar.BorderThickness = 0;
                        CircleImageAvatar.Source          = placeholder;
                    });
                }
            };
        }