private View CreateText(ScheduleItemViewModel model) { if (string.IsNullOrWhiteSpace(model.ItemMediaUrl)) { return(null); // hide if not defined } var label = new Label() { BindingContext = model, Padding = 20 }; var labelStyle = Application.Current.Resources.GetOrNull("TextScheduleItemLabelStyle"); if (labelStyle != null) { label.Style = (Style)labelStyle; } // text is in the url field label.SetBinding(Label.TextProperty, nameof(model.ItemMediaUrl)); return(new Frame() { Content = label, HeightRequest = MediaHeight - 40, Padding = 0, Margin = new Thickness(40, 20), CornerRadius = 50, HasShadow = false, IsClippedToBounds = true, }); }
public async Task <ScheduleItemViewModel> GetScheduleItem(int scheduleId) { ScheduleDetail detail = await _sheduleDataStore.GetItemAsync(scheduleId); ScheduleItemViewModel scheduleItemViewModel = AddScheduleItem(detail); return(scheduleItemViewModel); }
private static ScheduleItemViewModel GetScheduleItemViewModel() { var scheduleDetail = new ScheduleItemViewModel() { }; return(scheduleDetail); }
public MultiChoiceUserEntryView(ScheduleItemViewModel model) { this.model = model; InitializeComponent(); BindingContext = model; InitializeFromModel(); picker.SelectedIndexChanged += (o, e) => UpdateAnswer(); otherEntry.TextChanged += OtherEntry_TextChanged; }
public void AnswerInitializedFromPrevious() { string previousAnswer = "test_answer"; ScheduleItem item = TextPromptItem.Build(); mockRepo.Setup(r => r.GetAnswer(item.ItemId)) .Returns(previousAnswer); ScheduleItemViewModel model = new ScheduleItemViewModel(item, mockRepo.Object); Assert.Equal(previousAnswer, model.Answer); }
public void NonRecordingVideoHasAutoPlay() { ScheduleItem item = VideoItem .WithRecordingEnabled(false) .Build(); ScheduleItemViewModel model = new ScheduleItemViewModel(item, mockRepo.Object) { ItemDisplayState = ScheduleItemStateType.Start }; Assert.True(model.VideoPlay); }
private Image CreateImage(ScheduleItemViewModel model, string urlPropertyName) { var image = new Image() { BindingContext = model, HeightRequest = MediaHeight, Aspect = Aspect.AspectFill }; image.SetBinding(Image.SourceProperty, urlPropertyName, BindingMode.Default, new StringToImageSourceConverter()); return(image); }
public SuggestUserEntryView(ScheduleItemViewModel model) { this.model = model; InitializeComponent(); BindingContext = model; InitializeFromModel(); suggestBox.TextChanged += SuggestBox_TextChanged; suggestBox.SuggestionChosen += SuggestBox_SuggestionChosen; suggestBox.QuerySubmitted += SuggestBox_QuerySubmitted; otherEntry.TextChanged += OtherEntry_TextChanged; }
private static List <ScheduleItemViewModel> GetScheduleList() { List <ScheduleItemViewModel> scheduleItemList = new List <ScheduleItemViewModel>(); List <ScheduleDetail> scheduleDetailList = ScheduleDetails; foreach (ScheduleDetail detail in scheduleDetailList) { ScheduleItemViewModel scheduleItemViewModel = AddScheduleItem(detail); scheduleItemList.Add(scheduleItemViewModel); } return(scheduleItemList); }
public void VideoResetInvokedOnChangeToStart() { ScheduleItem item = VideoItem .WithRecordingEnabled(true) .Build(); ScheduleItemViewModel model = new ScheduleItemViewModel(item, mockRepo.Object); model.ItemDisplayState = ScheduleItemStateType.Finish; Assert.Raises <EventArgs>( attach: handler => model.VideoReset += handler, detach: handler => model.VideoReset -= handler, testCode: () => model.ItemDisplayState = ScheduleItemStateType.Start ); }
private View CreateEntry(ScheduleItemViewModel model) { var entry = new Entry() { Margin = 20, BindingContext = model }; entry.SetBinding(Entry.TextProperty, nameof(model.Answer)); entry.TextChanged += (sender, e) => { Debug.WriteLine("Marking text entry modified"); model.AnswerModified = true; }; return(entry); }
private static ScheduleItemViewModel AddScheduleItem(ScheduleDetail detail) { ScheduleItemViewModel scheduleItemViewModel = new ScheduleItemViewModel(); scheduleItemViewModel.ScheduleId = detail.ScheduleDetailId; scheduleItemViewModel.ScheduleDate = detail.ScheduleDate; scheduleItemViewModel.Category = detail.ScheduleCategory; scheduleItemViewModel.ScheduleTime = detail.ScheduleTime; scheduleItemViewModel.RoomNumber = detail.RoomNumber; scheduleItemViewModel.UserStatus = detail.UserStatus; scheduleItemViewModel.Diagnosis = detail.Diagnosis; scheduleItemViewModel.ReferenceDetail = detail.ReferenceDetail; scheduleItemViewModel.ContactType = detail.ContactType; scheduleItemViewModel.DiagnosisGroup = detail.DiagnosisGroup; scheduleItemViewModel.HealthIssue = detail.HealthIssue; scheduleItemViewModel.TentativeDiagnosis = detail.TentativeDiagnosis; scheduleItemViewModel.ReferralReason = detail.ReferralReason; scheduleItemViewModel.LevelOfCare = detail.LevelOfCare; scheduleItemViewModel.UserInfo = new UserBasicInfoViewModel(); scheduleItemViewModel.UserInfo.UserId = detail.UserInfo.UserId; scheduleItemViewModel.UserInfo.FirstName = detail.UserInfo.FirstName; scheduleItemViewModel.UserInfo.LastName = detail.UserInfo.LastName; scheduleItemViewModel.UserInfo.Gender = detail.UserInfo.Gender; scheduleItemViewModel.UserInfo.Surname = detail.UserInfo.Surname; scheduleItemViewModel.UserInfo.ReferenceNumber = detail.UserInfo.ReferenceNumber; scheduleItemViewModel.UserInfo.ContactNumber = detail.UserInfo.ContactNumber; scheduleItemViewModel.UserInfo.Email = detail.UserInfo.Email; List <UserAppointmentsViewModel> appointmentsList = new List <UserAppointmentsViewModel>(); detail.UserAppointments.ForEach(c => appointmentsList.Add(new UserAppointmentsViewModel { AppointmentId = c.AppointmentId, DepartmentName = c.DepartmentName, AppointmentDescription = c.AppointmentDescription, AppointmentDateTime = c.AppointmentDate.Date == DateTime.Today ? "Today " + c.AppointmentDate.ToString("HH:mm") : c.AppointmentDate.Date.ToString("M.d") + " " + c.AppointmentDate.Date.ToString("HH:mm") })); scheduleItemViewModel.UserAppointments = appointmentsList; TimeSpan TS = DateTime.Now - detail.UserInfo.RegisteredDate; double years = TS.TotalDays / 365.25; scheduleItemViewModel.UserInfo.PatientSince = years + " Years"; return(scheduleItemViewModel); }
private View CreateVideo(ScheduleItemViewModel model) { var video = new VideoPlayer() { BindingContext = model, Source = new UriVideoSource(model.Item.Url), StartTime = model.Item.StartTime, EndTime = model.Item.EndTime, Play = model.VideoPlay, // this must be set after start and end time HeightRequest = MediaHeight }; var backgroundColor = Application.Current.Resources.GetOrNull("AppBackgroundColor"); if (backgroundColor != null) { video.BackgroundColor = (Color)backgroundColor; } // binding starts video when recording starts and stops when recording stops, // and this is also updated if app goes to background video.SetBinding(VideoPlayer.PlayProperty, nameof(model.VideoPlay)); if (model.IsRecordingEnabled) { video.IsMuted = true; // this event handler is removed in ScheduleItemViewModel.ClearAfterDisplay model.VideoReset += (o, e) => video.Reset(); var image = CreateImage(model, nameof(model.VideoItemImageUrl)); // overlay image on top of video, so if image is defined it will cover // video and we dont need to show/hide either Grid grid = new Grid(); grid.Children.Add(video); grid.Children.Add(image); return(grid); } else { video.IsMuted = false; return(video); } }
public async Task <List <ScheduleItemViewModel> > GetAllSchedules() { IEnumerable <ScheduleDetail> scheduleDetailList = await _sheduleDataStore.GetItemsAsync(); List <ScheduleItemViewModel> scheduleItemList = new List <ScheduleItemViewModel>(); if (scheduleDetailList != null) { foreach (ScheduleDetail detail in scheduleDetailList.ToList()) { ScheduleItemViewModel scheduleItemViewModel = AddScheduleItem(detail); scheduleItemList.Add(scheduleItemViewModel); } } return(scheduleItemList); }
public void VideoImageNullWhenNotDefined() { ScheduleItem item = VideoItem .WithStart(new ScheduleItemState()) .WithFinish(new ScheduleItemState()) .Build(); ScheduleItemViewModel model = new ScheduleItemViewModel(item, mockRepo.Object); model.ItemDisplayState = ScheduleItemStateType.Start; Assert.Null(model.VideoItemImageUrl); model.ItemDisplayState = ScheduleItemStateType.Recording; Assert.Null(model.VideoItemImageUrl); model.ItemDisplayState = ScheduleItemStateType.Finish; Assert.Null(model.VideoItemImageUrl); }
private View CreatePicker(ScheduleItemViewModel model) { var picker = new Picker() { Title = AppResources.ChooseOptionText, ItemsSource = model.ChoiceOptions, Margin = 20, BindingContext = model }; picker.SetBinding(Picker.SelectedItemProperty, nameof(model.Answer)); picker.SelectedIndexChanged += (sender, e) => { Debug.WriteLine("Marking picker modified"); model.AnswerModified = true; }; return(picker); }
public void VideoImageSetWhenDefined() { ScheduleItem item = VideoItem .WithStart(new ScheduleItemState() { ImageUrl = "start_url" }) .WithFinish(new ScheduleItemState() { ImageUrl = "end_url" }) .Build(); ScheduleItemViewModel model = new ScheduleItemViewModel(item, mockRepo.Object); model.ItemDisplayState = ScheduleItemStateType.Start; Assert.Equal(item.Start.ImageUrl, model.VideoItemImageUrl); model.ItemDisplayState = ScheduleItemStateType.Recording; Assert.Null(model.VideoItemImageUrl); model.ItemDisplayState = ScheduleItemStateType.Finish; Assert.Equal(item.Finish.ImageUrl, model.VideoItemImageUrl); }