public override void ViewDidLoad() { base.ViewDidLoad(); View.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions; View.BackgroundColor = UIColor.White; var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle(ratingStyle + "/empty"), filledImage: UIImage.FromBundle(ratingStyle + "/filled"), chosenImage: UIImage.FromBundle(ratingStyle + "/chosen")); // [Optional] Put a little space between the rating items. ratingConfig.ItemPadding = 5f; var ratingFrame = new CGRect(CGPoint.Empty, new CGSize(View.Bounds.Width, 125f));; ratingView = new PDRatingView(ratingFrame, ratingConfig); // [Optional] Set the current rating to display. decimal rating = 3.58m; //decimal halfRoundedRating = Math.Round(rating * 2m, MidpointRounding.AwayFromZero) / 2m; //decimal wholeRoundedRating = Math.Round(rating, MidpointRounding.AwayFromZero); ratingView.AverageRating = rating; // [Optional] Make it read-only to keep the user from setting a rating. //StarRating.UserInteractionEnabled = false; // [Optional] Attach to the rating event to do something with the chosen value. ratingView.RatingChosen += (sender, e) => { (new UIAlertView("Rated!", e.Rating.ToString() + " " + ratingStyle, null, "Ok")).Show(); }; View.Add(ratingView); }
public override void ViewDidLoad() { base.ViewDidLoad(); btnSend.SetTitleTextAttributes(new UITextAttributes { Font = UIFont.FromName("Avenir-Book", 14f), TextColor = UIColor.White }, UIControlState.Normal); btnSend.Clicked += delegate { viewModel.SendFeedback(); }; var ratingConfig = new RatingConfig(UIImage.FromBundle("emptyStar"), UIImage.FromBundle("filledStar"), UIImage.FromBundle("filledStar")); var uiRatingView = new PDRatingView(new CGRect(30, 10, userInterfaceRatingPlaceholder.Frame.Width - 60, userInterfaceRatingPlaceholder.Frame.Height - 20), ratingConfig); uiRatingView.RatingChosen += delegate { viewModel.UserInterfaceRating = (int) uiRatingView.ChosenRating; }; userInterfaceRatingPlaceholder.Add(uiRatingView); var beerSelectionRatingView = new PDRatingView(new CGRect(30, 10, beerSelectionRatingPlaceholder.Frame.Width - 60, beerSelectionRatingPlaceholder.Frame.Height - 20), ratingConfig); beerSelectionRatingView.RatingChosen += delegate { viewModel.BeerSelectionRating = (int) beerSelectionRatingView.ChosenRating; }; tbxFeedback.Changed += delegate { viewModel.Feedback = tbxFeedback.Text; }; tbxFeedback.Started += delegate { var isDefault = tbxFeedback.Text.Contains("Write your feedback"); if (isDefault) tbxFeedback.Text = string.Empty; }; beerSelectionRatingPlaceholder.Add(beerSelectionRatingView); }
public SampleTableViewControllerCell() : base(UITableViewCellStyle.Value1, Key) { AutoresizingMask = UIViewAutoresizing.FlexibleDimensions; BackgroundColor = UIColor.White; var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/empty"), filledImage: UIImage.FromBundle("Stars/filled"), chosenImage: UIImage.FromBundle("Stars/chosen")); ratingView = new PDRatingView(new CGRect(CGPoint.Empty, ContentView.Bounds.Size), ratingConfig); ratingView.UserInteractionEnabled = false; ContentView.Add(ratingView); }
public void Bind (Movie movie, ConfigurationResponse configuration) { this.data = movie; this.configuration = configuration; this.vwFavoriteIndicator.Hidden = !Data.Current.IsInFavorites (this.data); var spotlightUri = new Uri (String.Concat (this.configuration.Images.BaseUrl, this.configuration.Images.BackdropSizes [0], this.data.BackdropPath)); this.imgPoster.Image = ImageLoader.DefaultRequestImage (spotlightUri, this); this.lblTitle.Text = this.data.Title; this.lblReleaseDate.Text = String.Format ("Released in {0}", this.data.ReleaseDate.Year); var ratingConfig = new RatingConfig(UIImage.FromBundle("star_empty"), UIImage.FromBundle("star_filled"), UIImage.FromBundle("star_filled")); var averageRating = (decimal)this.data.VoteAverage / 2; this.ratingView = new PDRatingView (new CGRect(0f, 0f, this.vwVoteAverageContainer.Frame.Width, this.vwVoteAverageContainer.Frame.Height), ratingConfig, averageRating); this.vwVoteAverageContainer.Add(this.ratingView); }
public override void ViewDidLoad() { viewModel = ServiceLocator.Instance.Resolve<ICheckInViewModel>(); logger = ServiceLocator.Instance.Resolve<IAppInsights>(); lblBeerName.Text = beer.Name; lblDate.Text = DateTime.Now.ToString("M"); starView.BackgroundColor = ratingView.BackgroundColor; RatingConfig ratingConfig = new RatingConfig(UIImage.FromFile("star_blue_empty.png"),UIImage.FromFile("star_blue_filled.png"), UIImage.FromFile("star_blue_filled.png")); decimal averageRating = 3; var starsView = new PDRatingView(starView.Bounds, ratingConfig, averageRating); starsView.Center = new CoreGraphics.CGPoint(View.Center.X -10, starView.Frame.Y +10); starsView.RatingChosen += (sender, e) => { rating = e.Rating; }; starView.Add(starsView); starView.LayoutSubviews(); }
private async void updateLayout () { this.btnPlay.Alpha = 0; this.vwSimilarMovies.Alpha = 0; if (this.MovieDetail != null) { var videoResponse = await Data.Current.GetVideosForMovieAsync (this.MovieDetail.Id); if (videoResponse != null && videoResponse.Results != null) { this.videos = videoResponse.Results; if (videoResponse.Results.Count > 0 && videoResponse.Results [0].Site.ToLower () == "youtube") UIView.Animate (0.3f, () => this.btnPlay.Alpha = 1.0f); else UIView.Animate (0.3f, () => this.btnPlay.Alpha = 0.0f); } var similarMoviesResponse = await Data.Current.GetSimilarForMovieAsync (this.MovieDetail.Id); if (similarMoviesResponse != null && similarMoviesResponse.Results != null) { this.similarMovies = similarMoviesResponse.Results; if (similarMoviesResponse.Results.Count == 0) UIView.Animate(0.3f, () => this.vwSimilarMovies.Alpha = 0.0f); else { if (this.collectionViewSource == null) { this.collectionViewSource = new MovieCollectionViewSource (this.similarMovies, this.Configuration); this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected; this.cvSimilarMovies.Source = this.collectionViewSource; this.cvSimilarMovies.ReloadData (); } else { this.collectionViewSource.Reload (this.similarMovies); this.cvSimilarMovies.ReloadData (); } this.updateSimilarMoviesLayout (); UIView.Animate(0.3f, () => this.vwSimilarMovies.Alpha = 1.0f); } } this.lblTitle.Text = this.MovieDetail.Title; this.lblReleaseDate.Text = String.Format ("Release Date: {0}", this.MovieDetail.ReleaseDate.ToShortDateString ()); var ratingConfig = new RatingConfig(UIImage.FromBundle("star_empty"), UIImage.FromBundle("star_filled"), UIImage.FromBundle("star_filled")); var averageRating = (decimal)this.MovieDetail.VoteAverage / 2; this.ratingView = new PDRatingView (new CGRect(0f, 0f, this.vwVoteAverageContainer.Frame.Width, this.vwVoteAverageContainer.Frame.Height), ratingConfig, averageRating); this.vwVoteAverageContainer.Add(this.ratingView); this.lblVoteCount.Text = String.Format ("(from {0} votes)", this.MovieDetail.VoteCount.ToString ()); this.tvOverview.Text = this.MovieDetail.Overview; this.tvOverviewHeightConstraint.Constant = this.tvOverview.SizeThatFits (new CGSize (this.tvOverview.Frame.Width, float.MaxValue)).Height; var posterUri = new Uri (String.Concat (this.Configuration.Images.BaseUrl, this.Configuration.Images.PosterSizes[1], this.MovieDetail.PosterPath)); this.imgPoster.Image = ImageLoader.DefaultRequestImage (posterUri, this); this.btnBack.Hidden = this.NavigationController.ViewControllers.Length < 3; this.startPulseBackground (); this.updateSaveButtonState (); } }
public RatingItemView(UIImage emptyImage, UIImage filledImage, UIImage chosenImage, PDRatingView parentView) { _parentView = parentView; UserInteractionEnabled = false; MultipleTouchEnabled = true; AutoresizingMask = UIViewAutoresizing.FlexibleDimensions; EmptyImageView = new UIImageView(emptyImage) { AutoresizingMask = UIViewAutoresizing.FlexibleDimensions, UserInteractionEnabled = false, }; Add(EmptyImageView); FilledImageView = new UIImageView(filledImage) { AutoresizingMask = UIViewAutoresizing.FlexibleDimensions, UserInteractionEnabled = false, }; FilledImageViewSizingHolder = new UIView() { UserInteractionEnabled = false, }; FilledImageViewSizingHolder.Add(FilledImageView); FilledImageViewObscuringWrapper = new UIView() { ClipsToBounds = true, UserInteractionEnabled = false, }; FilledImageViewObscuringWrapper.Add(FilledImageViewSizingHolder); Add(FilledImageViewObscuringWrapper); SelectedImageView = new UIImageView(chosenImage) { AutoresizingMask = UIViewAutoresizing.FlexibleDimensions, UserInteractionEnabled = false, }; Add(SelectedImageView); PercentFilled = 0; }