public EventDetailXAMLView(EventDetailViewModel vm)
        {
            VM             = vm ?? new EventDetailViewModel();
            BindingContext = VM;

            InitializeComponent();
        }
Example #2
0
        public CalendarioPage(CalendarioPageVM vm)
        {
            VM             = vm ?? new CalendarioPageVM();
            VM.UIPage      = this;
            BindingContext = VM;

            var calendar = new SfSchedule {
                ShowAppointmentsInline = true,
                ScheduleView           = ScheduleView.WeekView
            };

            #region Customization
            var headerStyle = new HeaderStyle();
            //headerStyle.TextSize = 15;
            //headerStyle.TextStyle
            headerStyle.TextColor = Color.Black;
            calendar.HeaderStyle  = headerStyle;
            #endregion

            ScheduleAppointmentMapping dataMapping = new ScheduleAppointmentMapping();
            dataMapping.SubjectMapping   = nameof(GoogleEventVM.Title);
            dataMapping.StartTimeMapping = nameof(GoogleEventVM.StartDate);
            dataMapping.EndTimeMapping   = nameof(GoogleEventVM.EndDate);
            dataMapping.ColorMapping     = nameof(GoogleEventVM.BackgroundColor);
            calendar.AppointmentMapping  = dataMapping;

            calendar.ScheduleCellTapped += async(object sender, ScheduleTappedEventArgs args) =>
            {
                var data   = args;
                var fine   = args.datetime.Add(TimeSpan.FromMinutes(calendar.TimeInterval));
                var events = VM.GetEventsFromDateTime(args.datetime, TimeSpan.FromMinutes(calendar.TimeInterval));
                if (events != null && events.Count > 0)
                {
                    var IsNuovoEvento       = false;
                    var stringaCrea         = "Crea evento";
                    var eventiListaStringhe = events.Select(x => x.Name).ToList();
                    eventiListaStringhe.Add(stringaCrea);

                    var stringaScelta = await DisplayActionSheet("Quale evento?", "Nessuno", null, eventiListaStringhe.ToArray());

                    if (stringaScelta == stringaCrea)
                    {
                        IsNuovoEvento = true;
                        await DoCrea(args.datetime, fine);

                        return;
                    }


                    var eventoScelto = VM.EventsObj.FirstOrDefault(x => x.Name == stringaScelta);
                    if (eventoScelto != null)
                    {
                        if (App.VM.user != null)
                        {
                            //se è modificabile, aprilo in edit
                            var eventoInterno = VM.EventiInterniObj.FirstOrDefault(x => x.data.RelatedGoogleEventID == eventoScelto.ID);
                            if (IsNuovoEvento || (eventoInterno != null && eventoInterno.data.RelatedOwnerGuid == App.VM.user.Guid))
                            {
                                var pageEditVM = new EventDetailEditVM {
                                    CalendarioVM = VM, ObjEvent = eventoScelto, ObjInternalEvent = eventoInterno,
                                    ObjAllEvents = VM.EventsObj
                                };
                                pageEditVM.DownloadData(false).ContinueWith(delegate {
                                    pageEditVM.UpdateVM();
                                });
                                await Navigation.PushAsync(new EventDetailViewEdit(pageEditVM));
                            }
                            else
                            {                              //altrimenti, aprilo in read only
                                var pageViewVM = new EventDetailViewModel {
                                    ObjEvent = eventoScelto
                                };
                                pageViewVM.DownloadData().ContinueWith(delegate
                                {
                                    pageViewVM.UpdateVM();
                                });
                                await Navigation.PushAsync(new EventDetailView(pageViewVM));
                            }
                        }
                        else
                        {                          //altrimenti, aprilo in read only
                            var pageViewVM = new EventDetailViewModel {
                                ObjEvent = eventoScelto
                            };
                            pageViewVM.UpdateVM();                             //non c'è bisogno qui di fare il download data perchè già ho gli oggetti interi che sto passando
                            await Navigation.PushAsync(new EventDetailView(pageViewVM));
                        }
                    }
                    else
                    {
                        //se non ho scelto nessun evento torna indietro
                        return;
                    }
                }
                else if (events == null || events.Count == 0)
                {
                    //se non ci sono già eventi in questa fascia oraria, permettine la creazione
                    await DoCrea(args.datetime, fine);
                }
            };
            //var listaVacanze = new List<DateTime> { };
            //listaVacanze.Add(DateTime.Now);
            //calendar.BlackoutDates = listaVacanze;

            calendar.SetBinding(SfSchedule.DataSourceProperty, new Binding(nameof(CalendarioPageVM.Items)));


            var loadingText = new Label {
                Text = "Caricamento in corso", HorizontalTextAlignment = TextAlignment.Center
            };
            loadingText.SetBinding(View.IsVisibleProperty, nameof(ViewModelBase.IsLoadingData));

            var grid = new Grid {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                }
            };
            grid.AddChild(loadingText, 0, 0);
            grid.AddChild(calendar, 1, 0);
            this.Content = grid;
        }
