public MyReviewCellView(NSString cellId) : base(UITableViewCellStyle.Default, cellId)
        {
            try
            {
                btnBack = new UIButton();
                btnBack.BackgroundColor        = UIColor.FromRGB(63, 63, 63);
                btnBack.UserInteractionEnabled = false;
                SelectionStyle             = UITableViewCellSelectionStyle.Gray;
                imageView                  = new UIButton();
                imageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                imageView.ContentMode      = UIViewContentMode.Center;
                imageView.ClipsToBounds    = true;
                //imageView.TouchDown += (object sender, EventArgs e) =>
                //{
                //	BTProgressHUD.Show("Loading...");
                //};
                imageView.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BTProgressHUD.Show(LoggingClass.txtloading);
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                Review review = new Review();
                separator = new UIImageView();

                btnItemname = new UIButton();
                btnItemname.SetTitle("", UIControlState.Normal);
                btnItemname.SetTitleColor(UIColor.FromRGB(127, 51, 0), UIControlState.Normal);
                btnItemname.Font                = UIFont.FromName("Verdana-Bold", 13f);
                btnItemname.LineBreakMode       = UILineBreakMode.WordWrap;
                btnItemname.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                btnItemname.TouchUpInside      += delegate
                {
                    BTProgressHUD.Show("Loading...");
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                ReviewDate = new UILabel()
                {
                    Font      = UIFont.FromName("AmericanTypewriter", 10f),
                    TextColor = UIColor.FromRGB(38, 127, 200),
                    //TextAlignment = UITextAlignment.Center,
                    BackgroundColor = UIColor.Clear
                };
                Comments = new UITextView()
                {
                    Font          = UIFont.FromName("AmericanTypewriter", 14f),
                    TextColor     = UIColor.FromRGB(55, 127, 0),
                    TextAlignment = UITextAlignment.Justified,
                    //TextAlignment = UITextAlignment.Natural,
                    BackgroundColor = UIColor.Clear,
                    //LineBreakMode = UILineBreakMode.WordWrap
                    Editable   = false,
                    Selectable = false
                };
                ReadMore = new UIButton()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    BackgroundColor = UIColor.White
                };
                Vintage = new UILabel()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    TextColor       = UIColor.FromRGB(127, 51, 100),
                    BackgroundColor = UIColor.Clear
                };
                decimal averageRating = 0.0m;
                var     ratingConfig  = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/star-silver2.png"),
                                                         filledImage: UIImage.FromBundle("Stars/star.png"),
                                                         chosenImage: UIImage.FromBundle("Stars/star.png"));
                stars   = new PDRatingView(new CGRect(110, 60, 60, 20), ratingConfig, averageRating);
                btnEdit = new UIButton();
                btnEdit.SetImage(UIImage.FromFile("edit.png"), UIControlState.Normal);
                btnEdit.TouchUpInside += (sender, e) =>
                {
                    PopupView yourController = new PopupView(WineIdLabel.Text, storeid);
                    yourController.NavController  = NavController;
                    yourController.parent         = Parent;
                    yourController.StartsSelected = stars.AverageRating;
                    yourController.Comments       = Comments.Text;
                    LoggingClass.LogInfo("Edited the review of " + wineId, screenid);


                    //yourController.WineId = Convert.ToInt32(WineIdLabel.Text);
                    yourController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                    //this.PresentViewController(yourController, true, null);
                    Parent.PresentModalViewController(yourController, false);
                };
                btnDelete = new UIButton();
                btnDelete.SetImage(UIImage.FromFile("delete.png"), UIControlState.Normal);
                btnDelete.TouchUpInside += (sender, e) =>
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Delete Review ",
                        Message = LoggingClass.txtdeletereview,
                    };
                    alert.AddButton("Yes");
                    alert.AddButton("No");

                    alert.Clicked += async(senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 0)
                        {
                            review.Barcode      = WineIdLabel.Text;
                            review.ReviewUserId = Convert.ToInt32(CurrentUser.RetreiveUserId());
                            BTProgressHUD.Show("Deleting review");
                            await sw.DeleteReview(review);

                            LoggingClass.LogInfo("Deleting the review of " + wineId, screenid);
                            BTProgressHUD.ShowSuccessWithStatus("Done");
                            ((IPopupParent)Parent).RefreshParent();
                        }
                    };

                    alert.Show();
                };
                btnLike = new UIButton();
                btnLike.ClipsToBounds              = true;
                btnLike.Layer.BorderColor          = UIColor.White.CGColor;
                btnLike.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                btnLike.Tag = 0;
                //myItem = new Item();
                //bool count =Convert.ToBoolean( myItem.IsLike);
                //if (count == true)
                //{
                //btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);}
                //else
                //{
                //	btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                //}
                btnLike.TouchUpInside += async(object sender, EventArgs e) =>
                {
                    try
                    {
                        UIButton temp = (UIButton)sender;
                        if (temp.Tag == 0)
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                            temp.Tag   = 1;
                            Data.Liked = 1;
                            //btnLike.Tag = 1;
                            LoggingClass.LogInfo("Liked Wine " + WineIdLabel.Text, screenid);
                        }
                        else
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                            temp.Tag   = 0;
                            Data.Liked = 0;

                            LoggingClass.LogInfo("Unliked Wine " + WineIdLabel.Text, screenid);
                        }
                        SKULike like = new SKULike();
                        like.UserID  = Convert.ToInt32(CurrentUser.RetreiveUserId());
                        like.BarCode = WineIdLabel.Text;
                        like.Liked   = Convert.ToBoolean(temp.Tag);

                        Data.Liked = Convert.ToInt32(temp.Tag);
                        await sw.InsertUpdateLike(like);
                    }
                    catch (Exception ex)
                    {
                        LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
                    }
                };
                WineIdLabel = new UILabel();
                ContentView.AddSubviews(new UIView[] { btnBack, btnItemname, ReadMore, ReviewDate, Comments, stars, imageView, Vintage, separator, btnEdit, btnDelete, btnLike });
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.View.BackgroundColor = new UIColor(0, 0, 0, 0.8f);

            var lblProducer = new UILabel();

            lblProducer.Frame           = new CGRect(4, 180, View.Frame.Width - 8, 30);
            lblProducer.Text            = "My Tasting";
            lblProducer.BackgroundColor = UIColor.Purple;
            lblProducer.TextAlignment   = UITextAlignment.Center;
            this.View.AddSubview(lblProducer);

            //this.View.Alpha = 0.5f;
            UIButton btnClose = new UIButton(new CGRect(9, 185, 20, 20));

            btnClose.SetBackgroundImage(new UIImage("Close.png"), UIControlState.Normal);
            this.View.AddSubview(btnClose);

            btnClose.TouchUpInside += (sender, e) =>
            {
                //var viewCtrl = NavController.PopViewController(false);
                //viewCtrl.Dispose();
                //NavController.PopToViewController(parent,false);
                NavController.DismissViewController(true, null);
            };

            UIImageView imgBtl = new UIImageView(new CGRect(View.Frame.Width - 64, 149, 60, 60));

            imgBtl.Image = UIImage.FromFile("wine_review.png");
            //imgBtl.BackgroundColor = UIColor.White;
            this.View.AddSubview(imgBtl);

            var lblWhite = new UILabel();

            lblWhite.Frame           = new CGRect(4, 210, View.Frame.Width - 8, 200);
            lblWhite.BackgroundColor = UIColor.White;
            lblWhite.TextAlignment   = UITextAlignment.Center;
            this.View.AddSubview(lblWhite);

            UIButton btnYes    = new UIButton(new CGRect(14, 340, View.Frame.Width - 28, 20));
            UIButton btnCancel = new UIButton(new CGRect(14, 340, View.Frame.Width - 30, 20));

            //btnSave.SetBackgroundImage(new UIImage("Close.png"), UIControlState.Normal);
            btnCancel.SetTitle("Cancel", UIControlState.Normal);
            btnCancel.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            btnCancel.SetTitleColor(UIColor.Purple, UIControlState.Normal);

            btnYes.SetTitle("Delete", UIControlState.Normal);
            btnYes.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            btnYes.SetTitleColor(UIColor.Purple, UIControlState.Normal);

            this.View.AddSubview(btnYes);
            this.View.AddSubview(btnCancel);
            btnCancel.TouchUpInside += (sender, e) =>
            {
                NavController.DismissViewController(true, null);
            };

            btnYes.TouchUpInside += async delegate
            {
                ServiceWrapper sw     = new ServiceWrapper();
                Review         review = new Review();
                review.WineId       = WineId;
                review.ReviewUserId = Convert.ToInt32(CurrentUser.RetreiveUserId());
                ((IPopupParent)parent).RefreshParent();
                await sw.DeleteReview(review);

                //myDialog.Dismiss();
            };
            //btnDelete.TouchDown += async delegate
            //{

            //	review.WineId = WineId;
            //	review.ReviewUserId = Convert.ToInt32(CurrentUser.RetreiveUserId());
            //	await sw.DeleteReview(review);

            //	((IPopupParent)parent).RefreshParent();

            //	NavController.DismissViewController(true, null);
            //Save Service Call.
            //txtComments
            //	BTProgressHUD.ShowSuccessWithStatus("Thank you!!!");
            //};
        }