async Task <string> GetVkData()
        {
            try
            {
                AppleVkService.thisNavigationController = this.NavigationController;
                if (/*String.IsNullOrEmpty(VkRetrievedData) && */ String.IsNullOrEmpty(urlString))
                {
                    //VKSdk.Instance.RegisterDelegate(this.ViewController);
                    //VKSdk.Instance.UiDelegate = this.ViewController;

                    activityIndicator.Hidden = false;
                    CardsPCL.Models.LoginResult loginResult = null;
                    try
                    {
                        loginResult = await appleVkService.Login();
                    }
                    catch
                    {
                        if (!methods.IsConnected())
                        {
                            InvokeOnMainThread(() =>
                            {
                                NoConnectionViewController.view_controller_name = GetType().Name;
                                this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                                return;
                            });
                        }
                        return(null);
                    }
                    activityIndicator.Hidden = true;
                    if (loginResult.LoginState != LoginState.Canceled)
                    {
                        if (!String.IsNullOrEmpty(loginResult.UserId))
                        {
                            //VkRetrievedData
                            urlString = SocialNetworkData.SampleData()[4].ContactUrl + "id" + loginResult.UserId;
                            return(urlString);//VkRetrievedData;
                        }
                    }
                }
                else
                {
                    return(urlString);//VkRetrievedData;
                }
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
        private async Task <bool> checkAccounts()
        {
            webView.Hidden = false;
            showBn.Hidden  = true;
            string result = null;

            if (urlRoot == SocialNetworkData.SampleData()[4].ContactUrl)
            {
                try
                {
                    result = await GetVkData();
                }
                catch
                {
                    if (!methods.IsConnected())
                    {
                        InvokeOnMainThread(() =>
                        {
                            NoConnectionViewController.view_controller_name = GetType().Name;
                            this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                            return;
                        });
                    }
                    return(false);
                }
            }
            //else if (urlRoot == SocialNetworkData.SampleData()[0].ContactUrl)
            //result = await GetFbData();
            if (!String.IsNullOrEmpty(result))
            {
                webView.Hidden    = false;
                showBn.Hidden     = true;
                urlString         = result;
                UrlTextField.Text = urlString;
                UrlTextField.FloatLabelTop();
            }
            else
            {
                //showBn.Hidden = true;
                webView.Hidden           = true;
                activityIndicator.Hidden = true;
                if (String.IsNullOrEmpty(UrlTextField.Text))
                {
                    showBn.Hidden = true;
                }
            }
            Dispose();
            return(true);
        }
        void AcceptBn_TouchUpInside(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(UrlTextField.Text))
            {
                return;
            }

            int i = 0;

            foreach (var item in SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl)
            {
                if (item.SocialNetworkID == SocialNetworkData.SampleData()[SocialNetworkTableViewSource <int, int> .currentIndex].Id)
                {
                    SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl.RemoveAt(i);

                    break;
                }
                i++;
            }

            // Check if the user entered id of his profile.
            if (!UrlTextField.Text.ToLower().Contains("http"))
            {
                JoinIdAndLink();
            }
            SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl.Add(
                new CardsPCL.Models.SocialNetworkModel
            {
                SocialNetworkID = SocialNetworkData.SampleData()[SocialNetworkTableViewSource <int, int> .currentIndex].Id,
                ContactUrl      = UrlTextField.Text
            });

            bool index_exists = false;

            foreach (var index in SocialNetworkTableViewSource <int, int> .selectedIndexes)
            {
                if (index == SocialNetworkTableViewSource <int, int> .currentIndex)
                {
                    index_exists = true;
                    break;
                }
            }
            if (!index_exists)
            {
                SocialNetworkTableViewSource <int, int> .selectedIndexes.Add(SocialNetworkTableViewSource <int, int> .currentIndex);
            }
            NavigationController.PopViewController(true);
        }
        public void Bind(object item)
        {
            var index = SocialNetworkData.SampleData().FindIndex(x => x.Id == Convert.ToInt32(item));

            if (index > 0)
            {
                DividerTopView.Hidden = true;
            }
            else
            {
                DividerTopView.Hidden = false;
            }
            NameNetworkLabel.Text      = SocialNetworkData.SampleData()[index].NameNetworkLabel;
            NameNetworkLabel.Font      = UIFont.FromName(Constants.fira_sans, 18f);
            NameNetworkLabel.TextColor = UIColor.White;
            LogoImageView.Image        = SocialNetworkData.SampleData()[index].Logo;
        }
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            currentIndex = indexPath.Row;
            try
            {
                //if (_checkedRows.ContainsKey(indexPath))
                //{
                //    var removeValue = selectedIndexes.First(x => x == indexPath.Row);
                //    selectedIndexes.Remove(removeValue);
                //    _checkedRows.Remove(indexPath);
                //}
                //else
                //{
                //    _checkedRows.Add(indexPath, string.Empty);
                //    selectedIndexes.Add(indexPath.Row);
                //}
                _indexPathOfSelectedRow = indexPath;
            }
            catch { }
            TableView.ReloadRows(new[] { indexPath }, UITableViewRowAnimation.Right);

            var  id = SocialNetworkData.SampleData()[indexPath.Row].Id;
            bool link_exists_in_users_social_list = false;
            int  i = 0;

            foreach (var item in socialNetworkListWithMyUrl)
            {
                if (item.SocialNetworkID == id)
                {
                    WebViewSocialToChooseViewController.urlString = socialNetworkListWithMyUrl[i].ContactUrl;
                    link_exists_in_users_social_list = true;
                    break;
                }
                i++;
            }
            if (!link_exists_in_users_social_list)
            {
                WebViewSocialToChooseViewController.urlString = null;
            }
            WebViewSocialToChooseViewController.urlRoot     = SocialNetworkData.SampleData()[indexPath.Row].ContactUrl;
            WebViewSocialToChooseViewController.headerValue = SocialNetworkData.SampleData()[indexPath.Row].NameNetworkLabel;

            navigationController.PushViewController(storyboard.InstantiateViewController(nameof(WebViewSocialToChooseViewController)), true);
        }
