示例#1
0
        public void BindDataToView(Card card, bool editable)
        {
            if (card == null)
            {
                return;
            }

            BackgroundColor = ColorUtils.FromHexString(card.BackgroundColor, UIColor.White);

            CompanyNameTextField.Text        = card.CompanyName;
            CompanyNameTextField.Placeholder = (editable) ? Strings.Basic.company_name : String.Empty;
            CompanyNameTextField.TextColor   = ColorUtils.FromHexString(card.CompanyNameTextColor, UIColor.White);
            CompanyNameTextField.Enabled     = editable;
            CompanyNameTextField.RemoveTarget(null, null, UIControlEvent.EditingChanged);
            CompanyNameTextField.EditingChanged += (sender, e) =>
            {
                card.UpdateStringProperty(() => card.CompanyName, CompanyNameTextField.Text.Trim());
                DealWithTextFieldborder(CompanyNameTextField, card, editable);
                NSNotificationCenter.DefaultCenter.PostNotificationName(Strings.InternalNotifications.notification_card_editing_changed, null);
            };
            CompanyNameTextField.RemoveTarget(null, null, UIControlEvent.EditingDidEndOnExit);
            CompanyNameTextField.EditingDidEndOnExit += (sender, e) =>
            {
                CompanyNameTextField.ResignFirstResponder();
            };
            DealWithTextFieldborder(CompanyNameTextField, card, editable);

            var fallback = (editable) ? "Buildings" : null;

            LogoImageButton.SetImageWithCustomCache(card.GetRemoteLogoUrlCached(), fallback, fallback, card.RemoteLogoURL);
            LogoImageButton.UserInteractionEnabled = editable;
        }
