Пример #1
0
        private void GetProfileComplete(ProfileResponseModel profileResponse)
        {
            try
            {
                if (profileResponse.ResponseCode > 0)
                {
                    ImageService.Instance.LoadUrl(profileResponse.Profile.ProfilePictureURL).Into(ivUserImage);
                    lblUserName.Text     = StringWithEmojiConverter.ConvertEmojiFromServer(profileResponse.Profile.UserName);
                    lblScoreValue.Text   = profileResponse.Profile.Score.ToString();
                    lblRankCategory.Text = profileResponse.Profile.ScoreLabel;

                    lblFriendsInfo.Text = profileResponse.Profile.FriendPreviewList?.Count > 0 ? profileResponse.Profile.FriendPreviewList?.Count + "Friends" : string.Empty;
                }
            }
            catch (Exception)
            {
            }
        }
        void SaveProfile()
        {
            SL.Profile.UserName              = SocialLadder.iOS.Helpers.StringWithEmojiConverter.ConvertEmojiToServer(DisplayNameText.Text);
            SL.Profile.City                  = CityText.Text;
            SL.Profile.EmailAddress          = EmailText.Text;
            SL.Profile.isNotificationEnabled = swNotifications.On;

            var newProfile = new ProfileUpdateModel()
            {
                UserName              = StringWithEmojiConverter.ConvertEmojiToServer(DisplayNameText.Text),
                EmailAddress          = EmailText.Text,
                isNotificationEnabled = swNotifications.On,
                isPhoneBookEnabled    = false,
                isGeoEnabled          = SL.Profile.isGeoEnabled,
                LocationLat           = SL.Profile.LocationLat,
                LocationLon           = SL.Profile.LocationLon,
                City       = CityText.Text,
                AppVersion = SL.Profile.AppVersion
            };

            SL.Manager.UpdateProfileAsync(newProfile);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            DisplayNameText.Text = StringWithEmojiConverter.ConvertEmojiFromServer(SL.Profile.UserName);//need to anderstand difference from NameText
            CityText.Text        = SL.Profile.City ?? "";
            NameOfCity           = SL.Profile.City ?? "";
            NameText.Text        = SL.Profile.UserName;

            CityText.EditingChanged += (s, e) =>
            {
                CityText.Text = CheckText(CityText.Text);
            };

            EmailText.EditingDidEnd += (s, e) =>
            {
                var profile = SL.Profile;
                profile.EmailAddress = EmailText.Text;
                SL.Manager.SaveProfileAsync(profile);
                SL.Profile = profile;
            };

            NameText.ShouldReturn = delegate
            {
                NameText.EndEditing(true);
                return(true);
            };

            DisplayNameText.ShouldReturn = delegate
            {
                DisplayNameText.EndEditing(true);
                return(true);
            };

            CityText.ShouldReturn = delegate
            {
                CityText.EndEditing(true);
                return(true);
            };

            EmailText.ShouldReturn = delegate
            {
                EmailText.EndEditing(true);
                return(true);
            };

            var tap = new UITapGestureRecognizer(() =>
            {
                foreach (var view in View.Subviews[0].Subviews[0].Subviews)
                {
                    if (view is UITextView text)
                    {
                        text.ResignFirstResponder();
                    }
                    if (view is UITextField text1)
                    {
                        text1.ResignFirstResponder();
                    }
                }
            });

            View.AddGestureRecognizer(tap);

            EmailText.Text = SL.Profile.EmailAddress;

            var version = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"];//NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"];

            VersionNumber.Text = $"v{version.Description}";

            #region v2
            //swFromElectricAdvinture.On = SL.AppSettings.GetValueOrDefault("FromElectricAdvintureEnabled", false);
            //swFromElectricAdvinture.ValueChanged += SwFromElectricAdvinture_ValueChanged;

            //Need remove to v.2
            Name_View.TranslatesAutoresizingMaskIntoConstraints = false;
            Name_Divider.Hidden = true;
            Name_View.RemoveConstraint(Name_View_Aspect);
            Name_View.AddConstraint(NSLayoutConstraint.Create(Name_View, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 0, 0));
            Name_View.UpdateConstraints();
            #endregion

            swComments.On            = SL.AppSettings.GetValueOrDefault("CommentsEnabled", false);
            swComments.ValueChanged += SwComments_ValueChanged;

            swLikes.On            = SL.AppSettings.GetValueOrDefault("LikesEnabled", false);
            swLikes.ValueChanged += SwLikes_ValueChanged;

            swDiscoverTeams.On            = SL.AppSettings.GetValueOrDefault("DiscoverTeamsEnabled", false);
            swDiscoverTeams.ValueChanged += SwDiscoverTeams_ValueChanged;

            swHideSocialNetworks.On            = SL.AppSettings.GetValueOrDefault("HideSocialNetworksEnabled", false);
            swHideSocialNetworks.ValueChanged += SwHideSocialNetworks_ValueChanged;

            #region v1
            var notificationStatus = SL.AppSettings.GetValueOrDefault("NotificationStatus", string.Empty);
            swNotifications.On            = notificationStatus.Equals(Enums.NotififcationStatus.Enabled.ToString()) ? true : false;
            swNotifications.ValueChanged += SwNotifications_ValueChanged;

            //SetupNotificationSwitch();

            ViewHideBlockDiscover.AddConstraint(NSLayoutConstraint.Create(ViewHideBlockDiscover, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 0));
            ViewHideBlockNotification.AddConstraint(NSLayoutConstraint.Create(ViewHideBlockNotification, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 0));
            View.UpdateConstraints();
            #endregion
        }