Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ViewModelState.Initialise(new NavigationService(this), new DeviceIntegration(this));

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.MovieDetails);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            ViewModelMovieDetails viewModel = new ViewModelMovieDetails();

            viewModel.Initialise();

            SupportActionBar.Title     = viewModel.Title;
            viewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(ViewModelMovieDetails.Title))
                {
                    SupportActionBar.Title = viewModel.Title;
                }
            };

            new ConnectorImageView(FindViewById <ImageView>(Resource.Id.poster), viewModel, nameof(ViewModelMovieDetails.PosterURL));
            new ConnectorListView <ListItemMovieAttributeBase>(this, FindViewById <ListView>(Resource.Id.attributes), viewModel, nameof(ViewModelMovieDetails.Attributes), null,
                                                               (item) =>
            {
                if (item is ListItemMovieAttributeLabel)
                {
                    return(Resource.Layout.TemplateListItemAttributeLabel);
                }
                return(Resource.Layout.TemplateListItemAttributeValue);
            },
                                                               (context, item, view, parent) =>
            {
                LayoutInflater layoutInflator = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

                if (item is ListItemMovieAttributeLabel)
                {
                    ListItemMovieAttributeLabel label = (ListItemMovieAttributeLabel)item;

                    view = layoutInflator.Inflate(Resource.Layout.TemplateListItemAttributeLabel, parent, false);
                    view.FindViewById <TextView>(Resource.Id.listItemMovieAttributeLabel).Text = label.Label;
                }
                else
                {
                    ListItemMovieAttributeValue value = item as ListItemMovieAttributeValue;
                    view = layoutInflator.Inflate(Resource.Layout.TemplateListItemAttributeValue, parent, false);

                    view.FindViewById <TextView>(Resource.Id.listItemMovieAttributeValue).Text = value.Value;
                }

                return(view);
            });
            new ConnectorTextView(FindViewById <TextView>(Resource.Id.plot), viewModel, nameof(ViewModelMovieDetails.Plot));
            new ConnectorButton(FindViewById <Button>(Resource.Id.imdbWebsite), viewModel.CommandBrowseToMovie);
        }
Ejemplo n.º 2
0
        public PageMovieDetails()
        {
            InitializeComponent();

            ItemTemplateSelectorMovieAttributeType.LabelTemplate = Resources["ListItemMovieAttributeLabel"] as DataTemplate;
            ItemTemplateSelectorMovieAttributeType.ValueTemplate = Resources["ListItemMovieAttributeValue"] as DataTemplate;

            ViewModelMovieDetails viewModel = new ViewModelMovieDetails();

            DataContext = viewModel;
            viewModel.Initialise();
        }
Ejemplo n.º 3
0
 public ViewControllerMovieDetails(IntPtr handle) : base(handle)
 {
     _viewModel = new ViewModelMovieDetails();
     _viewModel.Initialise();
 }