示例#2
0
        public void BindDataToView(NewCardModel model)
        {
            Reset();

            Label.Text = model.Title;
            RightView.BackgroundColor          = ColorUtils.FromHexString(model.ColorHexString, (model.IsTitle) ? UIColor.Clear : UIColor.White);
            RightViewSuperview.BackgroundColor = model.IsTitle ? UIColor.Clear : UIColor.White;
        }
        public override void ViewDidLoad()
        {
            PullToRefresh = false;

            base.ViewDidLoad();

            TableSource = new NewCardTableViewSource();
            TableSource.ItemSelected += (NSIndexPath arg1, NewCardModel arg2) =>
            {
                if (arg2 == null || String.IsNullOrEmpty(arg2.Title))
                {
                    return;
                }

                var vc = new ColorPickerViewController();
                vc.ModalPresentationStyle = UIModalPresentationStyle.OverFullScreen;
                vc.ModalTransitionStyle   = UIModalTransitionStyle.CrossDissolve;
                vc.LabelTitle             = arg2.Title;
                vc.StartingColor          = ColorUtils.FromHexString(arg2.ColorHexString, UIColor.White);
                vc.ColorPicked           += (UIColor obj) =>
                {
                    if (obj == null && String.IsNullOrEmpty(arg2.Title))
                    {
                        return;
                    }

                    arg2.ColorHexString = ColorUtils.HexStringFromColor(obj);

                    if (arg2.Title.Equals(NewCardShared.new_card_model_border_color, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Shared.SelectedCard.UpdateStringProperty(() => Shared.SelectedCard.BorderColor, arg2.ColorHexString);
                        Shared.SelectedCard.ShowFront();
                    }

                    else if (arg2.Title.Equals(NewCardShared.new_card_model_background_color, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Shared.SelectedCard.UpdateStringProperty(() => Shared.SelectedCard.BackgroundColor, arg2.ColorHexString);
                        Shared.SelectedCard.ShowBack();
                    }

                    else if (arg2.Title.Equals(NewCardShared.new_card_model_company_name_text_color, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Shared.SelectedCard.UpdateStringProperty(() => Shared.SelectedCard.CompanyNameTextColor, arg2.ColorHexString);
                        Shared.SelectedCard.ShowBack();
                    }


                    HeaderView.Update(false);
                    TableView.ReloadRows(new NSIndexPath[] { arg1 }, UITableViewRowAnimation.Automatic);
                };

                var flyingObjectsContainerViewController = new FlyingObjectsContainterViewController();
                var clearNavigationController            = flyingObjectsContainerViewController.ContainerNavigationController;
                clearNavigationController.SetViewControllers(new UIViewController[] { vc }, false);
                PresentViewController(flyingObjectsContainerViewController, false, null);
            };
            TableSource.RowDeleted += (NSIndexPath arg1, NewCardModel arg2) =>
            {
                if (arg2.Outlet == null)
                {
                    return;
                }

                Shared.SelectedCard.RemoveOutlet(arg2.Outlet);
                TableSource.TableItems.Remove(arg2);
                HeaderView.Update(false);
            };
            TableView.Source = TableSource;

            HeaderView.Editable     = true;
            HeaderView.SelectedCard = Shared.SelectedCard;
            HeaderView.View.Frame   = new CGRect(0, 0, TableView.Frame.Width, CardViewController.GetCalculatedHeight());
            AddChildViewController(HeaderView);
            TableView.TableHeaderView = HeaderView.View;


            AddRowViewController FooterView = new AddRowViewController();

            FooterView.LabelAddText = NewCardShared.AddNewOutlet;
            FooterView.Clicked     += (editing) =>
            {
                ShowMyOutletsViewController();
            };
            FooterView.View.Frame     = new CGRect(0, 0, TableView.Frame.Width, FooterView.GetHeight());
            TableView.TableFooterView = FooterView.View;
            AddChildViewController(FooterView);
        }
示例#4
0
        public void BindDataToView(Card card, bool editable, NSIndexPath indexPath, bool reloadImages)
        {
            if (card == null)
            {
                return;
            }

            BackgroundColor = ColorUtils.FromHexString(card.BorderColor, UIColor.White);

            UserDisplayNameTextField.Text        = card.UserDisplayName;
            UserDisplayNameTextField.Placeholder = (editable) ? Strings.Basic.your_name : String.Empty;
            UserDisplayNameTextField.Enabled     = editable;
            UserDisplayNameTextField.RemoveTarget(null, null, UIControlEvent.EditingChanged);
            UserDisplayNameTextField.EditingChanged += (sender, e) =>
            {
                card.UpdateStringProperty(() => card.UserDisplayName, UserDisplayNameTextField.Text.Trim());
                DealWithTextFieldborder(UserDisplayNameTextField, card, editable);
                NSNotificationCenter.DefaultCenter.PostNotificationName(Strings.InternalNotifications.notification_card_editing_changed, null);
            };
            UserDisplayNameTextField.RemoveTarget(null, null, UIControlEvent.EditingDidEndOnExit);
            UserDisplayNameTextField.EditingDidEndOnExit += (sender, e) =>
            {
                UserDisplayNameTextField.ResignFirstResponder();
            };
            DealWithTextFieldborder(UserDisplayNameTextField, card, editable);

            TitleTextField.Text        = card.Title;
            TitleTextField.Enabled     = editable;
            TitleTextField.Placeholder = (editable) ? Strings.Basic.title : String.Empty;
            TitleTextField.RemoveTarget(null, null, UIControlEvent.EditingChanged);
            TitleTextField.EditingChanged += (sender, e) =>
            {
                card.UpdateStringProperty(() => card.Title, TitleTextField.Text.Trim());
                DealWithTextFieldborder(TitleTextField, card, editable);
                NSNotificationCenter.DefaultCenter.PostNotificationName(Strings.InternalNotifications.notification_card_editing_changed, null);
            };
            TitleTextField.RemoveTarget(null, null, UIControlEvent.EditingDidEndOnExit);
            TitleTextField.EditingDidEndOnExit += (sender, e) =>
            {
                TitleTextField.ResignFirstResponder();
            };
            DealWithTextFieldborder(TitleTextField, card, editable);

            if (reloadImages)
            {
                HeaderImageButton.SetImageWithCustomCache(card.GetRemoteHeaderUrlCached(), "NoProfile", "NoProfile", card.RemoteHeaderURL);
            }
            HeaderImageButton.Layer.MasksToBounds    = true;
            HeaderImageButton.Layer.CornerRadius     = HeaderImageButton.Frame.Size.Width / 2;
            HeaderImageButton.ClipsToBounds          = false;
            HeaderImageButton.UserInteractionEnabled = editable;

            CollectionView.RegisterNibForCell(UINib.FromName("MyCardsCollectionViewCell", NSBundle.MainBundle), MyCardsCollectionViewCell.Key);
            CollectionView.ContentInset   = new UIEdgeInsets(0, 8, 0, 8);
            CollectionView.WeakDataSource = new MyCardsTableViewCellCollectionViewDataSource(card);
            CollectionView.WeakDelegate   = new MyCardsTableViewCellCollectionViewDelegateFlowLayout();

            if (CollectionViewTapGesture == null)
            {
                CollectionViewTapGesture = new UITapGestureRecognizer((obj) =>
                {
                    NSNotificationCenter.DefaultCenter.PostNotificationName(Strings.InternalNotifications.notification_collection_view_tapped, indexPath);
                });
            }
            CollectionView.RemoveGestureRecognizer(CollectionViewTapGesture);
            CollectionView.AddGestureRecognizer(CollectionViewTapGesture);

            NoOutletsButton.Hidden = !(card.Outlets == null || card.Outlets.Count == 0);
        }