Ejemplo n.º 1
0
        protected override void InitializeCell()
        {
            //	mUser = new UserClass ();
            mParent = MyDevice.rootPage;
            var mainRelativeLayout = new RelativeLayout(){
                Padding = 0,
                WidthRequest = MyDevice.GetScaledSize (630),
                HeightRequest = MyDevice.GetScaledSize (213),
            };
            categoryImage = new Image ()
            {
                WidthRequest = MyDevice.GetScaledSize (619),
                HeightRequest = MyDevice.GetScaledSize (202),
                /*CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,*/
            };
            //categoryImage.Success += (object sender, CachedImageEvents.SuccessEventArgs e) => {System.Diagnostics.Debug.WriteLine(category.CategoryImagePath);};

            var tapGestureRecognizer = new TapGestureRecognizer ();

            tapGestureRecognizer.Tapped +=async (sender, e) => {
                if(category.CategoryID == ReleaseConfig.TOBACCO_ID)
                {
                    var isOk = await mParent.DisplayAlert("Warning","I am over 20 years old and I know smoking is bad for my health.","AGREE","DISAGREE");
                    if(isOk)
                        mParent.LoadCategory(category);
                }else if(category.CategoryID == ReleaseConfig.FRUITS_ID||category.CategoryID == ReleaseConfig.MEAT_ID)
                {
                    await mParent.DisplayAlert("Please Remember","Delivered quantity might differ from the actual ordered quantity by ± 50 grams.","OK");

                    mParent.LoadCategory(category);
                }
                else
                    mParent.LoadCategory(category);
            };

            categoryImage.GestureRecognizers.Add (tapGestureRecognizer);

            mainRelativeLayout.Children.Add (categoryImage,
                Constraint.Constant (MyDevice.GetScaledSize(11)),
                Constraint.Constant (MyDevice.GetScaledSize(11))
            );

            this.View = mainRelativeLayout;
        }
Ejemplo n.º 2
0
        public CategoryCell(StackLayout parentGrid, Category category, RootPage parent = null)
        {
            mParent = parent;
            var mainRelativeLayout = new RelativeLayout(){
                Padding = 0
            };

            mCategory = category;
            mCategoryList = new List<Category> ();
            mProductDictionary = new Dictionary<string, List<Product>> ();
            mUser = new UserClass ();

            //System.Diagnostics.Debug.WriteLine (category.CategoryImagePath);

            CachedImage categoryImage = new CachedImage ()
            {
                WidthRequest = MyDevice.GetScaledSize (619),
                HeightRequest = MyDevice.GetScaledSize (202),
                Source = category.CategoryImagePath,//Source = category.CategoryImageName,
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
            };
            categoryImage.Success += (object sender, CachedImageEvents.SuccessEventArgs e) => {System.Diagnostics.Debug.WriteLine("aq");};
                /*
            if( mParent.mFolder.CheckExistsAsync(ProductModel.mRootFolderPath + "/" + ParseConstants.IMAGE_FOLDER_NAME + "/" + category.CategoryImageName).Result != PCLStorage.ExistenceCheckResult.NotFound)
                categoryImage.Source = ProductModel.mRootFolderPath + "/" + ParseConstants.IMAGE_FOLDER_NAME + "/" + category.CategoryImageName;
            else
                categoryImage.Source = ImageSource.FromResource("bluemart.SavedImages."+category.CategoryImageName);
            */
            /*Label shadowCategoryText = new Label (){
                FontSize = MyDevice.FontSizeMedium,
                BackgroundColor = Color.Transparent,
                TextColor = Color.Black,
                FontAttributes = FontAttributes.Bold,
                Text = category.Name
            };

            Label categoryText = new Label (){
                FontSize = MyDevice.FontSizeMedium,
                BackgroundColor = Color.Transparent,
                TextColor = Color.White,
                Text = category.Name
            };
            */
            var tapGestureRecognizer = new TapGestureRecognizer ();

            tapGestureRecognizer.Tapped +=async (sender, e) => {
                if(category.CategoryID == ReleaseConfig.TOBACCO_ID)
                {
                    var isOk = await mParent.DisplayAlert("Warning","I am over 20 years old and I know smoking is bad for my health.","AGREE","DISAGREE");
                    if(isOk)
                        LoadProductsPage(category.CategoryID,parent);
            }else if(category.CategoryID == ReleaseConfig.FRUITS_ID||category.CategoryID == ReleaseConfig.MEAT_ID)
            {
                await mParent.DisplayAlert("Please Remember","Delivered quantity might differ from the actual ordered quantity by ± 50 grams.","OK");

                    LoadProductsPage(category.CategoryID,parent);
            }
                else
                    LoadProductsPage(category.CategoryID,parent);
            };

            categoryImage.GestureRecognizers.Add (tapGestureRecognizer);

            mainRelativeLayout.Children.Add (categoryImage,
                Constraint.Constant (MyDevice.GetScaledSize(11)),
                Constraint.Constant (MyDevice.GetScaledSize(11))
            );
            /*mainRelativeLayout.Children.Add (shadowCategoryText,
                Constraint.RelativeToView (categoryImage, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize (12);
                }),
                Constraint.RelativeToView (categoryImage, (p, sibling) => {
                    return sibling.Bounds.Bottom - MyDevice.GetScaledSize (45);
                })
            );
            mainRelativeLayout.Children.Add (categoryText,
                Constraint.RelativeToView (categoryImage, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize (12);
                }),
                Constraint.RelativeToView (categoryImage, (p, sibling) => {
                    return sibling.Bounds.Bottom - MyDevice.GetScaledSize (45);
                })
            );*/

            this.View = mainRelativeLayout;
        }