Esempio n. 6
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(true);

            var source = new SocialNetworkTableViewSource <int, int>(tableView, this.NavigationController);
            var items  = new List <int>();

            datalist = SocialNetworkData.SampleData();

            for (int i = 0; i < datalist.Count; i++)
            {
                items.Add(datalist[i].Id);
            }

            source.Items = items.GroupBy(item => 10 * ((item + 9) / 10));

            tableView.RowHeight = cellHeight;
            tableView.Source    = source;
        }
 // If the user enters id of his profile.
 private void JoinIdAndLink()
 {
     // Facebook.
     if (urlRoot == SocialNetworkData.SampleData()[0].ContactUrl)
     {
         UrlTextField.Text = SocialNetworkData.SampleData()[0].ContactUrl /*+ Constants.faceBookUrlPart*/ + UrlTextField.Text;
     }
     // Instagram.
     else if (urlRoot == SocialNetworkData.SampleData()[1].ContactUrl)
     {
         UrlTextField.Text = SocialNetworkData.SampleData()[1].ContactUrl + UrlTextField.Text;
     }
     // LinkedIn.
     else if (urlRoot == SocialNetworkData.SampleData()[2].ContactUrl)
     {
         if (UrlTextField.Text.Contains("/"))
         {
             var linkedIdArray = UrlTextField.Text.Split("/");
             UrlTextField.Text = SocialNetworkData.SampleData()[2].ContactUrl + Constants.linkedInUrlPart + linkedIdArray[linkedIdArray.Length - 1];
         }
         else
         {
             UrlTextField.Text = SocialNetworkData.SampleData()[2].ContactUrl + Constants.linkedInUrlPart + UrlTextField.Text;
         }
     }
     // Twitter.
     else if (urlRoot == SocialNetworkData.SampleData()[3].ContactUrl)
     {
         UrlTextField.Text = SocialNetworkData.SampleData()[3].ContactUrl + UrlTextField.Text;
     }
     // Vkontakte.
     else if (urlRoot == SocialNetworkData.SampleData()[4].ContactUrl)
     {
         UrlTextField.Text = SocialNetworkData.SampleData()[4].ContactUrl + UrlTextField.Text;
     }
     urlString = UrlTextField.Text;
     UpdateWebView();
 }
 void SetFields()
 {
     if (!String.IsNullOrEmpty(urlString))
     {
         UrlTextField.FloatLabelTop();
         UrlTextField.Text = urlString;
         if (urlRoot != SocialNetworkData.SampleData()[2].ContactUrl && urlRoot != SocialNetworkData.SampleData()[0].ContactUrl)
         {
             webView.Hidden = false;
         }
         else
         {
             webView.Hidden = true;
         }
         showBn.Hidden = true;
         UpdateWebView();
     }
     else
     {
         showBn.Hidden  = true;
         webView.Hidden = true;
         UpdateWebView();
     }
 }