Example #3
0
        public EventsPage(EventsPageVM vm)
        {
            VM = vm; BindingContext = VM;
            var listPoints = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                IsPullToRefreshEnabled = true,
                //RowHeight=250,
                HasUnevenRows   = true,
                BackgroundColor = EventsPageVM.ColoreSfondoLista
            };

            listPoints.ItemTemplate = new DataTemplate(typeof(EventCellView));
            listPoints.SetBinding(ListView.ItemsSourceProperty, new Binding(nameof(EventsPageVM.Events)));

            listPoints.SetBinding(ListView.IsRefreshingProperty, new Binding(nameof(EventsPageVM.IsLoadingData)));

            listPoints.ItemTapped += (sender, e) =>
            {
                var item = (EventCellVM)e.Item; if (item == null)
                {
                    return;
                }
                listPoints.SelectedItem = null;

                var pageViewModel = new EventDetailViewModel {
                    ObjEvent = item.Obj
                };
                pageViewModel.UpdateVM();
                Navigation.PushAsync(new EventDetailView(pageViewModel));
            };
            listPoints.Refreshing += async(sender, e) =>
            {
                await VM.DownloadData().ContinueWith(delegate {
                    VM.UpdateVM();
                });

                listPoints.IsRefreshing = false;
            };

            var loading = new ActivityIndicator {
                IsRunning = false, IsVisible = false
            };

            loading.Bind(nameof(ViewModelBase.IsLoadingData));
            loading.BindingContext = VM;

            var labelListaVuota = new Label {
                Text = "Non ci sono ancora elementi qui", FontAttributes = FontAttributes.Italic, HorizontalOptions = LayoutOptions.Center
            };

            labelListaVuota.SetBinding(View.IsVisibleProperty, new Binding(nameof(ViewModelBase.IsListEmpty)));
            Title = "Eventi";

            Content = new StackLayout
            {
                Children =
                {
                    loading,
                    labelListaVuota,
                    listPoints,
                }
            };
        }
Example #4
0
        public EventDetailView(EventDetailViewModel vm)
        {
            VM             = vm ?? new EventDetailViewModel();
            VM.UIPage      = this;
            BindingContext = VM;

            var stackIntero = new StackLayout {
                Orientation = StackOrientation.Vertical
            };
            var image = new Image {
            };

            image.Bind(nameof(EventDetailViewModel.Img));

            var grigliaData = new Grid {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition {
                        Width = GridLength.Star
                    },
                    new ColumnDefinition {
                        Width = GridLength.Star
                    },
                }
            };

            var labelDataInizio = new Label {
                TextColor = Color.Navy
            };

            labelDataInizio.Bind(nameof(EventDetailViewModel.StartTime));

            var labelDurata = new Label {
                TextColor = Color.Navy, HorizontalTextAlignment = TextAlignment.End,
            };

            labelDurata.Bind(nameof(EventDetailViewModel.EndTime));

            grigliaData.AddChild(labelDataInizio, 0, 0);
            grigliaData.AddChild(labelDurata, 0, 1);

            var labelTitolo = new Label {
                TextColor = Color.Black,
                FontSize  = 30
            };

            labelTitolo.Bind(nameof(EventDetailViewModel.Title));

            var labelDescrizione = new Label
            {
                TextColor = Color.Black,
                FontSize  = 25
            };

            labelDescrizione.Bind(nameof(EventDetailViewModel.Description));

            stackIntero.Children.Add(image);
            stackIntero.Children.Add(grigliaData);
            stackIntero.Children.Add(labelTitolo);
            stackIntero.Children.Add(labelDescrizione);

            var scroller = new ScrollView {
                Content = stackIntero
            };

            Content = scroller;
        }