コード例 #1
0
        public async Task<bool> ToggleFavorite(Session session)
        {
            if(!Settings.Current.IsLoggedIn)
            {
                sessionQueued = session;
                DependencyService.Get<ILogger>().TrackPage(AppPage.Login.ToString(), "Favorite");
                MessagingService.Current.SendMessage(MessageKeys.NavigateLogin);
                return false;
            }

            sessionQueued = null;

            var store = DependencyService.Get<IFavoriteStore>();
            session.IsFavorite = !session.IsFavorite;//switch first so UI updates :)
            if (!session.IsFavorite)
            {
                DependencyService.Get<ILogger>().Track(EvolveLoggerKeys.FavoriteRemoved, "Title", session.Title);

                var items = await store.GetItemsAsync ();
                foreach (var item in items.Where (s => s.SessionId == session.Id)) 
                {
                    await store.RemoveAsync (item);
                }
            }
            else
            {
                DependencyService.Get<ILogger>().Track(EvolveLoggerKeys.FavoriteAdded, "Title", session.Title);
                await store.InsertAsync(new Favorite{ SessionId = session.Id });
            }

            Settings.Current.LastFavoriteTime = DateTime.UtcNow;
            return true;
        }
コード例 #2
0
        public SessionDetailsViewModel(INavigation navigation, Session session, IDevice device) : base(navigation)
        {
			this.device = device;
                Xamarin.Insights.Track($"DEVICE NAME:{device.Name}");
            Xamarin.Insights.Track($"FIRMWARE:{device.FirmwareVersion}");

            Session = session;
            if (Session.StartTime.HasValue)
                ShowReminder = !Session.StartTime.Value.IsTBA();
            else
                ShowReminder = false;
        }
コード例 #3
0
        public FeedbackPage(Session session)
        {
            InitializeComponent();

            BindingContext = vm = new FeedbackViewModel(Navigation, session);
            if (Device.OS != TargetPlatform.iOS)
                ToolbarDone.Icon = "toolbar_close.png";

            ToolbarDone.Command = new Command(async () =>
                {
                    if(vm.IsBusy)
                        return;

                    await Navigation.PopModalAsync();
                });
        }
コード例 #4
0
        void ExecuteFavoriteCommand(Session session)
        {
            MessagingService.Current.SendMessage<MessagingServiceQuestion>(MessageKeys.Question, new MessagingServiceQuestion
                {
                    Negative = "Cancel",
                    Positive = "Unfavorite",
                    Question = "Are you sure you want to remove this session from your favorites?",
                    Title = "Unfavorite Session",
                    OnCompleted = (async (result) =>
                        {
                            if(!result)
                                return;

                            var toggled = await FavoriteService.ToggleFavorite(session);
                            if(toggled)
                                await ExecuteLoadSessionsCommandAsync();
                        })
                });
            
        }
コード例 #5
0
        public SessionDetailsPage(Session session, IDevice device)
        {
            InitializeComponent();

            FavoriteButtonAndroid.Clicked += (sender, e) =>
            {
                Device.BeginInvokeOnMainThread(() => FavoriteIconAndroid.Grow());
            };
            FavoriteButtoniOS.Clicked += (sender, e) =>
            {
                Device.BeginInvokeOnMainThread(() => FavoriteIconiOS.Grow());
            };

            ListViewSpeakers.ItemSelected += async (sender, e) =>
                {
                    var speaker = ListViewSpeakers.SelectedItem as Speaker;
                    if (speaker == null)
                        return;

                    var speakerDetails = new SpeakerDetailsPage(vm.Session.Id, device);

                    speakerDetails.Speaker = speaker;
                    App.Logger.TrackPage(AppPage.Speaker.ToString(), speaker.FullName);
                    await NavigationService.PushAsync(Navigation, speakerDetails);
                    ListViewSpeakers.SelectedItem = null;
                };

            ButtonRate.Clicked += async (sender, e) =>
            {
                var title = this.ViewModel?.Session?.Title;
                Xamarin.Insights.Track("Rate Session", "SessionTitle", title);

                if (DemoHelper.ShouldThrowException
                    && (device.Name == "Nexus 5")
                    && device.FirmwareVersion == "6.0.1"
                   )
                {
                    try
                    {
                        throw new NotSupportedException();
                    }
                    catch (Exception ex)
                    {

                        Xamarin.Insights.Report(ex, Insights.Severity.Critical);
                        await Xamarin.Insights.PurgePendingCrashReports();
                        await Task.Delay(10000);
                        throw;
                    }
                    //throw new NotSupportedException("Second exception");

                }

                if (!Settings.Current.IsLoggedIn)
                {
                    DependencyService.Get<ILogger>().TrackPage(AppPage.Login.ToString(), "Feedback");
                    MessagingService.Current.SendMessage(MessageKeys.NavigateLogin);
                    return;
                }
                await NavigationService.PushModalAsync(Navigation, new EvolveNavigationPage(new FeedbackPage(ViewModel.Session)));
            };
            BindingContext = new SessionDetailsViewModel(Navigation, session, device);
            ViewModel.LoadSessionCommand.Execute(null);
        }
コード例 #6
0
 async Task ExecuteFavoriteCommandAsync(Session session)
 {
     var toggled = await FavoriteService.ToggleFavorite(session);
     if(toggled && Settings.Current.FavoritesOnly)
         SortSessions();
 }
コード例 #7
0
 public FeedbackViewModel(INavigation navigation, Session session) : base(navigation)
 {
     Session = session;
 }