Esempio n. 9
0
        private void FillVariables(CardsDataModel des_card_data)
        {
            InvokeOnMainThread(() =>
            {
                if (des_card_data.isPrimary)
                {
                    switchSw.On = true;
                    EditPersonalDataViewControllerNew.is_primary = true;
                    switchSw.UserInteractionEnabled = false;
                }
                else
                {
                    switchSw.On = false;
                    EditPersonalDataViewControllerNew.is_primary = false;
                    switchSw.UserInteractionEnabled = true;
                }
            });
            try { EditPersonalProcessViewController.company_id = des_card_data.employment.company.id; } catch { }

            ids_of_attachments.Clear();
            images_from_server_list.Clear();
            //SocialNetworkTableViewSource<int, int>.selectedIndexes.Clear();
            //SocialNetworkTableViewSource<int, int>.socialNetworkListWithMyUrl.Clear();
            //SocialNetworkTableViewSource<int, int>._checkedRows.Clear();
            if (des_card_data.gallery != null)
            {
                foreach (var item in des_card_data.gallery)
                {
                    ids_of_attachments.Add(item.id);
                    try
                    {
                        UIImage image;
                        using (var url = new NSUrl(item.url))
                            using (var data = NSData.FromUrl(url))
                                image = UIImage.LoadFromData(data);
                        images_from_server_list.Add(image);
                    }
                    catch
                    {
                        if (!methods.IsConnected())
                        {
                            InvokeOnMainThread(() =>
                            {
                                NoConnectionViewController.view_controller_name = GetType().Name;
                                this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                                return;
                            });
                        }
                        return;
                    }
                }
            }

            //des_card_data.employment.company.logo.url
            //ids_of_attachments = des_card_data.gallery.;
            //var position = des_card_data.employment.position;
            if (String.IsNullOrEmpty(QRViewController.CompanyLogoInQr))
            {
                try
                {
                    if (des_card_data.employment.company.logo != null)
                    {
                        try
                        {
                            UIImage image_logo;
                            using (var url = new NSUrl(des_card_data.employment.company.logo.url))
                                using (var data = NSData.FromUrl(url))
                                    CropCompanyLogoViewController.cropped_result = UIImage.LoadFromData(data);
                        }
                        catch
                        {
                            if (!methods.IsConnected())
                            {
                                InvokeOnMainThread(() =>
                                {
                                    NoConnectionViewController.view_controller_name = GetType().Name;
                                    this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                                    return;
                                });
                            }
                            return;
                        }
                    }
                }
                catch { }
            }
            //else
            //{

            //}
            if (des_card_data.person.socialNetworks != null)
            {
                try
                {
                    SocialNetworkTableViewSource <int, int> .selectedIndexes.Clear();

                    SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl.Clear();
                }
                catch { }
                //foreach (var item in des_card_data.person.socialNetworks)
                //{
                //    SocialNetworkTableViewSource<int, int>.selectedIndexes.Add(item.id);
                //}

                int i = 0;
                foreach (var item_ in SocialNetworkData.SampleData())
                {
                    foreach (var item in des_card_data.person.socialNetworks)
                    {
                        if (item.id == item_.Id)
                        {
                            SocialNetworkTableViewSource <int, int> .selectedIndexes.Add(i);

                            SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl.Add(new SocialNetworkModel { SocialNetworkID = item.id, ContactUrl = item.contactUrl });
                        }
                    }
                    i++;
                }
            }
            try { EditPersonalDataViewControllerNew.mySurname = des_card_data.person.lastName; } catch { }
            try { EditPersonalDataViewControllerNew.myName = des_card_data.person.firstName; } catch { }
            try { EditPersonalDataViewControllerNew.myMiddlename = des_card_data.person.middleName; } catch { }
            try { EditPersonalDataViewControllerNew.myPhone = des_card_data.person.mobilePhone; } catch { }
            try { EditPersonalDataViewControllerNew.myEmail = des_card_data.person.email; } catch { }
            try { EditPersonalDataViewControllerNew.myHomePhone = des_card_data.person.homePhone; } catch { }
            try { EditPersonalDataViewControllerNew.mySite = des_card_data.person.siteUrl; } catch { }
            try { EditPersonalDataViewControllerNew.myDegree = des_card_data.person.education; } catch { }
            try { EditPersonalDataViewControllerNew.myCardName = des_card_data.name; } catch { }
            try { EditPersonalDataViewControllerNew.myCardNameOriginal = des_card_data.name; } catch { }
            try { EditPersonalDataViewControllerNew.myBirthDate = des_card_data.person.birthdate.Substring(0, 10); } catch { }
            try { PersonalDataViewControllerNew.images_list.Clear(); } catch { }
            try { HomeAddressViewController.FullAddressStatic = des_card_data.person.location.address; } catch { }
            try { HomeAddressViewController.myCountry = des_card_data.person.location.country; } catch { }
            try { HomeAddressViewController.myRegion = des_card_data.person.location.region; } catch { }
            try { HomeAddressViewController.myCity = des_card_data.person.location.city; } catch { }
            try { HomeAddressViewController.myIndex = des_card_data.person.location.postalCode; } catch { }
            try { HomeAddressViewController.myNotation = des_card_data.person.location.notes; } catch { }
            try { NewCardAddressMapViewController.lat = des_card_data.person.location.latitude.ToString().Replace(',', '.'); } catch { }
            try { NewCardAddressMapViewController.lng = des_card_data.person.location.longitude.ToString().Replace(',', '.'); } catch { }

            try { EditCompanyDataViewControllerNew.companyName = des_card_data.employment.company.name; } catch { }
            try { EditCompanyDataViewControllerNew.linesOfBusiness = des_card_data.employment.company.activity; } catch { }
            try { EditCompanyDataViewControllerNew.position = des_card_data.employment.position; } catch { }
            try { EditCompanyDataViewControllerNew.foundationYear = des_card_data.employment.company.foundedYear.ToString(); } catch { }
            try { EditCompanyDataViewControllerNew.clients = des_card_data.employment.company.customers; } catch { }
            try { EditCompanyDataViewControllerNew.companyPhone = des_card_data.employment.company.phone; } catch { }
            try { EditCompanyDataViewControllerNew.corporativePhone = des_card_data.employment.phone; } catch { }
            try { EditCompanyDataViewControllerNew.fax = des_card_data.employment.company.fax; } catch { }
            try { EditCompanyDataViewControllerNew.companyEmail = des_card_data.employment.company.email; } catch { }
            try { EditCompanyDataViewControllerNew.corporativeSite = des_card_data.employment.company.siteUrl; } catch { }
            try { CompanyAddressViewController.FullCompanyAddressStatic = des_card_data.employment.company.location.address; } catch { }
            try { CompanyAddressViewController.country = des_card_data.employment.company.location.country; } catch { }
            try { CompanyAddressViewController.region = des_card_data.employment.company.location.region; } catch { }
            try { CompanyAddressViewController.city = des_card_data.employment.company.location.city; } catch { }
            try { CompanyAddressViewController.index = des_card_data.employment.company.location.postalCode; } catch { }
            try { CompanyAddressViewController.notation = des_card_data.employment.company.location.notes; } catch { }
            try { CompanyAddressMapViewController.company_lat = des_card_data.employment.company.location.latitude.ToString().Replace(',', '.'); } catch { }
            try { CompanyAddressMapViewController.company_lng = des_card_data.employment.company.location.longitude.ToString().Replace(',', '.'); } catch { }
            try { EditCompanyDataViewControllerNew.logo_id = des_card_data.employment.company.logo.id; } catch { EditCompanyDataViewControllerNew.logo_id = null; }
        }
        //public override void ViewWillAppear(bool animated)
        //{
        //    base.ViewWillAppear(animated);


        //}

        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitElements();

            string[] tableItems = new string[] { "Да" };

            option          = new UIActionSheet(null, null, "Нет", null, tableItems);
            option.Title    = "Удалить ссылку на профиль в социальной сети?";
            option.Clicked += (btn_sender, args) => //Console.WriteLine("{0} Clicked", args.ButtonIndex);
            {
                if (args.ButtonIndex == 0)
                {
                    SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl.RemoveAll(x => x.SocialNetworkID == SocialNetworkData.SampleData()[SocialNetworkTableViewSource <int, int> .currentIndex].Id);

                    SocialNetworkTableViewSource <int, int> .selectedIndexes.RemoveAll(x => x == SocialNetworkTableViewSource <int, int> .currentIndex);

                    NavigationController.PopViewController(true);
                    SocialNetworkTableViewSource <int, int> ._checkedRows.Clear();
                }
            };
            backBn.TouchUpInside += (s, e) =>
            {
                this.NavigationController.PopViewController(true);
            };
            if (!methods.IsConnected())
            {
                NoConnectionViewController.view_controller_name = GetType().Name;
                this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                return;
            }
            acceptBn.TouchUpInside += AcceptBn_TouchUpInside;
            removeBn.TouchUpInside += (s, e) =>
            {
                option.ShowInView(View);
            };
            //InitElements();
            //View.Hidden = true;
            try
            {
                var res = await checkAccounts();
            }
            catch
            {
                if (!methods.IsConnected())
                {
                    InvokeOnMainThread(() =>
                    {
                        NoConnectionViewController.view_controller_name = GetType().Name;
                        this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                        return;
                    });
                }
                return;
            }
            UpdateWebView();
            //webView.LoadFinished += (s, e) =>
            //{
            //    using (s as UIWebView)
            //    {
            //        UrlTextField.Text = ((UIWebView)s).Request.Url.AbsoluteString;
            //        urlString = ((UIWebView)s).Request.Url.AbsoluteString;
            //        UrlTextField.FloatLabelTop();
            //    }
            //};
            //var gkgmg = new WKWebView();
        }
        private void InitElements()
        {
            // Enable back navigation using swipe.
            NavigationController.InteractivePopGestureRecognizer.Delegate = null;

            new AppDelegate().disableAllOrientation = true;
            var deviceModel = Xamarin.iOS.DeviceHardware.Model;

            if (deviceModel.Contains("X"))
            {
                headerView.Frame  = new Rectangle(0, 0, Convert.ToInt32(View.Frame.Width), (Convert.ToInt32(View.Frame.Height) / 10) + 8);
                backBn.Frame      = new Rectangle(0, (Convert.ToInt32(View.Frame.Width) / 20) + 20, Convert.ToInt32(View.Frame.Width) / 8, Convert.ToInt32(View.Frame.Width) / 8);
                headerLabel.Frame = new Rectangle(Convert.ToInt32(View.Frame.Width) / 5, (Convert.ToInt32(View.Frame.Width) / 12) + 20, (Convert.ToInt32(View.Frame.Width) / 5) * 3, Convert.ToInt32(View.Frame.Width) / 18);
                removeBn.Frame    = new Rectangle(Convert.ToInt32(View.Frame.Width - View.Frame.Width / 4), Convert.ToInt32(View.Frame.Width) / 12 + 20, Convert.ToInt32(View.Frame.Width) / 4, Convert.ToInt32(View.Frame.Width) / 19);
            }
            else
            {
                headerView.Frame  = new Rectangle(0, 0, Convert.ToInt32(View.Frame.Width), (Convert.ToInt32(View.Frame.Height) / 10));
                backBn.Frame      = new Rectangle(0, Convert.ToInt32(View.Frame.Width) / 20, Convert.ToInt32(View.Frame.Width) / 8, Convert.ToInt32(View.Frame.Width) / 8);
                headerLabel.Frame = new Rectangle(Convert.ToInt32(View.Frame.Width) / 5, Convert.ToInt32(View.Frame.Width) / 12, (Convert.ToInt32(View.Frame.Width) / 5) * 3, Convert.ToInt32(View.Frame.Width) / 18);
                removeBn.Frame    = new Rectangle(Convert.ToInt32(View.Frame.Width - View.Frame.Width / 4), Convert.ToInt32(View.Frame.Width) / 12, Convert.ToInt32(View.Frame.Width) / 4, Convert.ToInt32(View.Frame.Width) / 19);
            }
            View.BackgroundColor       = UIColor.FromRGB(36, 43, 52);
            headerView.BackgroundColor = UIColor.FromRGB(36, 43, 52);
            headerLabel.Text           = headerValue;
            removeBn.SetTitle("Удалить", UIControlState.Normal);

            acceptBn.BackgroundColor = UIColor.FromRGB(255, 99, 62);
            backBn.ImageEdgeInsets   = new UIEdgeInsets(backBn.Frame.Height / 3.5F, backBn.Frame.Width / 2.35F, backBn.Frame.Height / 3.5F, backBn.Frame.Width / 3);
            activityIndicator.Color  = UIColor.FromRGB(255, 99, 62);
            activityIndicator.Frame  = new Rectangle((int)(View.Frame.Width / 2 - View.Frame.Width / 20), (int)(View.Frame.Height / 2 - View.Frame.Width / 20), (int)(View.Frame.Width / 10), (int)(View.Frame.Width / 10));

            var hintLabel = new UILabel();

            hintLabel.TextColor = UIColor.White;
            hintLabel.Text      = "Укажите свой аккаунт в социальной сети (id) или вставьте ссылку на свой профиль";

            hintLabel.Frame = new CoreGraphics.CGRect(20, headerView.Frame.Height + 10, headerView.Frame.Width - 40, headerView.Frame.Height / 1.65);
            hintLabel.Lines = 2;
            View.AddSubview(hintLabel);
            hintLabel.Font      = UIFont.FromName(Constants.fira_sans, 14f);
            hintLabel.TextColor = UIColor.FromRGB(146, 150, 155);
            //hintLabel.TextAlignment = UITextAlignment.;
            //hintLabel.BackgroundColor = UIColor.Red;

            webView = new WKWebView(View.Frame, new WKWebViewConfiguration());
            //webView = new UIWebView();
            webView.NavigationDelegate = this;
            View.AddSubview(webView);
            //webView.Hidden = true;
            UpdateWebView();
            acceptBn.Frame = new Rectangle(Convert.ToInt32(View.Frame.Width) / 15,
                                           (Convert.ToInt32(View.Frame.Height) / 10) * 9,
                                           Convert.ToInt32(View.Frame.Width) - ((Convert.ToInt32(View.Frame.Width) / 15) * 2),
                                           Convert.ToInt32(View.Frame.Height) / 12);
            acceptBn.SetTitle("СОХРАНИТЬ", UIControlState.Normal);
            acceptBn.Font = acceptBn.Font.WithSize(15f);
            var val = View.Frame.Height - acceptBn.Frame.Y - acceptBn.Frame.Height;

            webView.Frame = new Rectangle(0,
                                          (int)headerView.Frame.Height * 2 + 51,
                                          (int)View.Frame.Width,
                                          (int)(acceptBn.Frame.Y - headerView.Frame.Height * 3 - val));
            acceptBn.Font = UIFont.FromName(Constants.fira_sans, 15f);
            removeBn.Font = UIFont.FromName(Constants.fira_sans, 17f);

            UrlTextField = new FloatingTextField
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder            = "Ссылка на ваш профиль",
                TextColor              = UIColor.White,
                ReturnKeyType          = UIReturnKeyType.Done,
                AutocapitalizationType = UITextAutocapitalizationType.None
            };
            UrlTextField.ShouldReturn = _ => View.EndEditing(true);

            UrlTextField.EditingChanged += (s, e) =>
            {
                urlString = UrlTextField.Text;
                UpdateWebView();
                webView.Hidden = true;
                // Second condition means that we do not need facebook and linkedin previews.
                if (!String.IsNullOrEmpty(UrlTextField.Text) && urlRoot != SocialNetworkData.SampleData()[2].ContactUrl && urlRoot != SocialNetworkData.SampleData()[0].ContactUrl)
                {
                    showBn.Hidden = false;
                }
                else
                {
                    showBn.Hidden = true;
                }

                //if (!UrlTextField.Text.ToLower().Contains("http"))
                //JoinIdAndLink();
            };
            View.AddSubview(UrlTextField);
            View.AddConstraints(new NSLayoutConstraint[]
            {
                UrlTextField.TopAnchor.ConstraintEqualTo(View.TopAnchor, hintLabel.Frame.Y + hintLabel.Frame.Height + 10),
                UrlTextField.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor, 16),
                UrlTextField.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor, -16),
                UrlTextField.HeightAnchor.ConstraintEqualTo(48)
            });

            showBn      = new UIButton();
            showBn.Font = UIFont.FromName(Constants.fira_sans, 15f);
            View.AddSubview(showBn);
            showBn.Frame = new Rectangle(Convert.ToInt32(View.Frame.Width) / 15,
                                         Convert.ToInt32(webView.Frame.Y),
                                         Convert.ToInt32(View.Frame.Width) - ((Convert.ToInt32(View.Frame.Width) / 15) * 2),
                                         Convert.ToInt32(View.Frame.Height) / 12);
            showBn.SetTitle("ПРОСМОТР", UIControlState.Normal);
            showBn.BackgroundColor = UIColor.FromRGB(255, 99, 62);
            showBn.TouchUpInside  += (s, e) =>
            {
                // Check if the user entered id of his profile.
                if (!UrlTextField.Text.ToLower().Contains("http"))
                {
                    JoinIdAndLink();
                }
                webView.Hidden = false;
                showBn.Hidden  = true;
            };
        }
        public static void show_loader(int card_id)
        {
            if (!methods.IsConnected())
            {
                NoConnectionViewController.view_controller_name = "CreatingCardViewController";
                var vc = UINavigationController_;
                vc.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                return;
            }
            staticLoaderView.Hidden = false;

            InvokeInBackground(async() =>
            {
                var UDID          = UIDevice.CurrentDevice.IdentifierForVendor.ToString();
                var res_card_data = await cards.CardDataGet(databaseMethods.GetAccessJwt(), card_id, UDID);
                if (/*res_card_data == Constants.status_code409 ||*/ res_card_data == Constants.status_code401)
                {
                    UINavigationController_.InvokeOnMainThread(() =>
                    {
                        ShowSeveralDevicesRestriction();
                        return;
                    });
                    return;
                }
                var des_card_data = JsonConvert.DeserializeObject <CardsDataModel>(res_card_data);
                try
                {
                    using (var url = new NSUrl(des_card_data.employment.company.logo.url))
                        using (var data = NSData.FromUrl(url))
                            CropCompanyLogoViewController.cropped_result = UIImage.LoadFromData(data);
                }
                catch
                {
                }
                UINavigationController_.InvokeOnMainThread(() =>
                {
                    try
                    {
                        PersonalDataViewControllerNew.images_list.Clear();
                    }
                    catch
                    {
                    }
                });
                if (des_card_data.gallery != null)
                {
                    foreach (var item in des_card_data.gallery)
                    {
                        UIImage image;
                        using (var url = new NSUrl(item.url))
                            using (var data = NSData.FromUrl(url))
                                image = UIImage.LoadFromData(data);
                        UINavigationController_.InvokeOnMainThread(() =>
                        {
                            PersonalDataViewControllerNew.images_list.Add(image);
                        });
                    }
                }
                UINavigationController_.InvokeOnMainThread(() =>
                {
                    PersonalDataViewControllerNew.mySurname    = des_card_data?.person?.lastName;
                    PersonalDataViewControllerNew.myName       = des_card_data?.person?.firstName;
                    PersonalDataViewControllerNew.myMiddlename = des_card_data?.person?.middleName;
                    PersonalDataViewControllerNew.myPhone      = des_card_data?.person?.mobilePhone;
                    PersonalDataViewControllerNew.myEmail      = des_card_data?.person?.email;
                    PersonalDataViewControllerNew.myHomePhone  = des_card_data?.person?.homePhone;
                    PersonalDataViewControllerNew.mySite       = des_card_data?.person?.siteUrl;
                    PersonalDataViewControllerNew.myDegree     = des_card_data?.person?.education;
                    PersonalDataViewControllerNew.myCardName   = des_card_data?.name;
                    try { PersonalDataViewControllerNew.myBirthdate = des_card_data.person.birthdate.Substring(0, 10); } catch { }

                    HomeAddressViewController.FullAddressStatic = des_card_data?.person?.location?.address;
                    HomeAddressViewController.myCountry         = des_card_data?.person?.location?.country;
                    HomeAddressViewController.myRegion          = des_card_data?.person?.location?.region;
                    HomeAddressViewController.myCity            = des_card_data?.person?.location?.city;
                    HomeAddressViewController.myIndex           = des_card_data?.person?.location?.postalCode;
                    HomeAddressViewController.myNotation        = des_card_data?.person?.location?.notes;
                    NewCardAddressMapViewController.lat         = des_card_data?.person?.location?.latitude?.ToString()?.Replace(',', '.');
                    NewCardAddressMapViewController.lng         = des_card_data?.person?.location?.longitude?.ToString()?.Replace(',', '.');
                    try { CompanyDataViewControllerNew.position = des_card_data.employment.position; } catch { }
                    try { CompanyDataViewControllerNew.companyName = des_card_data.employment.company.name; } catch { }
                    try { CompanyDataViewControllerNew.linesOfBusiness = des_card_data.employment.company.activity; } catch { }
                    try { CompanyDataViewControllerNew.foundationYear = des_card_data.employment.company.foundedYear.ToString(); } catch { }
                    try { CompanyDataViewControllerNew.clients = des_card_data.employment.company.customers; } catch { }
                    try { CompanyDataViewControllerNew.companyPhone = des_card_data.employment.company.phone; } catch { }
                    try { CompanyDataViewControllerNew.corporativePhone = des_card_data.employment.phone; } catch { }
                    try { CompanyDataViewControllerNew.fax = des_card_data.employment.company.fax; } catch { }
                    try { CompanyDataViewControllerNew.companyEmail = des_card_data.employment.company.email; } catch { }
                    try { CompanyDataViewControllerNew.corporativeSite = des_card_data.employment.company.siteUrl; } catch { }
                    try { CompanyAddressViewController.FullCompanyAddressStatic = des_card_data.employment.company.location.address; } catch { }
                    try { CompanyAddressViewController.country = des_card_data.employment.company.location.country; } catch { }
                    try { CompanyAddressViewController.region = des_card_data.employment.company.location.region; } catch { }
                    try { CompanyAddressViewController.city = des_card_data.employment.company.location.city; } catch { }
                    try { CompanyAddressViewController.index = des_card_data.employment.company.location.postalCode; } catch { }
                    try { CompanyAddressViewController.notation = des_card_data.employment.company.location.notes; } catch { }
                    try { CompanyAddressMapViewController.company_lat = des_card_data.employment.company.location.latitude.ToString().Replace(',', '.'); } catch { }
                    try { CompanyAddressMapViewController.company_lng = des_card_data.employment.company.location.longitude.ToString().Replace(',', '.'); } catch { }
                    if (des_card_data.person.socialNetworks != null)
                    {
                        try
                        {
                            SocialNetworkTableViewSource <int, int> .selectedIndexes?.Clear();
                            SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl?.Clear();
                        }
                        catch { }
                        //foreach (var item in des_card_data.person.socialNetworks)
                        //{
                        //    SocialNetworkTableViewSource<int, int>.selectedIndexes.Add(item.id);
                        //}
                        try
                        {
                            int i = 0;
                            foreach (var item_ in SocialNetworkData.SampleData())
                            {
                                foreach (var item in des_card_data?.person?.socialNetworks)
                                {
                                    if (item.id == item_.Id)
                                    {
                                        SocialNetworkTableViewSource <int, int> .selectedIndexes.Add(i);
                                        SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl.Add(new SocialNetworkModel {
                                            SocialNetworkID = item.id, ContactUrl = item.contactUrl
                                        });
                                    }
                                }
                                i++;
                            }
                            foreach (var item /*index*/ in SocialNetworkTableViewSource <int, int> .socialNetworkListWithMyUrl)//.selectedIndexes)
                            {
                                databaseMethods.InsertPersonalNetwork(new SocialNetworkModel {
                                    SocialNetworkID = item.SocialNetworkID, ContactUrl = item.ContactUrl
                                });
                                //databaseMethods.InsertPersonalNetwork(new SocialNetworkModel { SocialNetworkID = datalist[index].Id, ContactUrl = datalist[index].ContactUrl });
                            }
                        }
                        catch { }
                    }
                    staticLoaderView.Hidden = true;
                    personal_dataVC         = sb.InstantiateViewController(nameof(PersonalDataViewControllerNew));
                    UINavigationController_.PushViewController(personal_dataVC, true);
                });
            });
        }