Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.AddComment);

            // Retrieve navigation parameter and set as current "DataContext"
            Vm = GlobalNavigation.GetAndRemoveParameter<FlowerViewModel>(Intent);

            // Avoid aggressive linker problem which removes the TextChanged event
            CommentText.TextChanged += (s, e) =>
            {
            };

            _saveBinding = this.SetBinding(
                () => CommentText.Text);

            // Avoid aggressive linker problem which removes the Click event
            SaveCommentButton.Click += (s, e) =>
            {
            };

            SaveCommentButton.SetCommand(
                "Click",
                Vm.SaveCommentCommand,
                _saveBinding);
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Details);

            // Retrieve navigation parameter and set as current "DataContext"
            Vm = GlobalNavigation.GetAndRemoveParameter<FlowerViewModel>(Intent);

            var headerView = LayoutInflater.Inflate(Resource.Layout.CommentsListHeaderView, null);
            headerView.FindViewById<TextView>(Resource.Id.NameText).Text = Vm.Model.Name;
            headerView.FindViewById<TextView>(Resource.Id.DescriptionText).Text = Vm.Model.Description;

            CommentsList.AddHeaderView(headerView);
            CommentsList.Adapter = Vm.Model.Comments.GetAdapter(GetCommentTemplate);

            ImageDownloader.AssignImageAsync(FlowerImageView, Vm.Model.Image, this);

            // Avoid aggressive linker problem which removes the Click event
            AddCommentButton.Click += (s, e) =>
            {
            };

            AddCommentButton.SetCommand(
                "Click",
                Vm.AddCommentCommand);
        }
Ejemplo n.º 3
0
 private void BindFlowerCell(UITableViewCell cell, FlowerViewModel flower, NSIndexPath path)
 {
     cell.TextLabel.Text = flower.Model.Name;
     cell.DetailTextLabel.Text = flower.Model.Description;
     cell.ImageView.SetImage(
         new NSUrl(flower.ImageUri.AbsoluteUri),
         UIImage.FromBundle("flower_256_magenta.png"));
 }
Ejemplo n.º 4
0
        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            DescriptionText = new UILabel(new CGRect(0, 0, 300, 235))
            {
                LineBreakMode = UILineBreakMode.WordWrap,
                Lines = 0,
            };
            Scroll.Add(DescriptionText);

            FlowerImage.SetImage(
                new NSUrl(Vm.ImageUri.AbsoluteUri),
                UIImage.FromBundle("flower_256_magenta.png"));

            this.SetBinding(
                () => Vm.Model.Name)
                .WhenSourceChanges(
                    () =>
                    {
                        // iOS is quite primitive and requires layout recalculation when the content
                        // of UI elements changes. This is a good place to do that.

                        NameText.Text = Vm.Model.Name;
                        NameText.SizeToFit();
                        NameText.Frame = new CGRect(140, 75, 170, NameText.Bounds.Height);
                    });

            this.SetBinding(
                () => Vm.Model.Description)
                .WhenSourceChanges(
                    () =>
                    {
                        DescriptionText.Text = Vm.Model.Description;
                        DescriptionText.SizeToFit();
                        DescriptionText.Frame = new CGRect(
                            0,
                            0,
                            Scroll.Bounds.Width - 20,
                            DescriptionText.Bounds.Height);

                        Scroll.ContentSize = new CGSize(Scroll.Bounds.Width - 20, DescriptionText.Bounds.Height + 20);
                        Scroll.SetNeedsLayout();
                    });

            SeeCommentsButton.TouchUpInside += (s, e) =>
            {
                var nav = ServiceLocator.Current.GetInstance<INavigationService>();
                nav.NavigateTo(AppDelegate.SeeCommentsPageKey, Vm);
            };

            base.ViewDidLoad();
        }
Ejemplo n.º 5
0
        public DetailsPage(FlowerViewModel flower)
        {
            InitializeComponent();

            BindingContext = flower;

            ShowCommentsButton.Clicked += (s, e) =>
            {
                var nav = ServiceLocator.Current.GetInstance<INavigationService>();
                nav.NavigateTo(App.ShowCommentsPageKey, BindingContext);
            };
        }
Ejemplo n.º 6
0
        private View GetFlowerAdapter(int position, FlowerViewModel flower, View convertView)
        {
            // Not reusing views here
            convertView = LayoutInflater.Inflate(Resource.Layout.FlowerTemplate, null);

            var title = convertView.FindViewById<TextView>(Resource.Id.NameTextView);
            title.Text = flower.Model.Name;

            var desc = convertView.FindViewById<TextView>(Resource.Id.DescriptionTextView);
            desc.Text = flower.Model.Description;

            var image = convertView.FindViewById<ImageView>(Resource.Id.FlowerImageView);
            ImageDownloader.AssignImageAsync(image, flower.Model.Image, this);

            return convertView;
        }
        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            _tableController = Vm.Model.Comments.GetController(
                CreateCommentCell,
                BindCommentCell);

            _tableController.TableView = CommentsTableView;

            AddCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
            NavigationItem.SetRightBarButtonItem(AddCommentButton, false);
            AddCommentButton.SetCommand("Clicked", Vm.AddCommentCommand);

            base.ViewDidLoad();
        }
        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            SaveCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, null);
            NavigationItem.SetRightBarButtonItem(SaveCommentButton, false);

            _commentBinding = this.SetBinding(
                () => CommentText.Text)
                .UpdateSourceTrigger("Changed");

            SaveCommentButton.SetCommand(
                "Clicked",
                Vm.SaveCommentCommand,
                _commentBinding);

            base.ViewDidLoad();
        }
Ejemplo n.º 9
0
 public AddCommentViewController(FlowerViewModel flower)
 {
     Vm = flower;
 }
Ejemplo n.º 10
0
 public DetailsViewController(FlowerViewModel flower)
 {
     Vm = flower;
 }
Ejemplo n.º 11
0
 public ShowCommentsPage(FlowerViewModel flower)
 {
     InitializeComponent();
     BindingContext = flower;
 }