CachedImage - Xamarin.Forms image replacement with caching and downsampling capabilities
Inheritance: Xamarin.Forms.View
		public ImagePopupPage (CachedImage robotImage, ParseObject teamData)
		{
			data = teamData;
			robotImage.Aspect = Aspect.Fill;

			//Back Button
			Button retakeImageBtn = new Button () {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "Retake Image",
				TextColor = Color.Green,
				BackgroundColor = Color.Black
			};
			retakeImageBtn.Clicked += (object sender, EventArgs e) => {
				OpenImagePicker();
			};

			//Back Button
			Button backBtn = new Button () {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "Back",
				TextColor = Color.Green,
				BackgroundColor = Color.Black
			};
			backBtn.Clicked += (object sender, EventArgs e) => {
				popUpReturn();
			};

			StackLayout navigationBtns = new StackLayout () {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Orientation = StackOrientation.Horizontal,
				BackgroundColor = Color.Green,
				Padding = 5,

				Children = {
					retakeImageBtn,
					backBtn
				}
			};

			layoutGrid.Children.Add(robotImage, 0, 2, 0, 1);
			layoutGrid.Children.Add(navigationBtns, 0, 2, 1, 2);

			this.Content = layoutGrid;
		}
		public ImagePopupPage (CachedImage robotImage)
		{
			robotImage.Aspect = Aspect.Fill;
			//Back Button
			Button backBtn = new Button () {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "Back",
				TextColor = Color.Green,
				BackgroundColor = Color.Black
			};
			backBtn.Clicked += (object sender, EventArgs e) => {
				popUpReturn();
			};

			layoutGrid.Children.Add(robotImage, 0, 2, 0, 1);
			layoutGrid.Children.Add(backBtn, 0, 2, 1, 2);

			this.Content = layoutGrid;
		}
		void addRobotImage(ParseObject teamData, int arrayIndex){
			try {
				if (teamData ["robotImage"].ToString() != null) {
					ParseFile robotImageURL = (ParseFile)teamData ["robotImage"];
					//Gets the image from parse and converts it to ParseFile

					robotImage[arrayIndex] = new CachedImage(){
						HorizontalOptions = LayoutOptions.Center,
						VerticalOptions = LayoutOptions.Center,
						Source = new UriImageSource{
							Uri = robotImageURL.Url,
							CachingEnabled = true,
							CacheValidity = new TimeSpan(7,0,0,0) //Caches Images onto your device for a week
						},
						HeightRequest = 120,
						DownsampleToViewSize = true
					};
					robotImageFull[arrayIndex] = new CachedImage(){
						Source = new UriImageSource{
							Uri = robotImageURL.Url,
							CachingEnabled = true,
							CacheValidity = new TimeSpan(7,0,0,0) //Caches Images onto your device for a week
						}
					};

					TapGestureRecognizer tap = new TapGestureRecognizer();
					tap.Tapped += (object sender, EventArgs e) => {
						// Create a gesture recognizer to display the popup image
						popUpPage(robotImageFull[arrayIndex]);
					};
					robotImage[arrayIndex].GestureRecognizers.Add (tap);
					robotImage[arrayIndex].Aspect = Aspect.AspectFit; 
				} else {}
			}
			catch {
				robotImage[arrayIndex].Source = "Placeholder_image_placeholder.png";
			}

			headerGrid.Children.Add (robotImage[arrayIndex], 2 * arrayIndex, 2 * (arrayIndex + 1 ), 1, 2);
		}
Beispiel #4
0
        public AddressCell(AddressClass address, SettingsPage rootPage)
        {
            mRootPage = rootPage;
            mAddressClass = address;

            var mainLayout = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(600),
                HeightRequest = MyDevice.GetScaledSize(122),
                Padding = 0
            };

            var backgroundImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(600),
                HeightRequest = MyDevice.GetScaledSize(122),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "SettingsPage_AddressCellBackground.png"
            };

            var editButton = new Label () {
                WidthRequest = MyDevice.GetScaledSize (48),
                HeightRequest = MyDevice.GetScaledSize(68),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.End,
                TextColor = Color.FromRgb(98,98,98),
                Text = "edit",
                FontSize = MyDevice.FontSizeMicro
            };

            mActiveAddressImage = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(82),
                HeightRequest = MyDevice.GetScaledSize(90),
                BackgroundColor = Color.White
            };

            var nameLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (300),
                HeightRequest = MyDevice.GetScaledSize(28),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = address.Name,
                FontSize = MyDevice.FontSizeSmall
            };

            var addressLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (360),
                HeightRequest = MyDevice.GetScaledSize(28),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = address.Address,
                FontSize = MyDevice.FontSizeSmall
            };

            var phoneLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (360),
                HeightRequest = MyDevice.GetScaledSize(28),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = address.PhoneNumber,
                FontSize = MyDevice.FontSizeSmall
            };

            var tapGestureRecognizer = new TapGestureRecognizer ();
            tapGestureRecognizer.Tapped += (sender, e) => {

                mAddressModel.MakeActive(mAddressClass);
                mRootPage.SwitchActiveAddress(this);

            };
            mainLayout.GestureRecognizers.Add (tapGestureRecognizer);

            var editTapGestureRecognizer = new TapGestureRecognizer ();
            editTapGestureRecognizer.Tapped += (sender, e) => {
                mRootPage.mParent.LoadAddAddress(mAddressClass);
            };
            editButton.GestureRecognizers.Add (editTapGestureRecognizer);

            mainLayout.Children.Add (backgroundImage,
                Constraint.Constant (0),
                Constraint.Constant (0)
            );

            mainLayout.Children.Add (editButton,
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize (26);
                }),
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize (26);
                })
            );

            mainLayout.Children.Add (mActiveAddressImage,
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Right - MyDevice.GetScaledSize (105);
                }),
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize (13);
                })
            );

            mainLayout.Children.Add (nameLabel,
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize (105);
                }),
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize (16);
                })
            );
            mainLayout.Children.Add (addressLabel,
                Constraint.RelativeToView (nameLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (nameLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                })
            );
            mainLayout.Children.Add (phoneLabel,
                Constraint.RelativeToView (addressLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (addressLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                })
            );

            mActiveAddressImage.IsVisible = !mAddressClass.IsActive;

            this.View = mainLayout;
        }
Beispiel #5
0
		private void InitializeMenuLayout()
		{
			mMenuLayout = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(mMenuWidth),
				HeightRequest = MyDevice.ScreenHeight,
				BackgroundColor = Color.FromRgb(51,51,51)
			};

			var openImage = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(54),
				HeightRequest = MyDevice.GetScaledSize(44),
				Source = "MenuPage_Open.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			categoriesLabel = new Label () {
				Text = "Categories",
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(400),
				HeightRequest = MyDevice.GetScaledSize(44)
			};

			var categoriesButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(512),
				HeightRequest = MyDevice.GetScaledSize(50)
			};

			var firstLine = new BoxView (){
				HeightRequest = 1,
				WidthRequest = MyDevice.GetScaledSize(mMenuWidth),
				Color = Color.FromRgb(129,129,129)
			};

			var settingsImage = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(40),
				HeightRequest = MyDevice.GetScaledSize(35),
				Source = "MenuPage_Settings.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			var settingsLabel = new Label () {
				Text = "My Profile",
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(400),
				HeightRequest = MyDevice.GetScaledSize(44)
			};

			var settingsButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(512),
				HeightRequest = MyDevice.GetScaledSize(50)
			};

			var favoritesImage = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(40),
				HeightRequest = MyDevice.GetScaledSize(35),
				Source = "MenuPage_Favorites.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			var favoritesLabel = new Label () {
				Text = "Favorites",
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(400),
				HeightRequest = MyDevice.GetScaledSize(44)
			};

			var favoritesButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(512),
				HeightRequest = MyDevice.GetScaledSize(50)
			};

			var trackImage = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(40),
				HeightRequest = MyDevice.GetScaledSize(35),
				Source = "MenuPage_Track.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			var trackLabel = new Label () {
				Text = "Track Your Order",
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(400),
				HeightRequest = MyDevice.GetScaledSize(44)
			};

			var trackButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(512),
				HeightRequest = MyDevice.GetScaledSize(50),
				Padding = 0
			};

			var trackTapRecognizer = new TapGestureRecognizer ();
			trackTapRecognizer.Tapped += (sender, e) => {
				mParent.LoadTrackPage();
			};
			trackButton.GestureRecognizers.Add (trackTapRecognizer);

			mMenuLayout.Children.Add (trackButton,
				Constraint.Constant(0),
				Constraint.RelativeToView (trackImage, (parent,sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(3);
				})
			);

			var secondLine = new BoxView (){
				HeightRequest = 1,
				WidthRequest = MyDevice.GetScaledSize(mMenuWidth),
				Color = Color.FromRgb(129,129,129)
			};

			var categoryNameStackLayout = new StackLayout {
				Orientation = StackOrientation.Vertical,
				Padding = 0,
				Spacing = 0
			};

			for (int i = 0; i < mParent.mBrowseCategoriesPage.mCategories.Count; i++) {
				if (!mParent.mBrowseCategoriesPage.mCategories [i].IsSubCategory) {
					Label label = new Label () {
						WidthRequest = MyDevice.GetScaledSize(442),	
						HeightRequest = MyDevice.GetScaledSize(78),
						TextColor = Color.White,
						HorizontalTextAlignment = TextAlignment.Start,
						VerticalTextAlignment = TextAlignment.Center,
						Text = mParent.mBrowseCategoriesPage.mCategories [i].Name,
						FontSize = MyDevice.FontSizeMedium
					};

					var tapRecog = new TapGestureRecognizer ();
					tapRecog.Tapped += async(sender, e) => {
						string categoryName = (sender as Label).Text;
						Category category = null;
						foreach(var tempCategory in mParent.mBrowseCategoriesPage.mCategories)
						{
							if(tempCategory.Name == categoryName)
							{
								category = tempCategory;
							}
						}
						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)
							{
								IsMenuOpen = false;
								MyDevice.rootPage.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");
							IsMenuOpen = false;
							MyDevice.rootPage.LoadCategory(category);										
						}
						else
						{
							IsMenuOpen = false;
							MyDevice.rootPage.LoadCategory(category);
						}
						/*
						foreach(var categoryCell in mParent.mBrowseCategoriesPage.mCategoryCellList)
						{
							if( category != null && categoryCell.mCategory == category )
							{
								IsMenuOpen = false;
								categoryCell.LoadProductsPage(category.CategoryID,mParent);
							}
						}*/

					};

					label.GestureRecognizers.Add (tapRecog);
					categoryNameStackLayout.Children.Add (label);	
				}
			}

			var categoryNameScrollView = new ScrollView {
				Orientation = ScrollOrientation.Vertical,
				Content = categoryNameStackLayout
			};

			var categoriesTapRecognizer = new TapGestureRecognizer ();
			categoriesTapRecognizer.Tapped += (sender, e) => {
				mParent.SwitchTab("BrowseCategories");
			};
			categoriesButton.GestureRecognizers.Add (categoriesTapRecognizer);

			var favoritesTapRecognizer = new TapGestureRecognizer ();
			favoritesTapRecognizer.Tapped += (sender, e) => {
				mParent.LoadFavoritesPage();
			};
			favoritesButton.GestureRecognizers.Add (favoritesTapRecognizer);

			var settingsTapRecognizer = new TapGestureRecognizer ();
			settingsTapRecognizer.Tapped += (sender, e) => {
				mParent.LoadSettingsPage();
			};
			settingsButton.GestureRecognizers.Add (settingsTapRecognizer);

			mainRelativeLayout.Children.Add (mMenuLayout,
				Constraint.Constant (MyDevice.GetScaledSize (mMenuWidth) * -1),
				Constraint.Constant (0)
			);

			mMenuLayout.Children.Add (openImage,				
				Constraint.Constant(MyDevice.GetScaledSize(16)),
				Constraint.RelativeToParent (parent => {
					return parent.Bounds.Top + MyDevice.GetScaledSize (20.59f);
				})
			);

			mMenuLayout.Children.Add (categoriesLabel,
				Constraint.RelativeToView (openImage, (parent,sibling) => {
					return sibling.Bounds.Right + MyDevice.GetScaledSize (10);
				}),
				Constraint.RelativeToView (openImage, (parent,sibling) => {
					return sibling.Bounds.Top;
				})
			);

			mMenuLayout.Children.Add (firstLine,
				Constraint.Constant(0),
				Constraint.RelativeToView (openImage, (parent,sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize(22);
				})
			);

			mMenuLayout.Children.Add (settingsImage,
				Constraint.RelativeToView (openImage, (parent,sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (9);
				}),
				Constraint.RelativeToView (firstLine, (parent,sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize (25);
				})
			);

			mMenuLayout.Children.Add (settingsLabel,
				Constraint.RelativeToView (settingsImage, (parent,sibling) => {
					return sibling.Bounds.Right + MyDevice.GetScaledSize (15);
				}),
				Constraint.RelativeToView (settingsImage, (parent,sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(4);
				})
			);

			mMenuLayout.Children.Add (favoritesImage,
				Constraint.RelativeToView (openImage, (parent,sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (9);
				}),
				Constraint.RelativeToView (settingsImage, (parent,sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize (46);
				})
			);

			mMenuLayout.Children.Add (favoritesLabel,
				Constraint.RelativeToView (favoritesImage, (parent,sibling) => {
					return sibling.Bounds.Right + MyDevice.GetScaledSize (15);
				}),
				Constraint.RelativeToView (favoritesImage, (parent,sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(4);
				})
			);

			mMenuLayout.Children.Add (trackImage,
				Constraint.RelativeToView (openImage, (parent,sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (9);
				}),
				Constraint.RelativeToView (favoritesImage, (parent,sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize (46);
				})
			);

			mMenuLayout.Children.Add (trackLabel,
				Constraint.RelativeToView (trackImage, (parent,sibling) => {
					return sibling.Bounds.Right + MyDevice.GetScaledSize (15);
				}),
				Constraint.RelativeToView (trackImage, (parent,sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(4);
				})
			);

			mMenuLayout.Children.Add (secondLine,
				Constraint.Constant(MyDevice.GetScaledSize(0)),
				Constraint.RelativeToView (trackImage, (parent,sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize(22);
				})
			);

			mMenuLayout.Children.Add (categoryNameScrollView,
				Constraint.Constant(MyDevice.GetScaledSize(76)),
				Constraint.RelativeToView (secondLine, (parent,sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize(22);
				}),
				Constraint.Constant(MyDevice.GetScaledSize(440)),
				Constraint.Constant(MyDevice.ScreenHeight - MyDevice.GetScaledSize(445))
			);

			mMenuLayout.Children.Add (categoriesButton,
				Constraint.Constant(0),
				Constraint.RelativeToView (openImage, (parent,sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(3);
				})
			);

			mMenuLayout.Children.Add (settingsButton,
				Constraint.Constant(0),
				Constraint.RelativeToView (settingsImage, (parent,sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(3);
				})
			);

			mMenuLayout.Children.Add (favoritesButton,
				Constraint.Constant(0),
				Constraint.RelativeToView (favoritesImage, (parent,sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(3);
				})
			);
		}
Beispiel #6
0
		private void InitializeSearchLayout()
		{
			mSearchLayout = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(640),
				HeightRequest = MyDevice.GetScaledSize(73),
				BackgroundColor = Color.FromRgb(27,184,105)
			};

			SearchEntry = new Entry () {
				WidthRequest = MyDevice.GetScaledSize(640),
				HeightRequest = MyDevice.GetScaledSize(73),
				Text = "Search",
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeMedium,
				HorizontalTextAlignment = TextAlignment.Start
			};

			var searchImage = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(583),
				HeightRequest = MyDevice.GetScaledSize(52),
				Source = "ProductsPage_SearchBar.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			var searchButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(444),
				HeightRequest = MyDevice.GetScaledSize(51)
			};
					

			var deleteButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(69),
				HeightRequest = MyDevice.GetScaledSize(51)
			};

			var backButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(65),
				HeightRequest = MyDevice.GetScaledSize(72)
			};					


			var searchEntryTapRecognizer= new TapGestureRecognizer ();
			searchEntryTapRecognizer.Tapped += (sender, e) => {				
				SearchEntry.Focus();
			};
			searchButton.GestureRecognizers.Add(searchEntryTapRecognizer);

			var deleteButtonTapRecognizer= new TapGestureRecognizer ();
			deleteButtonTapRecognizer.Tapped += (sender, e) => {				
				if( SearchEntry.Text.Length > 0 )
					SearchEntry.Text = SearchEntry.Text.Remove(SearchEntry.Text.Length - 1);
			};
			deleteButton.GestureRecognizers.Add(deleteButtonTapRecognizer);

			var backButtonTapRecognizer= new TapGestureRecognizer ();
			backButtonTapRecognizer.Tapped += (sender, e) => {				
				mParent.SwitchTab ("BrowseCategories");
			};
			backButton.GestureRecognizers.Add(backButtonTapRecognizer);


			mMidLayout.Children.Add (mSearchLayout,
				Constraint.Constant(0),
				Constraint.RelativeToView (mTopLayout, (parent, sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize (1);
				})
			);

			mMidLayout.Children.Add (searchImage,
				Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (28);
				}),
				Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
					return sibling.Bounds.Top + MyDevice.GetScaledSize (10);
				})
			);

			mMidLayout.Children.Add (SearchEntry,
				Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (136);
				}),
				Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
					return sibling.Bounds.Top + MyDevice.GetScaledSize (5);
				})
			);

			mMidLayout.Children.Add (searchButton,
				Constraint.RelativeToView (searchImage, (parent, sibling) => {
					return sibling.Bounds.Left;
				}),
				Constraint.RelativeToView (searchImage, (parent, sibling) => {
					return sibling.Bounds.Top;
				})
			);

			mMidLayout.Children.Add (deleteButton,
				Constraint.RelativeToView (searchImage, (parent, sibling) => {
					return sibling.Bounds.Right - MyDevice.GetScaledSize (67);
				}),
				Constraint.RelativeToView (searchImage, (parent, sibling) => {
					return sibling.Bounds.Top;
				})
			);

			mMidLayout.Children.Add (backButton,
				Constraint.Constant (0),
				Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
					return sibling.Bounds.Top;
				})
			);
		}
		void addRobotImage(){
			var imageTap = new TapGestureRecognizer ();
			imageTap.Tapped += (s, e) => {
				Console.WriteLine ("Tapped");
				OpenImagePicker ();
			};

			// RobotImage
			try {
				if (data ["robotImage"].ToString () != null) {
					ParseFile robotImageURL = (ParseFile)data ["robotImage"];
					// Gets the image from parse and converts it to ParseFile

					robotImage = new CachedImage(){
						HorizontalOptions = LayoutOptions.Center,
						VerticalOptions = LayoutOptions.Center,
						Source = new UriImageSource{
							Uri = robotImageURL.Url,
							CachingEnabled = true,
							CacheValidity = new TimeSpan(7,0,0,0) //Caches Images onto your device for a week
						},
						HeightRequest = 120,
						DownsampleToViewSize = true
					};
					robotImageFull = new CachedImage(){
						Source = new UriImageSource{
							Uri = robotImageURL.Url,
							CachingEnabled = true,
							CacheValidity = new TimeSpan(7,0,0,0) //Caches Images onto your device for a week
						}
					};

					TapGestureRecognizer tap = new TapGestureRecognizer();
					tap.Tapped += (object sender, EventArgs e) => {
						// Create a gesture recognizer to display the popup image
						popUpPage(robotImageFull);
					};
					robotImage.GestureRecognizers.Add (tap);
					robotImage.Aspect = Aspect.AspectFit; 
				} else {
				}
			} catch {
				robotImage.Source = "Placeholder_image_placeholder.png";
				robotImage.GestureRecognizers.Add (imageTap);
			}
			robotImage.Aspect = Aspect.AspectFit; //Need better way to scale an image while keeping aspect ratio, but not overflowing everything else
		}
Beispiel #8
0
        protected override void InitializeCell()
        {
            mainRelativeLayout = new RelativeLayout(){
                Padding = 0,
                WidthRequest = MyDevice.GetScaledSize (299),
                HeightRequest = MyDevice.GetScaledSize (377),
                BackgroundColor = Color.White
            };

            mProductImage = new Image ()
            {
                WidthRequest = MyDevice.GetScaledSize(250),
                HeightRequest = MyDevice.GetScaledSize(198),
                /*CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,*/

            };
            productNameLabel = new Label (){
                FontSize = MyDevice.FontSizeMicro - MyDevice.GetScaledSize(2),
                TextColor = Color.FromRgb(77,77,77),
                HorizontalTextAlignment=TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                WidthRequest = MyDevice.GetScaledSize(240),
                HeightRequest = MyDevice.GetScaledSize(60)
            };

            productQuantityLabel = new Label (){
                FontSize = MyDevice.FontSizeMicro,
                VerticalTextAlignment = TextAlignment.Start,
                HorizontalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb(176,176,176),
                WidthRequest = MyDevice.GetScaledSize(111),
                HeightRequest = MyDevice.GetScaledSize(22),
                //FontAttributes = FontAttributes.Italic
            };

            productPriceLabel = new Label (){
                FontSize = MyDevice.FontSizeMicro,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb(213,53,53),
                WidthRequest = MyDevice.GetScaledSize(111),
                HeightRequest = MyDevice.GetScaledSize(22),
                FontAttributes = FontAttributes.Bold
            };

            mFavoriteButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(74),
                HeightRequest = MyDevice.GetScaledSize(65)
            };

            mRemoveFavoriteImage = new CachedImage()
            {
                WidthRequest = MyDevice.GetScaledSize(42),
                HeightRequest = MyDevice.GetScaledSize(35),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                Source = "CartPage_RemoveFavorites.png",
                IsVisible = false,
                FadeAnimationEnabled = false
            };

            mAddFavoriteImage = new CachedImage()
            {
                WidthRequest = MyDevice.GetScaledSize(42),
                HeightRequest = MyDevice.GetScaledSize(35),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                Source = "CartPage_AddFavorites.png",
                IsVisible = false,
                FadeAnimationEnabled = false
            };

            mProductForegroundImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize (300),
                HeightRequest = MyDevice.GetScaledSize (377),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                Source = "ProductsPage_ProductForeground.png",
                IsVisible = false,
            };

            mProductOutOfStockImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize (300),
                HeightRequest = MyDevice.GetScaledSize (377),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                Source = "OutOfStocks.png",
                IsVisible = false,
            };

            mProductNumberLabel = new Label (){
                FontSize = MyDevice.FontSizeMedium,
                VerticalTextAlignment = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(117,117,117),
                WidthRequest = MyDevice.GetScaledSize(78),
                HeightRequest = MyDevice.GetScaledSize(55),
                IsVisible = false
            };

            addButton = new Label () {
                WidthRequest = MyDevice.GetScaledSize(118),
                HeightRequest = MyDevice.GetScaledSize(64),
                BackgroundColor = Color.FromRgb(213,53,53),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                Text = "ADD",
                TextColor = Color.White,
                FontSize = MyDevice.FontSizeSmall
            };

            mMinusButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(64),
                HeightRequest = MyDevice.GetScaledSize(64)
            };

            mPlusButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(64),
                HeightRequest = MyDevice.GetScaledSize(64)
            };

            mainRelativeLayout.Children.Add (mProductImage,
                Constraint.Constant(MyDevice.GetScaledSize(24)),
                Constraint.Constant(MyDevice.GetScaledSize(52))
            );

            mainRelativeLayout.Children.Add (addButton,
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize(159);
                }),
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize(307);
                })
            );

            mainRelativeLayout.Children.Add (mProductForegroundImage,
                Constraint.Constant (MyDevice.GetScaledSize(0)),
                Constraint.Constant (MyDevice.GetScaledSize(0))
            );

            mainRelativeLayout.Children.Add (mProductOutOfStockImage,
                Constraint.Constant (MyDevice.GetScaledSize(0)),
                Constraint.Constant (MyDevice.GetScaledSize(0))
            );

            mainRelativeLayout.Children.Add (productNameLabel,
                Constraint.RelativeToView(mProductImage, (p,sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize(5);
                }),
                Constraint.RelativeToView(mProductImage, (p,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(0);
                })
            );

            mainRelativeLayout.Children.Add (productQuantityLabel,
                Constraint.RelativeToView(productNameLabel, (p,sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView(productNameLabel, (p,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(5);
                })
            );

            mainRelativeLayout.Children.Add (productPriceLabel,
                Constraint.RelativeToView(productQuantityLabel, (p,sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView(productQuantityLabel, (p,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(5);
                })
            );

            mainRelativeLayout.Children.Add (mProductNumberLabel,
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize(113);
                }),
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize(162);
                })
            );

            mainRelativeLayout.Children.Add (mFavoriteButton,
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Right - MyDevice.GetScaledSize(74);
                }),
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Top;
                })
            );

            mainRelativeLayout.Children.Add (mRemoveFavoriteImage,
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Right - MyDevice.GetScaledSize(58);
                }),
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize(19);
                })
            );

            mainRelativeLayout.Children.Add (mAddFavoriteImage,
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Right - MyDevice.GetScaledSize(58);
                }),
                Constraint.RelativeToView(mProductForegroundImage, (p,sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize(19);
                })
            );

            AddTapRecognizers ();

            View = mainRelativeLayout;
        }
Beispiel #9
0
		private void InitializeAddAddressLayout(){

			double labelGap = MyDevice.GetScaledSize (8);
			double entryGap = MyDevice.GetScaledSize (14);
			var addressLayout = new RelativeLayout () {
				Padding = 0
			};
			var infoLabel = new Label () {
				Text = "Please Enter Your Delivery Address",
				HorizontalTextAlignment = TextAlignment.Center,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(640),
				HeightRequest = MyDevice.GetScaledSize(40)
			};

			addressLayout.Children.Add (infoLabel,
				Constraint.Constant (0),
				Constraint.Constant (0)
			);

			#region FirstName
			var firstNameLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (222),
				HeightRequest = MyDevice.GetScaledSize(26),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				Text = "First Name",
				FontSize = MyDevice.FontSizeSmall
			};

			NameEntry = new Entry () {
				WidthRequest = MyDevice.GetScaledSize(600),
				HeightRequest = MyDevice.GetScaledSize(61),
				BackgroundColor = Color.White,
				Keyboard = Keyboard.Create(KeyboardFlags.CapitalizeSentence)
			};					

			addressLayout.Children.Add (firstNameLabel,
				Constraint.RelativeToView (infoLabel, (p, sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (28);	
				}),
				Constraint.RelativeToView (infoLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize (43);	
				})
			);

			addressLayout.Children.Add (NameEntry,
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (7);	
				}),
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap;	
				})
			);				
			#endregion

			#region SurName
			var surNameLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (222),
				HeightRequest = MyDevice.GetScaledSize(26),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				Text = "Last Name",
				FontSize = MyDevice.FontSizeSmall
			};

			SurNameEntry = new Entry () {
				WidthRequest = MyDevice.GetScaledSize(600),
				HeightRequest = MyDevice.GetScaledSize(61),
				BackgroundColor = Color.White,
				Keyboard = Keyboard.Create(KeyboardFlags.CapitalizeSentence)
			};					

			addressLayout.Children.Add (surNameLabel,
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Left;	
				}),
				Constraint.RelativeToView (NameEntry, (p, sibling) => {
					return sibling.Bounds.Bottom + entryGap;	
				})
			);

			addressLayout.Children.Add (SurNameEntry,
				Constraint.RelativeToView (surNameLabel, (p, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (7);	
				}),
				Constraint.RelativeToView (surNameLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap;	
				})
			);
				
			#endregion

			#region Region
			var regionLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (222),
				HeightRequest = MyDevice.GetScaledSize(28),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				Text = "Nearest Bluemart Location",
				FontSize = MyDevice.FontSizeSmall
			};

			var regionImageBackground = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(600),
				HeightRequest = MyDevice.GetScaledSize(61),
				Source = "AddressPage_EntryBackground.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			RegionEntryLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (581),
				HeightRequest = MyDevice.GetScaledSize(61),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(230,88,91),
				FontSize = MyDevice.FontSizeSmall
			};

			addressLayout.Children.Add (regionLabel,
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Left;	
				}),
				Constraint.RelativeToView (SurNameEntry, (p, sibling) => {
					return sibling.Bounds.Bottom + entryGap;	
				})
			);

			addressLayout.Children.Add (regionImageBackground,
				Constraint.RelativeToView (regionLabel, (p, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (7);	
				}),
				Constraint.RelativeToView (regionLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap;	
				})
			);


			addressLayout.Children.Add (RegionEntryLabel,
				Constraint.RelativeToView (regionImageBackground, (p, sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (17);	
				}),
				Constraint.RelativeToView (regionImageBackground, (p, sibling) => {
					return sibling.Bounds.Top;	
				})
			);

			UserClass user = mUserModel.GetUser ();
			RegionEntryLabel.Text = user.ActiveRegion;
			#endregion

			#region Address
			var addressLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (222),
				HeightRequest = MyDevice.GetScaledSize(26),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				Text = "Area / Cluster",
				FontSize = MyDevice.FontSizeSmall
			};

			AddressEntry = new Entry () {
				WidthRequest = MyDevice.GetScaledSize(600),
				HeightRequest = MyDevice.GetScaledSize(61),
				BackgroundColor = Color.White
			};
					
			addressLayout.Children.Add (addressLabel,
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Left;	
				}),
				Constraint.RelativeToView (regionImageBackground, (p, sibling) => {
					return sibling.Bounds.Bottom + entryGap;	
				})
			);

			addressLayout.Children.Add (AddressEntry,
				Constraint.RelativeToView (addressLabel, (p, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (7);	
				}),
				Constraint.RelativeToView (addressLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap;	
				})
			);				
			#endregion

			#region AddressDescription
			var addressDescriptionLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (422),
				HeightRequest = MyDevice.GetScaledSize(28),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				Text = "Community / Building Name",
				FontSize = MyDevice.FontSizeSmall
			};

			AddressDescriptionEntry = new Entry () {
				WidthRequest = MyDevice.GetScaledSize(600),
				HeightRequest = MyDevice.GetScaledSize(61),
				BackgroundColor = Color.White
			};					

			addressLayout.Children.Add (addressDescriptionLabel,
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Left;	
				}),
				Constraint.RelativeToView (AddressEntry, (p, sibling) => {
					return sibling.Bounds.Bottom + entryGap;	
				})
			);

			addressLayout.Children.Add (AddressDescriptionEntry,
				Constraint.RelativeToView (addressDescriptionLabel, (p, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (7);	
				}),
				Constraint.RelativeToView (addressDescriptionLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap;	
				})
			);				
			#endregion

			#region AddressLine3
			var addressLine3 = new Label () {
				WidthRequest = MyDevice.GetScaledSize (422),
				HeightRequest = MyDevice.GetScaledSize(28),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				Text = "Apartment / House No",
				FontSize = MyDevice.FontSizeSmall
			};

			AddressLine3Entry = new Entry () {
				WidthRequest = MyDevice.GetScaledSize(600),
				HeightRequest = MyDevice.GetScaledSize(61),
				BackgroundColor = Color.White
			};					

			addressLayout.Children.Add (addressLine3,
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Left;	
				}),
				Constraint.RelativeToView (AddressDescriptionEntry, (p, sibling) => {
					return sibling.Bounds.Bottom + entryGap;	
				})
			);

			addressLayout.Children.Add (AddressLine3Entry,
				Constraint.RelativeToView (addressLine3, (p, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (7);	
				}),
				Constraint.RelativeToView (addressLine3, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap;	
				})
			);				
			#endregion

			#region Phone
			var phoneLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (222),
				HeightRequest = MyDevice.GetScaledSize(26),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.FromRgb(98,98,98),
				Text = "Telephone",
				FontSize = MyDevice.FontSizeSmall
			};

			var initialText = new Label () {
				WidthRequest = MyDevice.GetScaledSize (54),
				HeightRequest = MyDevice.GetScaledSize(62),
				HorizontalTextAlignment = TextAlignment.End,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.Black,
				Text = "05",
				FontSize = MyDevice.FontSizeMedium + MyDevice.GetScaledSize(3),
				BackgroundColor = Color.White
			};

			PhoneEntry = new Entry () {
				WidthRequest = MyDevice.GetScaledSize(565),
				HeightRequest = MyDevice.GetScaledSize(61),
				BackgroundColor = Color.White,
				Keyboard = Keyboard.Numeric,
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalOptions = LayoutOptions.Center
			};					

			addressLayout.Children.Add (phoneLabel,
				Constraint.RelativeToView (firstNameLabel, (p, sibling) => {
					return sibling.Bounds.Left;	
				}),
				Constraint.RelativeToView (AddressLine3Entry, (p, sibling) => {
					return sibling.Bounds.Bottom + entryGap;	
				})
			);

			addressLayout.Children.Add (PhoneEntry,
				Constraint.RelativeToView (phoneLabel, (p, sibling) => {
					return sibling.Bounds.Left + MyDevice.GetScaledSize (30);		
				}),
				Constraint.RelativeToView (phoneLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap + MyDevice.GetScaledSize(5);	
				})
			);

			addressLayout.Children.Add (initialText,
				Constraint.RelativeToView (phoneLabel, (p, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (4);	
				}),
				Constraint.RelativeToView (phoneLabel, (p, sibling) => {
					return sibling.Bounds.Bottom + labelGap;	
				})
			);	

						

			#endregion

		
			var line = new BoxView () {
				WidthRequest = MyDevice.GetScaledSize(600),
				HeightRequest = MyDevice.GetScaledSize(1),
				Color = Color.FromRgb(181,185,187)
			};

			addressLayout.Children.Add (line,
				Constraint.RelativeToView (PhoneEntry, (p, sibling) => {
					return sibling.Bounds.Left;	
				}),
				Constraint.RelativeToView (PhoneEntry, (p, sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize(40);	
				})
			);

			SubmitButton = new Label () {
				WidthRequest = MyDevice.GetScaledSize (197),
				HeightRequest = MyDevice.GetScaledSize(56),
				HorizontalTextAlignment = TextAlignment.Center,
				VerticalTextAlignment = TextAlignment.Center,
				BackgroundColor = Color.FromRgb(98,98,98),
				TextColor = Color.White,
				Text = "SUBMIT",
				FontSize = MyDevice.FontSizeMicro
			};

			addressLayout.Children.Add (SubmitButton,
				Constraint.RelativeToView (line, (p, sibling) => {
					return sibling.Bounds.Right - MyDevice.GetScaledSize(197);	
				}),
				Constraint.RelativeToView (line, (p, sibling) => {
					return sibling.Bounds.Bottom;	
				})
			);



			scroll = new ScrollView () {
				Orientation = ScrollOrientation.Vertical,
				Content = addressLayout,
				HeightRequest = MyDevice.ScreenHeight - MyDevice.GetScaledSize(200)
			};

			mMidLayout.Children.Add (scroll,
				Constraint.Constant (0),
				Constraint.Constant (MyDevice.GetScaledSize (120)),
				Constraint.Constant (MyDevice.ScreenWidth)/*,
				Constraint.Constant (MyDevice.ScreenHeight - MyDevice.GetScaledSize(200))*/
			);
					
		}
Beispiel #10
0
        protected override void InitializeCell()
        {
            //System.Diagnostics.Debug.WriteLine ("InitializeCell");
            mParentPage = MyDevice.currentPage;
            mainCellView = new Grid (){
                RowSpacing = 0,
                ColumnSpacing = 0,
                Padding = 0,
                BackgroundColor=Color.FromRgb(51,51,51),
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = MyDevice.GetScaledSize(150),
                WidthRequest = MyDevice.GetScaledSize(535)
            };
            mainCellView.ColumnDefinitions.Add (new ColumnDefinition (){ Width = MyDevice.GetScaledSize(535) } );
            mainCellView.RowDefinitions.Add (new RowDefinition (){ Height = MyDevice.GetScaledSize(148) } );
            mainCellView.RowDefinitions.Add (new RowDefinition (){ Height = MyDevice.GetScaledSize(2) } );

            mainLayout = new RelativeLayout () {
                HeightRequest = MyDevice.GetScaledSize(148),
                WidthRequest = MyDevice.GetScaledSize(535),
                Padding = 0,
                BackgroundColor = Color.FromRgb(253,59,47)
            };

            cellLayout = new MR.Gestures.RelativeLayout () {
                HeightRequest = MyDevice.GetScaledSize(148),
                WidthRequest = MyDevice.GetScaledSize(535),
                Padding = 0,
                BackgroundColor=Color.FromRgb(51,51,51)
            };

            productImage = new Image () {
                WidthRequest = MyDevice.GetScaledSize(126),
                HeightRequest = MyDevice.GetScaledSize(122),
                /*CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false*/
            };
            imageMask = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(126),
                HeightRequest = MyDevice.GetScaledSize(122),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "CartPage_ImageMask.png"
            };

            mFavoriteImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(39),
                HeightRequest = MyDevice.GetScaledSize(32),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false
            };

            favoriteButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(84),
                HeightRequest = MyDevice.GetScaledSize(71),
                BackgroundColor = Color.Transparent
            };
            mProductPriceLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(102),
                HeightRequest = MyDevice.GetScaledSize(40),
                HorizontalTextAlignment = TextAlignment.End,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.White,
                FontSize = MyDevice.FontSizeMedium
            };
            productNameLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(225),
                HeightRequest = MyDevice.GetScaledSize(40),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.White,
                FontSize = MyDevice.FontSizeMicro,
            };
            productQuantityLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(225),
                HeightRequest = MyDevice.GetScaledSize(26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb(152,152,152),
                FontSize = MyDevice.FontSizeMicro
            };
            mRemoveImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(27),
                HeightRequest = MyDevice.GetScaledSize(21),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "CartPage_RemoveProduct.png"
            };

            var removeProductButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(59),
                HeightRequest = MyDevice.GetScaledSize(49),
                BackgroundColor = Color.Transparent
            };

            mProductNumberLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(120),
                HeightRequest = MyDevice.GetScaledSize(47),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                BackgroundColor = Color.FromRgb(152,152,152),
                TextColor = Color.FromRgb(51,51,51),
                FontSize = MyDevice.FontSizeSmall
            };
            mAddImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(27),
                HeightRequest = MyDevice.GetScaledSize(21),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "CartPage_AddProduct.png"
            };

            var addProductButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(59),
                HeightRequest = MyDevice.GetScaledSize(49),
                BackgroundColor = Color.Transparent
            };

            var deleteButton = new Label () {
                WidthRequest = MyDevice.GetScaledSize(167),
                HeightRequest = MyDevice.GetScaledSize(147),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                BackgroundColor = Color.FromRgb(253,59,47),
                TextColor = Color.White,
                FontSize = MyDevice.FontSizeSmall,
                Text = "DELETE"
            };

            var cartTapRecogniser = new TapGestureRecognizer ();

            cartTapRecogniser.Tapped += (sender, e) => {
                if( !deleteIsOpenDictionary.ContainsKey(product.ProductID) || !deleteIsOpenDictionary[product.ProductID])
                {
                    deleteIsOpenDictionary[product.ProductID] = true;
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(-164),0,300,Easing.Linear);
                }
                else
                {
                    deleteIsOpenDictionary[product.ProductID] = false;
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(0),0,300,Easing.Linear);
                }
                //IsOpen = !IsOpen;
            };

            cellLayout.GestureRecognizers.Add (cartTapRecogniser);

            cellLayout.Swiped += (object sender, MR.Gestures.SwipeEventArgs e) =>
            {
                if( ( !deleteIsOpenDictionary.ContainsKey(product.ProductID) || !deleteIsOpenDictionary[product.ProductID]) && e.Direction == MR.Gestures.Direction.Left )
                {
                    deleteIsOpenDictionary[product.ProductID] = true;
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(-164),0,300,Easing.Linear);
                }
                else if( deleteIsOpenDictionary.ContainsKey(product.ProductID) && deleteIsOpenDictionary[product.ProductID] && e.Direction == MR.Gestures.Direction.Right )
                {
                    deleteIsOpenDictionary[product.ProductID] = false;
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(0),0,300,Easing.Linear);
                }
                //IsOpen = !IsOpen;
            };

            var deleteButtonTapRecogniser = new TapGestureRecognizer ();
            deleteButtonTapRecogniser.Tapped += (sender, e) => {
                Cart.ProductTotalPrice -= (mProduct.ProductNumberInCart-1)*mProduct.Price;
                mProduct.ProductNumberInCart = 1;

                if (mParentPage is BrowseProductsPage) {
                    foreach (var productCell in (mParentPage as BrowseProductsPage).mProductCellList) {
                        if (productCell.mProduct.ProductID == mProduct.ProductID) {

                            productCell.DeactivateAddMenu ();
                        }
                    }
                }
                else if (mParentPage is SearchPage) {
                    foreach (var productCell in (mParentPage as SearchPage).mProductCellList) {
                        if (productCell.mProduct.ProductID == mProduct.ProductID) {
                            productCell.DeactivateAddMenu ();
                        }
                    }
                }
                else if (mParentPage is FavoritesPage) {
                    foreach (var productCell in (mParentPage as FavoritesPage).mProductCellList) {
                        if (productCell.mProduct.ProductID == mProduct.ProductID) {
                            productCell.DeactivateAddMenu ();
                        }
                    }
                }

                RemoveProductFromCart();
            };
            deleteButton.GestureRecognizers.Add (deleteButtonTapRecogniser);

            var removeProductTapRecogniser = new TapGestureRecognizer ();
            removeProductTapRecogniser.Tapped += (sender, e) => {
                RemoveProductFromCart();
            };
            removeProductButton.GestureRecognizers.Add (removeProductTapRecogniser);

            var addProductTapRecogniser = new TapGestureRecognizer ();
            addProductTapRecogniser.Tapped += (sender, e) => {
                AddProductInCart();
            };
            addProductButton.GestureRecognizers.Add (addProductTapRecogniser);

            var favoriteTapRecogniser = new TapGestureRecognizer ();
            favoriteTapRecogniser.Tapped += (sender, e) => {
                if( !bIsFavorite )
                {
                    mFavoriteModel.AddProductID(mProduct.ProductID);
                    mFavoriteImage.Source = "CartPage_RemoveFavorites.png";
                    bIsFavorite = true;
                }
                else
                {
                    mFavoriteModel.RemoveProductID(mProduct.ProductID);
                    mFavoriteImage.Source = "CartPage_AddFavorites.png";
                    bIsFavorite = false;
                }
            };
            favoriteButton.GestureRecognizers.Add (favoriteTapRecogniser);

            mainLayout.Children.Add (deleteButton,
                Constraint.Constant (MyDevice.GetScaledSize (368)),
                Constraint.Constant (0)
            );

            mainLayout.Children.Add (cellLayout,
                Constraint.Constant (0),
                Constraint.Constant (0)
            );

            cellLayout.Children.Add (productImage,
                Constraint.Constant (MyDevice.GetScaledSize(12)),
                Constraint.Constant (MyDevice.GetScaledSize(12))
            );

            cellLayout.Children.Add (imageMask,
                Constraint.RelativeToView (productImage, (p,sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (productImage, (p,sibling) => {
                    return sibling.Bounds.Top;
                })
            );

            cellLayout.Children.Add (mFavoriteImage,
                Constraint.Constant (MyDevice.GetScaledSize(479)),
                Constraint.Constant (MyDevice.GetScaledSize(27))
            );

            cellLayout.Children.Add (favoriteButton,
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(24);
                }),
                Constraint.Constant(0)
            );

            cellLayout.Children.Add (mProductPriceLabel,
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Right - MyDevice.GetScaledSize(102);
                }),
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(30);
                })
            );

            cellLayout.Children.Add (productNameLabel,
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(278);
                }),
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(8);
                })
            );

            cellLayout.Children.Add (productQuantityLabel,
                Constraint.RelativeToView(productNameLabel, (p,sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView(productNameLabel, (p,sibling) => {
                    return sibling.Bounds.Bottom;
                })
            );

            cellLayout.Children.Add (mRemoveImage,
                Constraint.RelativeToView(productQuantityLabel, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(7);
                }),
                Constraint.RelativeToView(productQuantityLabel, (p,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(15);
                })
            );

            cellLayout.Children.Add (removeProductButton,
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(11);
                }),
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(14);
                })
            );

            cellLayout.Children.Add (mProductNumberLabel,
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Right + MyDevice.GetScaledSize(18);
                }),
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(14);
                })
            );

            cellLayout.Children.Add (mAddImage,
                Constraint.RelativeToView(mProductNumberLabel, (p,sibling) => {
                    return sibling.Bounds.Right + MyDevice.GetScaledSize(18);
                }),
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Top;
                })
            );

            cellLayout.Children.Add (addProductButton,
                Constraint.RelativeToView(mAddImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(11);
                }),
                Constraint.RelativeToView(mAddImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(14);
                })
            );

            var bottomLayout = new RelativeLayout () {
                HeightRequest = MyDevice.GetScaledSize(2),
                WidthRequest = MyDevice.GetScaledSize(535),
                BackgroundColor = Color.FromRgb(129,129,129),
                Padding = 0
            };

            mainCellView.Children.Add (mainLayout, 0, 0);
            mainCellView.Children.Add (bottomLayout, 0, 1);

            this.View = mainCellView;
        }
        //Constructor that sets up the item template for the EventEntry list
        public SchedListView(List <EventEntry> _events, MyEventEntries myEvents = null, EventEntriesMain _mainEvents = null) : base(ListViewCachingStrategy.RecycleElement)
        {
            this.IsPullToRefreshEnabled = false;
            mainEvents = _mainEvents;
            events     = _events;

            Task.Factory.StartNew(() => {
                refresh();
                ItemTemplate = new DataTemplate(() =>
                {
                    RowHeight            = 95;
                    Label Title          = new Label();
                    Title.FontAttributes = FontAttributes.Bold;
                    Title.SetBinding(Label.TextProperty, "Title");
                    Title.MinimumHeightRequest = 50;
                    Title.FontSize             = Xamarin.Forms.AbsoluteLayout.AutoSize;

                    Label date          = new Label();
                    date.FontAttributes = FontAttributes.Italic;
                    date.SetBinding(Label.TextProperty, "StartTime", BindingMode.Default, null, ("{0:MMMM dd}"));
                    date.MinimumHeightRequest = 50;
                    date.FontSize             = Xamarin.Forms.AbsoluteLayout.AutoSize;

                    Label speaker          = new Label();
                    speaker.FontAttributes = FontAttributes.Italic;
                    speaker.SetBinding(Label.TextProperty, "speaker1");
                    speaker.MinimumHeightRequest = 50;
                    speaker.FontSize             = Xamarin.Forms.AbsoluteLayout.AutoSize;

                    Label startEndTime          = new Label();
                    startEndTime.FontAttributes = FontAttributes.Italic;
                    startEndTime.SetBinding(Label.TextProperty, "StartEndTime");
                    startEndTime.MinimumHeightRequest = 50;
                    startEndTime.FontSize             = Xamarin.Forms.AbsoluteLayout.AutoSize;

                    Label location = new Label();
                    location.SetBinding(Label.TextProperty, "Location");
                    location.MinimumHeightRequest = 50;
                    location.FontSize             = Xamarin.Forms.AbsoluteLayout.AutoSize;

                    FFImageLoading.Forms.CachedImage im = new FFImageLoading.Forms.CachedImage()
                    {
                        RetryCount    = 3,   //Number of trys until it gives up
                        RetryDelay    = 200, //Delay between tries (in ms)
                        HeightRequest = 50,
                        WidthRequest  = 50,
                        // DownsampleWidth = 100, //Down sample to predetermined width (maintains aspect ratio)
                        Aspect = Xamarin.Forms.Aspect.AspectFit, //Sets aspect ratio
                        DownsampleToViewSize = true,
                        CacheType            = FFImageLoading.Cache.CacheType.All,
                        IsOpaque             = true,
                        LoadingPriority      = FFImageLoading.Work.LoadingPriority.High,
                        LoadingPlaceholder   = AppResources.defaultPicture
                    };

                    var transform = new FFImageLoading.Transformations.CircleTransformation(10, "#000000");
                    im.Transformations.Add(transform);
                    im.SetBinding(CachedImage.SourceProperty, "ThumbnailStr");
                    im.SetBinding(CachedImage.BackgroundColorProperty, "Color");

                    FFImageLoading.Forms.CachedImage calenderImage = new FFImageLoading.Forms.CachedImage()
                    {
                        IsVisible     = false,
                        HeightRequest = 50,
                        WidthRequest  = 50,
                        // DownsampleWidth = 100, //Down sample to predetermined width (maintains aspect ratio)
                        Aspect = Xamarin.Forms.Aspect.AspectFit, //Sets aspect ratio
                        DownsampleToViewSize = true,
                        CacheType            = FFImageLoading.Cache.CacheType.Memory,
                        IsOpaque             = true,
                        LoadingPriority      = FFImageLoading.Work.LoadingPriority.High,
                        Source = "checklist.png"
                    };
                    calenderImage.SetBinding(CachedImage.IsVisibleProperty, "inMySched");



                    Button addRemove;
                    addRemove = new Button
                    {
                        Text = "Add/Remove",
                    };

                    BoxView boxView = new BoxView
                    {
                        Color             = Color.Gray,
                        HeightRequest     = 1,
                        HorizontalOptions = LayoutOptions.Fill
                    };


                    var tempGrid           = new Grid();
                    tempGrid.RowSpacing    = 2;
                    tempGrid.ColumnSpacing = 5;

                    tempGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    });
                    tempGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(50, GridUnitType.Star)
                    });
                    tempGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(50, GridUnitType.Auto)
                    });
                    tempGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(25, GridUnitType.Star)
                    });
                    tempGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(25, GridUnitType.Star)
                    });
                    tempGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(5, GridUnitType.Star)
                    });

                    tempGrid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(30, GridUnitType.Star)
                    });
                    tempGrid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(50, GridUnitType.Star)
                    });
                    tempGrid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(10, GridUnitType.Star)
                    });
                    tempGrid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(50, GridUnitType.Star)
                    });
                    tempGrid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(10, GridUnitType.Star)
                    });
                    //  tempGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(50, GridUnitType.Star) });
                    tempGrid.Children.Add(Title, 1, 4, 1, 3);
                    tempGrid.Children.Add(date, 1, 3);
                    tempGrid.Children.Add(startEndTime, 3, 3);
                    tempGrid.Children.Add(location, 1, 3, 4, 5);
                    tempGrid.Children.Add(speaker, 3, 4);
                    tempGrid.Children.Add(im, 0, 1, 1, 5);
                    tempGrid.Children.Add(calenderImage, 4, 5, 1, 5);
                    //tempGrid.Children.Add(addRemove, 2, 3, 1, 4);
                    tempGrid.Children.Add(boxView, 0, 5, 5, 6);
                    tempGrid.SetBinding(Grid.BackgroundColorProperty, "Color");

                    return(new ViewCell
                    {
                        View = tempGrid
                    });
                });
            }).ContinueWith(task =>
            {
                // scrollToCurrent();
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Beispiel #12
0
		public LoadingPage ()
		{
			NavigationPage.SetHasNavigationBar (this, false);
			InitializeComponent ();
			ProgressBar1 = new ProgressBar () {
				Progress = 0
			};

			bgImage = new Image {
				Source = "Loading_BG.jpg",
				WidthRequest = MyDevice.GetScaledSize(640),
				/*CacheDuration = TimeSpan.FromDays(30),
				//DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false,*/
				Aspect = Aspect.Fill
			};

			var footerImage = new CachedImage () {
				Source = "Loading_Footer.png",
				WidthRequest = MyDevice.GetScaledSize(421),
				HeightRequest = MyDevice.GetScaledSize(94),
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			var versionText = new Label () {
				Text = "Ver 1.0",
				FontSize = MyDevice.FontSizeMicro,
				HorizontalTextAlignment = TextAlignment.Center,
				WidthRequest = MyDevice.GetScaledSize(80),
				HeightRequest = MyDevice.GetScaledSize(30),
				TextColor = Color.White,
				FontAttributes = FontAttributes.Bold
			};

			ProgressBar1.WidthRequest = MyDevice.GetScaledSize (415);
			ProgressBar1.HeightRequest = MyDevice.GetScaledSize (90);

			relLayout1.Children.Add (bgImage, 
				Constraint.Constant (0),
				Constraint.Constant (0)
			);

			relLayout1.Children.Add (footerImage,
				Constraint.RelativeToParent (parent => {
					return parent.Bounds.Left +  MyDevice.GetScaledSize(114);
				}),
				Constraint.RelativeToParent (parent => {
					return parent.Bounds.Bottom - MyDevice.GetScaledSize(170);
				})
			);

			relLayout1.Children.Add (versionText,
				Constraint.RelativeToView (footerImage, (parent, sibling) => {
					return sibling.Bounds.Right - MyDevice.GetScaledSize (80);
				}),
				Constraint.RelativeToView (footerImage, (parent, sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize (10);
				})
			);
			if (Device.OS == TargetPlatform.Android) {
				
				relLayout1.Children.Add (ProgressBar1, 
					Constraint.RelativeToParent (parent => {
						return parent.Bounds.Left + MyDevice.GetScaledSize (117);
					}),
					Constraint.RelativeToParent (parent => {
						return parent.Bounds.Bottom - MyDevice.GetScaledSize (130);
					})
				);
			} else 
			{
				relLayout1.Children.Add (ProgressBar1, 
					Constraint.RelativeToParent (parent => {
						return parent.Bounds.Left + MyDevice.GetScaledSize (117);
					}),
					Constraint.RelativeToParent (parent => {
						return parent.Bounds.Bottom - MyDevice.GetScaledSize (130) + 20;
					})
				);
			}
			Load();
		}
Beispiel #13
0
		private void InitializeSwitchLayout ()
		{
			mSwitchLayout = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(640),
				HeightRequest = MyDevice.GetScaledSize(74),
				BackgroundColor = Color.Black
			};

			TrackLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (320),
				HeightRequest = MyDevice.GetScaledSize (74),
				HorizontalTextAlignment = TextAlignment.Center,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.White,
				Text = "TRACK",
				FontSize = MyDevice.FontSizeMedium,
				BackgroundColor = Color.FromRgb (76, 76, 76)
			};

			HistoryLabel = new Label () {
				WidthRequest = MyDevice.GetScaledSize (320),
				HeightRequest = MyDevice.GetScaledSize (74),
				HorizontalTextAlignment = TextAlignment.Center,
				VerticalTextAlignment = TextAlignment.Center,
				TextColor = Color.White,
				Text = "HISTORY",
				FontSize = MyDevice.FontSizeMedium
			};

			var trackMaskImage = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(73),
				HeightRequest = MyDevice.GetScaledSize(73),
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false,
				Source = "TrackPage_TrackMask.png"
			};

			var trackTapRecognizer = new TapGestureRecognizer ();
			trackTapRecognizer.Tapped +=async (sender, e) => {
				if(IsRefreshing || mActiveLabel == TrackLabel)
					return;
				mActiveLabel = TrackLabel;
				await Task.Factory.StartNew (() => Refresh()
					, TaskCreationOptions.None
				);
				IsRefreshing = false;
			};
			TrackLabel.GestureRecognizers.Add (trackTapRecognizer);

			var historyTapRecognizer = new TapGestureRecognizer ();
			historyTapRecognizer.Tapped +=async (sender, e) => {
				if(IsRefreshing || mActiveLabel == HistoryLabel)
					return;
				IsRefreshing = true;
				mActiveLabel = HistoryLabel;
				await Task.Factory.StartNew (() => Refresh()
					, TaskCreationOptions.None
				);			
				IsRefreshing = false;
			};
			HistoryLabel.GestureRecognizers.Add (historyTapRecognizer);

			mMidLayout.Children.Add (mSwitchLayout,
				Constraint.Constant (0),
				Constraint.Constant (MyDevice.GetScaledSize(87))
			);

			mSwitchLayout.Children.Add (TrackLabel,
				Constraint.Constant (0),
				Constraint.Constant (0)
			);

			mSwitchLayout.Children.Add (HistoryLabel,
				Constraint.RelativeToView (TrackLabel, (p, sibling) => {
					return sibling.Bounds.Right;
				}),
				Constraint.Constant (0)
			);

			mSwitchLayout.Children.Add (trackMaskImage,
				Constraint.RelativeToView (TrackLabel, (p, sibling) => {
					return sibling.Bounds.Right - MyDevice.GetScaledSize(37);
				}),
				Constraint.Constant (0)
			);

			mActiveLabel = TrackLabel;
		}
Beispiel #14
0
        private void SetGridDefinitions()
        {
            this.RowDefinitions [0].Height = MyDevice.ScreenWidth * 0.148f;
            this.ColumnDefinitions [0].Width = MyDevice.MenuPadding;
            this.ColumnDefinitions [1].Width = MyDevice.ScreenWidth - MyDevice.ScreenWidth*0.174f - MyDevice.MenuPadding*2;
            this.ColumnDefinitions [2].Width = MyDevice.ScreenWidth*0.174f;
            this.ColumnDefinitions [3].Width = MyDevice.MenuPadding;

            mSearchButtonLayout = new RelativeLayout(){
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding = 0
            };

            var searchImage = new CachedImage () {
                Source = "search",
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false
            };

            mSearchButtonLayout.Children.Add(searchImage,
                Constraint.RelativeToParent( parent =>
                    {
                        return (MyDevice.ScreenWidth*0.174f-MyDevice.ScreenWidth*0.087f)/2;
                    }),
                Constraint.RelativeToParent( parent =>
                    {
                        return (MyDevice.ScreenWidth*0.148f-MyDevice.ScreenWidth*0.087f)/2;
                    }),
                Constraint.Constant(MyDevice.ScreenWidth*0.087f),
                Constraint.Constant(MyDevice.ScreenWidth*0.087f)
                );

            this.Children.Add (mSearchButtonLayout, 2, 0);
        }
Beispiel #15
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;
        }
Beispiel #16
0
		private void InitializeHeaderLayout ()
		{
			mTopLayout = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(640),
				HeightRequest = MyDevice.GetScaledSize(87),
				BackgroundColor = Color.White
			};

			menuIcon = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(36),
				HeightRequest = MyDevice.GetScaledSize(37),
				Source = "ReceiptPage_MenuIcon.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};

			var logo = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(217),
				HeightRequest = MyDevice.GetScaledSize(39),
				Source = "ReceiptPage_Logo.png",
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false
			};



			var menuButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(72),
				HeightRequest = MyDevice.GetScaledSize(86)
			};

			var menuTapRecognizer= new TapGestureRecognizer ();
			menuTapRecognizer.Tapped += (sender, e) => {				
				ActivateOrDeactivateMenu();
			};
			menuButton.GestureRecognizers.Add(menuTapRecognizer);



			mMidLayout.Children.Add (mTopLayout,
				Constraint.Constant (0),
				Constraint.Constant (0)
			);

			mMidLayout.Children.Add (menuIcon, 
				Constraint.RelativeToParent (parent => {
					return parent.Bounds.Left +  MyDevice.GetScaledSize(20);
				}),
				Constraint.RelativeToParent (parent => {
					return parent.Bounds.Top + MyDevice.GetScaledSize(27);
				})
			);	

			mMidLayout.Children.Add (logo,
				Constraint.RelativeToView (menuIcon, (p, sibling) => {
					return sibling.Bounds.Right + MyDevice.GetScaledSize (150);	
				}),
				Constraint.RelativeToView (menuIcon, (p, sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize(5);	
				})
			);

			mMidLayout.Children.Add (menuButton,
				Constraint.Constant (0),
				Constraint.Constant (0));

		}
        public CachedImageHandler(NativeComponentRenderer renderer, FF.CachedImage cachedImageControl) : base(renderer, cachedImageControl)
        {
            CachedImageControl = cachedImageControl ?? throw new ArgumentNullException(nameof(CachedImageControl));

            Initialize(renderer);
        }
Beispiel #18
0
        public TrackCell(StatusClass status, TrackPage rootPage)
        {
            mRootPage = rootPage;
            mStatus = status;

            var mainLayout = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize (600),
                HeightRequest = MyDevice.GetScaledSize (180),
                BackgroundColor = Color.White,
                Padding = 0
            };

            var backgroundImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize (62),
                HeightRequest = MyDevice.GetScaledSize (82),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "TrackPage_TrackBackground_Red.png"
            };

            var totalPriceLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (455),
                HeightRequest = MyDevice.GetScaledSize (26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb (98, 98, 98),
                Text = "Total Price: " + status.TotalPrice + " AED",
                FontSize = MyDevice.FontSizeMicro
            };

            DateTime statusDate = DateTime.Now;

            DateTime.TryParse(status.Date,out statusDate);
            DateTime addedStatusDate =statusDate.AddHours (2);
            var dateLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (220),
                HeightRequest = MyDevice.GetScaledSize (26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb (98, 98, 98),
                Text = "Date: " + addedStatusDate.ToString ("MM/dd/yyyy") + " - Time: ",
                FontSize = MyDevice.FontSizeMicro
            };

            var timeLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (80),
                HeightRequest = MyDevice.GetScaledSize (26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = MyDevice.RedColor,
                Text = addedStatusDate.ToString ("hh:mm:ss"),
                FontSize = MyDevice.FontSizeMicro
            };

            var regionLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (455),
                HeightRequest = MyDevice.GetScaledSize (26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb (98, 98, 98),
                Text = "Region: " + status.Region,
                FontSize = MyDevice.FontSizeMicro
            };

            var statusLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (455),
                HeightRequest = MyDevice.GetScaledSize (60),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb (98, 98, 98),
                Text = status.Status,
                FontSize = MyDevice.FontSizeMicro
            };

            var line = new BoxView () {
                WidthRequest = MyDevice.GetScaledSize (600),
                HeightRequest = MyDevice.GetScaledSize (1),
                Color = Color.FromRgb (181, 185, 187)
            };

            mainLayout.Children.Add (totalPriceLabel,
                Constraint.Constant (MyDevice.GetScaledSize (140)),
                Constraint.Constant (MyDevice.GetScaledSize (26))
            );

            mainLayout.Children.Add (dateLabel,
                Constraint.RelativeToView (totalPriceLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (totalPriceLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                })
            );

            mainLayout.Children.Add (timeLabel,
                Constraint.RelativeToView (dateLabel, (p, sibling) => {
                    return sibling.Bounds.Right + MyDevice.GetScaledSize(2);
                }),
                Constraint.RelativeToView (dateLabel, (p, sibling) => {
                    return sibling.Bounds.Top;
                })
            );

            mainLayout.Children.Add (regionLabel,
                Constraint.RelativeToView (dateLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (dateLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                })
            );

            mainLayout.Children.Add (statusLabel,
                Constraint.RelativeToView (regionLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (regionLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                })
            );

            if (status.OrderStatus == OrderModel.OrderStatus.WAITING_CONFIRMATION) {
                backgroundImage.Source = "TrackPage_TrackBackground_Red.png";
                mainLayout.Children.Add (backgroundImage,
                    Constraint.Constant (MyDevice.GetScaledSize (42)),
                    Constraint.Constant (MyDevice.GetScaledSize (42))
                );

                mainLayout.Children.Add (line,
                    Constraint.Constant (0),
                    Constraint.Constant (MyDevice.GetScaledSize (179))
                );
            }
            else if(status.OrderStatus == OrderModel.OrderStatus.CONFIRMED){
                backgroundImage.Source = "TrackPage_TrackBackground_Blue.png";
                mainLayout.Children.Add (backgroundImage,
                    Constraint.Constant (MyDevice.GetScaledSize (42)),
                    Constraint.Constant (MyDevice.GetScaledSize (42))
                );

                mainLayout.Children.Add (line,
                    Constraint.Constant (0),
                    Constraint.Constant (MyDevice.GetScaledSize (179))
                );
            }
            else if (status.OrderStatus == OrderModel.OrderStatus.IN_TRANSIT) {
                mainLayout.HeightRequest = MyDevice.GetScaledSize (232);
                mainLayout.Children.Add (line,
                    Constraint.Constant (0),
                    Constraint.Constant (MyDevice.GetScaledSize (231))
                );

                var deliveryStaffNameLabel = new Label () {
                    WidthRequest = MyDevice.GetScaledSize (455),
                    HeightRequest = MyDevice.GetScaledSize (26),
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalTextAlignment = TextAlignment.Start,
                    TextColor = Color.FromRgb (98, 98, 98),
                    Text = "Staff Name: " + status.DeliveryStaffName,
                    FontSize = MyDevice.FontSizeMicro
                };

                var deliveryStaffPhoneLabel = new Label () {
                    WidthRequest = MyDevice.GetScaledSize (455),
                    HeightRequest = MyDevice.GetScaledSize (26),
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalTextAlignment = TextAlignment.Start,
                    TextColor = Color.FromRgb (98, 98, 98),
                    Text = "Staff Phone: " + status.Phone,
                    FontSize = MyDevice.FontSizeMicro
                };

                mainLayout.Children.Add (deliveryStaffNameLabel,
                    Constraint.RelativeToView (statusLabel, (p, sibling) => {
                        return sibling.Bounds.Left;
                    }),
                    Constraint.RelativeToView (statusLabel, (p, sibling) => {
                        return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                    })
                );

                mainLayout.Children.Add (deliveryStaffPhoneLabel,
                    Constraint.RelativeToView (deliveryStaffNameLabel, (p, sibling) => {
                        return sibling.Bounds.Left;
                    }),
                    Constraint.RelativeToView (deliveryStaffNameLabel, (p, sibling) => {
                        return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                    })
                );

                backgroundImage.Source = "TrackPage_TrackBackground_Green.png";
                mainLayout.Children.Add (backgroundImage,
                    Constraint.Constant (MyDevice.GetScaledSize (42)),
                    Constraint.Constant (MyDevice.GetScaledSize (70))
                );

            }

            var tapGestureRecognizer = new TapGestureRecognizer ();
            tapGestureRecognizer.Tapped += (sender, e) => {
                mRootPage.mParent.LoadReceiptPage (mStatus);
            };
            mainLayout.GestureRecognizers.Add (tapGestureRecognizer);

            this.View = mainLayout;
        }
        public DocumentsCellTemplate()
        {
            var publishLabel = new Label () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            publishLabel.SetBinding (Label.TextProperty, new Binding ("PublicationDate", converter: new DateConverter ()));

            var nameLabel = new CustomLabel () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.StartAndExpand,
            };
            nameLabel.SetBinding (Label.TextProperty, "FileName");

            var descriptionLabel = new CustomLabel2 () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.StartAndExpand,
            };
            descriptionLabel.SetBinding (Label.TextProperty, "Description");

            Device.OnPlatform (iOS: () => {
                nameLabel.LineBreakMode = LineBreakMode.TailTruncation;
                descriptionLabel.LineBreakMode = LineBreakMode.TailTruncation;
            });

            var thumbnailImage = new CachedImage () {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions = LayoutOptions.StartAndExpand,
                HeightRequest = UIConstants.GetThumbnailHeight (),
                WidthRequest = UIConstants.GetThumbnailWidth (),
                BackgroundColor = ColorConstants.SemiOpaqueBackground,

                CacheDuration = TimeSpan.FromDays (30),
                DownsampleHeight = UIConstants.GetThumbnailHeight () - 100,
                RetryCount = 3,
                RetryDelay = 250,
                TransparencyEnabled = false,
                ErrorPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png"),
                LoadingPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png")

            };

            thumbnailImage.SetBinding (CachedImage.SourceProperty, new Binding ("ThumbPath", converter: new NoCacheConverter ()));

            var downloadLabel = new Label () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            downloadLabel.SetBinding (Label.TextProperty, new Binding ("DownloadDate", converter: new DownloadDateConverter ()));

            //Read Online Button
            var readOnline = new Button () {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.Center,
                BackgroundColor = Color.FromHex ("#006699"),
                TextColor = Color.White,
                HeightRequest = UIConstants.GetButtonHeight (),
                WidthRequest = UIConstants.GetButtonWidth (),
            };

            readOnline.SetBinding (Button.TextProperty, new Binding ("CategoryCode", converter: new OfflineTextConverter ()));
            readOnline.SetBinding (Button.CommandParameterProperty, new Binding ("."));

            readOnline.Clicked += (sender, e) => {

                var btn = ((Button)sender);

                var fileItem = (Downloads)btn.CommandParameter;

                if (fileItem.MimeType.StartsWith ("mp4")) {
                    Device.OnPlatform (
                        iOS: () => {
                            var page = (Page)Activator.CreateInstance (typeof(DownloadViewer), fileItem);
                            this.ParentView.Navigation.PushAsync (page, true);
                        },
                        Android: () => {
                            var page = (Page)Activator.CreateInstance (typeof(AndroidVideoPlayer), fileItem);
                            this.ParentView.Navigation.PushAsync (page, true);
                        }
                    );
                } else {
                    var pdfService = DependencyService.Get<IPdfService> ();
                    if (pdfService == null)
                        return;

                    pdfService.OpenPDF (LibraryType.MyDocuments, fileItem.FilePath, fileItem.FileName, 0, null);
                }

            };

            //Download Button
            var download = new Button () {
                Text = Translation.Localize ("DeleteText"),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.Center,
                BackgroundColor = Color.FromHex ("#006699"),
                TextColor = Color.White,
                HeightRequest = UIConstants.GetButtonHeight (),
                WidthRequest = UIConstants.GetButtonWidth (),
            };
            download.SetBinding (Button.CommandParameterProperty, new Binding ("."));

            download.Clicked += async (sender, e) => {

                var btn = ((Button)sender);
                //download.IsEnabled = false;
                var fileItem = (Downloads)btn.CommandParameter;
                var parent = (MyDocumentsView)this.ParentView.ParentView.Parent;

                var textToDisplay =
                    fileItem.MimeType.StartsWith ("mp4")
                    ? Translation.Localize ("DeleteVideoMessage")
                    : Translation.Localize ("DeleteDocumentMessage");

                var confirm = await parent.DisplayAlert ("", textToDisplay, Translation.Localize ("Yes"), Translation.Localize ("No"));

                if (confirm) {
                    var deleteService = DependencyService.Get<IDeleteService> ();
                    if (deleteService == null)
                        return;

                    deleteService.DeleteFile (fileItem.FilePath, (bool completed) => {
                        if (completed == true) {
                            var ViewModel = (MyDocumentsViewModel)this.Parent.BindingContext;
                            ViewModel.DocFileID = fileItem.Id;
                            ViewModel.DeleteDocumentsCommand.Execute (null);
                        }
                    });

                }
            };

            Grid grid = new Grid {
                Padding = 5,
                VerticalOptions = LayoutOptions.Center,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = GridLength.Auto },
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                }
            };

            Grid details = new Grid {
                Padding = 5,
                VerticalOptions = LayoutOptions.Start,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },

                }
            };

            details.Children.Add (publishLabel, 0, 0);
            details.Children.Add (nameLabel, 0, 1);
            details.Children.Add (descriptionLabel, 0, 2);
            details.Children.Add (readOnline, 0, 3);
            details.Children.Add (download, 0, 4);

            Grid leftdetails = new Grid {
                Padding = 5,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                }
            };

            leftdetails.Children.Add (thumbnailImage, 0, 0);
            leftdetails.Children.Add (downloadLabel, 0, 1);

            grid.Children.Add (leftdetails, 0, 0);
            grid.Children.Add (details, 1, 0);

            var frame = new Frame {
                OutlineColor = Color.FromRgba (255, 255, 255, 0.5),
                HasShadow = true,
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor = Color.FromRgba (255, 255, 255, 0.1),
                VerticalOptions = LayoutOptions.Center,
                Padding = 5,
            };

            Device.OnPlatform (
                iOS: () => {
                    frame.Content = new StackLayout {
                        Padding = 0,
                        Children = {
                            grid
                        }
                    };
                },
                Android: () => {
                    frame.Content = new AbsoluteLayout {
                        Padding = 0,
                        Children = {
                            grid
                        }
                    };
                }
            );

            this.View = frame;
        }
Beispiel #20
0
        public CartCell(Product product,Page parent)
        {
            //change PriceLabel
            //mQuantity = Convert.ToInt32 (product.Quantity.Split (' ') [0]);
            //mQuantityLabel = product.Quantity.Split (' ') [1];
            mProduct = product;
            mParentPage = parent;
            bIsFavorite = mFavoriteModel.IsProductFavorite (product.ProductID);

            Grid mainCellView = new Grid (){
                RowSpacing = 0,
                ColumnSpacing = 0,
                Padding = 0,
                BackgroundColor=Color.FromRgb(51,51,51),
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = MyDevice.GetScaledSize(150),
                WidthRequest = MyDevice.GetScaledSize(535)
            };

            //mainCellView.BackgroundColor = Color.Red;
            mainCellView.ColumnDefinitions.Add (new ColumnDefinition (){ Width = MyDevice.GetScaledSize(535) } );
            mainCellView.RowDefinitions.Add (new RowDefinition (){ Height = MyDevice.GetScaledSize(148) } );
            mainCellView.RowDefinitions.Add (new RowDefinition (){ Height = MyDevice.GetScaledSize(2) } );

            var mainLayout = new RelativeLayout () {
                HeightRequest = MyDevice.GetScaledSize(148),
                WidthRequest = MyDevice.GetScaledSize(535),
                Padding = 0,
                BackgroundColor = Color.FromRgb(253,59,47)
            };

            var cellLayout = new MR.Gestures.RelativeLayout () {
                HeightRequest = MyDevice.GetScaledSize(148),
                WidthRequest = MyDevice.GetScaledSize(535),
                Padding = 0,
                BackgroundColor=Color.FromRgb(51,51,51)
            };

            var productImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(126),
                HeightRequest = MyDevice.GetScaledSize(122),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false
            };

            /*PCLStorage.IFolder folder=null;

            if (mParentPage is BrowseProductsPage) {
                folder = (mParentPage as BrowseProductsPage).mParent.mFolder;
            } else if (mParentPage is FavoritesPage) {
                folder = (mParentPage as FavoritesPage).mParent.mFolder;
            } else if (mParentPage is SearchPage) {
                folder = (mParentPage as SearchPage).mParent.mFolder;
            }*/
            /*
            if( folder.CheckExistsAsync(ProductModel.mRootFolderPath + "/" + ParseConstants.IMAGE_FOLDER_NAME + "/" + mProduct.ProductImageName).Result != PCLStorage.ExistenceCheckResult.NotFound)
                productImage.Source = ProductModel.mRootFolderPath + "/" + ParseConstants.IMAGE_FOLDER_NAME + "/" + mProduct.ProductImageName;
            else
                productImage.Source = ImageSource.FromResource("bluemart.SavedImages."+mProduct.ProductImageName);
            */
            productImage.Source = mProduct.ProductImagePath;

            var imageMask = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(126),
                HeightRequest = MyDevice.GetScaledSize(122),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "CartPage_ImageMask.png"
            };

            mFavoriteImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(39),
                HeightRequest = MyDevice.GetScaledSize(32),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false
            };

            var favoriteButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(84),
                HeightRequest = MyDevice.GetScaledSize(71),
                BackgroundColor = Color.Transparent
            };

            if (!bIsFavorite) {
                mFavoriteImage.Source = "CartPage_AddFavorites.png";
            } else {
                mFavoriteImage.Source = "CartPage_RemoveFavorites.png";
            }

            mProductPriceLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(102),
                HeightRequest = MyDevice.GetScaledSize(40),
                HorizontalTextAlignment = TextAlignment.End,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.White,
                FontSize = MyDevice.FontSizeMedium
            };

            UpdatePriceLabel();

            var productNameLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(225),
                HeightRequest = MyDevice.GetScaledSize(40),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.White,
                FontSize = MyDevice.FontSizeMicro,
                Text = product.Name
            };

            var productQuantityLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(225),
                HeightRequest = MyDevice.GetScaledSize(26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb(152,152,152),
                FontSize = MyDevice.FontSizeMicro,
                Text = product.Quantity
            };

            mRemoveImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(27),
                HeightRequest = MyDevice.GetScaledSize(21),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "CartPage_RemoveProduct.png"
            };

            var removeProductButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(59),
                HeightRequest = MyDevice.GetScaledSize(49),
                BackgroundColor = Color.Transparent
            };

            mProductNumberLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize(120),
                HeightRequest = MyDevice.GetScaledSize(47),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                BackgroundColor = Color.FromRgb(152,152,152),
                TextColor = Color.FromRgb(51,51,51),
                FontSize = MyDevice.FontSizeSmall
            };

            UpdateNumberLabel ();

            mAddImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(27),
                HeightRequest = MyDevice.GetScaledSize(21),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "CartPage_AddProduct.png"
            };

            var addProductButton = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(59),
                HeightRequest = MyDevice.GetScaledSize(49),
                BackgroundColor = Color.Transparent
            };

            var deleteButton = new Label () {
                WidthRequest = MyDevice.GetScaledSize(167),
                HeightRequest = MyDevice.GetScaledSize(147),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                BackgroundColor = Color.FromRgb(253,59,47),
                TextColor = Color.White,
                FontSize = MyDevice.FontSizeSmall,
                Text = "DELETE"
            };

            var cartTapRecogniser = new TapGestureRecognizer ();

            cartTapRecogniser.Tapped += (sender, e) => {
                if( !IsOpen )
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(-164),0,300,Easing.Linear);
                else
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(0),0,300,Easing.Linear);
                IsOpen = !IsOpen;
            };

            cellLayout.GestureRecognizers.Add (cartTapRecogniser);

            cellLayout.Swiped += (object sender, MR.Gestures.SwipeEventArgs e) =>
            {
                if( !IsOpen && e.Direction == MR.Gestures.Direction.Left )
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(-164),0,300,Easing.Linear);
                else if( IsOpen && e.Direction == MR.Gestures.Direction.Right )
                    cellLayout.TranslateTo( MyDevice.GetScaledSize(0),0,300,Easing.Linear);
                IsOpen = !IsOpen;
            };

            var deleteButtonTapRecogniser = new TapGestureRecognizer ();
            deleteButtonTapRecogniser.Tapped += (sender, e) => {
                Cart.ProductTotalPrice -= (mProduct.ProductNumberInCart-1)*mProduct.Price;
                mProduct.ProductNumberInCart = 1;

                if (mParentPage is BrowseProductsPage) {
                    foreach (var productCell in (mParentPage as BrowseProductsPage).mProductCellList) {
                        if (productCell.mProduct.ProductID == mProduct.ProductID) {

                            productCell.DeactivateAddMenu ();
                        }
                    }
                }
                else if (mParentPage is SearchPage) {
                    foreach (var productCell in (mParentPage as SearchPage).mProductCellList) {
                        if (productCell.mProduct.ProductID == mProduct.ProductID) {
                            productCell.DeactivateAddMenu ();
                        }
                    }
                }
                else if (mParentPage is FavoritesPage) {
                    foreach (var productCell in (mParentPage as FavoritesPage).mProductCellList) {
                        if (productCell.mProduct.ProductID == mProduct.ProductID) {
                            productCell.DeactivateAddMenu ();
                        }
                    }
                }

                RemoveProductFromCart();
            };
            deleteButton.GestureRecognizers.Add (deleteButtonTapRecogniser);

            var removeProductTapRecogniser = new TapGestureRecognizer ();
            removeProductTapRecogniser.Tapped += (sender, e) => {
                RemoveProductFromCart();
            };
            removeProductButton.GestureRecognizers.Add (removeProductTapRecogniser);

            var addProductTapRecogniser = new TapGestureRecognizer ();
            addProductTapRecogniser.Tapped += (sender, e) => {
                AddProductInCart();
            };
            addProductButton.GestureRecognizers.Add (addProductTapRecogniser);

            var favoriteTapRecogniser = new TapGestureRecognizer ();
            favoriteTapRecogniser.Tapped += (sender, e) => {
                if( !bIsFavorite )
                {
                    mFavoriteModel.AddProductID(mProduct.ProductID);
                    mFavoriteImage.Source = "CartPage_RemoveFavorites.png";
                    bIsFavorite = true;
                }
                else
                {
                    mFavoriteModel.RemoveProductID(mProduct.ProductID);
                    mFavoriteImage.Source = "CartPage_AddFavorites.png";
                    bIsFavorite = false;
                }
            };
            favoriteButton.GestureRecognizers.Add (favoriteTapRecogniser);

            mainLayout.Children.Add (deleteButton,
                Constraint.Constant (MyDevice.GetScaledSize (368)),
                Constraint.Constant (0)
            );

            mainLayout.Children.Add (cellLayout,
                Constraint.Constant (0),
                Constraint.Constant (0)
            );

            cellLayout.Children.Add (productImage,
                Constraint.Constant (MyDevice.GetScaledSize(12)),
                Constraint.Constant (MyDevice.GetScaledSize(12))
            );

            cellLayout.Children.Add (imageMask,
                Constraint.RelativeToView (productImage, (p,sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (productImage, (p,sibling) => {
                    return sibling.Bounds.Top;
                })
            );

            cellLayout.Children.Add (mFavoriteImage,
                Constraint.Constant (MyDevice.GetScaledSize(479)),
                Constraint.Constant (MyDevice.GetScaledSize(27))
            );

            cellLayout.Children.Add (favoriteButton,
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(24);
                }),
                Constraint.Constant(0)
            );

            cellLayout.Children.Add (mProductPriceLabel,
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Right - MyDevice.GetScaledSize(102);
                }),
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(30);
                })
            );

            cellLayout.Children.Add (productNameLabel,
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(278);
                }),
                Constraint.RelativeToView(mFavoriteImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(8);
                })
            );

            cellLayout.Children.Add (productQuantityLabel,
                Constraint.RelativeToView(productNameLabel, (p,sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView(productNameLabel, (p,sibling) => {
                    return sibling.Bounds.Bottom;
                })
            );

            cellLayout.Children.Add (mRemoveImage,
                Constraint.RelativeToView(productQuantityLabel, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(7);
                }),
                Constraint.RelativeToView(productQuantityLabel, (p,sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(15);
                })
            );

            cellLayout.Children.Add (removeProductButton,
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(11);
                }),
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(14);
                })
            );

            cellLayout.Children.Add (mProductNumberLabel,
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Right + MyDevice.GetScaledSize(18);
                }),
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(14);
                })
            );

            cellLayout.Children.Add (mAddImage,
                Constraint.RelativeToView(mProductNumberLabel, (p,sibling) => {
                    return sibling.Bounds.Right + MyDevice.GetScaledSize(18);
                }),
                Constraint.RelativeToView(mRemoveImage, (p,sibling) => {
                    return sibling.Bounds.Top;
                })
            );

            cellLayout.Children.Add (addProductButton,
                Constraint.RelativeToView(mAddImage, (p,sibling) => {
                    return sibling.Bounds.Left - MyDevice.GetScaledSize(11);
                }),
                Constraint.RelativeToView(mAddImage, (p,sibling) => {
                    return sibling.Bounds.Top - MyDevice.GetScaledSize(14);
                })
            );

            var bottomLayout = new RelativeLayout () {
                HeightRequest = MyDevice.GetScaledSize(2),
                WidthRequest = MyDevice.GetScaledSize(535),
                BackgroundColor = Color.FromRgb(129,129,129),
                Padding = 0
            };

            mainCellView.Children.Add (mainLayout, 0, 0);
            mainCellView.Children.Add (bottomLayout, 0, 1);

            this.View = mainCellView;
        }
        public GridViewCellTemplate()
        {
            //			var thumbnailImage = new Image () {
            //				HorizontalOptions = LayoutOptions.Center,
            //				VerticalOptions = LayoutOptions.Center,
            //				BackgroundColor = ColorConstants.SemiOpaqueBackground,
            //				WidthRequest = UIConstants.GetGridViewItemWidths (),
            //				HeightRequest = UIConstants.GetGridViewItemHeights () - 40,
            //				Source = "New/foldedpdf.png"
            //			};
            //			thumbnailImage.SetBinding (Image.SourceProperty, new Binding ("ThumbPath", converter: new NoCacheConverter ()));

            var thumbnailImage = new CachedImage () {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                WidthRequest = UIConstants.GetGridViewItemWidths (),
                HeightRequest = UIConstants.GetGridViewItemHeights () - 40,
                BackgroundColor = ColorConstants.SemiOpaqueBackground,

                CacheDuration = TimeSpan.FromDays (30),
                DownsampleHeight = UIConstants.GetThumbnailHeight () - 100,
                RetryCount = 3,
                RetryDelay = 250,
                TransparencyEnabled = false,
                // Shown after loading error occurs:
                ErrorPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png"),
                // Shown before targe image is loaded:
                LoadingPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png"),
            };

            thumbnailImage.SetBinding (CachedImage.SourceProperty, new Binding ("ThumbPath", converter: new NoCacheConverter ()));

            var titleLabel = new CustomLabel2 () {
                FontSize = UIConstants.GetGridViewFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.StartAndExpand,
                WidthRequest = UIConstants.GetGridViewItemWidths (),
                HeightRequest = 40,
            };
            titleLabel.SetBinding (Label.TextProperty, "FileName");

            Device.OnPlatform (
                iOS: () => {
                    this.View = new StackLayout {
                        WidthRequest = UIConstants.GetGridViewItemWidths (),
                        HeightRequest = UIConstants.GetGridViewItemHeights (),
                        Orientation = StackOrientation.Vertical,
                        Children = {
                            thumbnailImage,
                            titleLabel
                        }
                    };
                },
                Android: () => {
                    this.View = new AbsoluteLayout {
                        WidthRequest = UIConstants.GetGridViewItemWidths (),
                        HeightRequest = UIConstants.GetGridViewItemHeights (),
                        //Orientation = StackOrientation.Vertical,
                        Children = {
                            thumbnailImage,
                            titleLabel
                        }
                    };
                }
            );
        }
		async void popUpPage(CachedImage rImage){
			await Task.Yield ();
			await PopupNavigation.PushAsync (new ImagePopupPage (rImage, data), false);
		}
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged ();

            dynamic c = BindingContext;

            Grid details = new Grid {
                //Padding = 5,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                }
            };

            var thumbnailImage = new CachedImage {
                Aspect = Aspect.AspectFit,
                Source = c.ThumbPath,
                HorizontalOptions =
                    LayoutOptions.CenterAndExpand,
                VerticalOptions =
                    LayoutOptions.CenterAndExpand,
                HeightRequest = 183,
                WidthRequest = 183,
                BackgroundColor = ColorConstants.SemiOpaqueBackground,
                CacheDuration = TimeSpan.FromDays (30),
                DownsampleHeight = 80,
                RetryCount = 3,
                RetryDelay = 250,
                TransparencyEnabled = false,
                ErrorPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png"),
                LoadingPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png"),
            };

            var title = new CustomLabel2 () {
                Text = c.FileName,
                FontSize = UIConstants.GetGridViewFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.End,
                WidthRequest = 183,
                HeightRequest = 40,
            };

            details.Children.Add (thumbnailImage, 0, 0);
            details.Children.Add (title, 0, 1);

            var layout = new StackLayout {
                Padding = 0,
                //Orientation  = LayoutOptions.,
                Children = {
                    details
                }
            };

            View = layout;
        }
Beispiel #24
0
		private void InitializeCartLayout()
		{
			mCartLayout = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(mCartWidth),
				HeightRequest = MyDevice.ScreenHeight,
				BackgroundColor = Color.FromRgb(51,51,51),
				Padding = 0
			};

			UserClass user = mUserModel.GetUser ();
			AddressClass activeAdress = mAddressModel.GetActiveAddress (user.ActiveRegion);
			string userName = "";
			if (activeAdress != null)
				userName = activeAdress.Name;

			var userNameLabel = new Label () {				
				Text = userName.Split(' ')[0],
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.End,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(190),
				HeightRequest = MyDevice.GetScaledSize(85)
			};

			var titleLabel = new Label () {
				Text = "'s Basket (AED)",
				TextColor = Color.FromRgb(152,152,152),
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(250),
				HeightRequest = MyDevice.GetScaledSize(85)
			};

			var profilePic = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(33),
				HeightRequest = MyDevice.GetScaledSize(37),
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false,
				Source = "CartPage_ProfilePic.png"
			};

			var firstLine = new BoxView (){
				HeightRequest = 1,
				WidthRequest = MyDevice.GetScaledSize(mCartWidth),
				Color = Color.FromRgb(129,129,129)
			};

			/*CartStackLayout = new StackLayout {
				Orientation = StackOrientation.Vertical,
				Padding = 0,
				Spacing = 0
			};	*/				

			cartListView = new ListView()
			{
				RowHeight = (int)MyDevice.GetScaledSize(150)
			};
			cartListView.ItemTemplate = new DataTemplate (typeof(CartCellNew));
			/*var cartScrollView = new ScrollView {
				Orientation = ScrollOrientation.Vertical,
				Content = CartStackLayout
			};*/

			var bottomLayout = new RelativeLayout () {
				BackgroundColor = Color.Black,
				WidthRequest = MyDevice.GetScaledSize(mCartWidth),
				HeightRequest = MyDevice.GetScaledSize(239)
			};

			var subtotalLabel = new Label () {
				Text = "Subtotal",
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(140),
				HeightRequest = MyDevice.GetScaledSize(51)
			};

			subtotalPriceLabel = new Label () {
				Text = "1055,85",
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.End,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(130),
				HeightRequest = MyDevice.GetScaledSize(51)
			};

			var deliveryFeeLabel = new Label () {
				Text = "Delivery Fee",
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(213),
				HeightRequest = MyDevice.GetScaledSize(51)
			};

			var deliveryFeePriceLabel = new Label () {
				Text = "FREE",
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.End,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(130),
				HeightRequest = MyDevice.GetScaledSize(51)
			};

			var checkoutLabel = new Label () {
				Text = "Checkout Now",
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.Start,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeMedium,
				WidthRequest = MyDevice.GetScaledSize(251),
				HeightRequest = MyDevice.GetScaledSize(60)
			};

			checkoutPriceLabel = new Label () {
				Text = "1055,85",
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.End,
				VerticalTextAlignment = TextAlignment.Center,
				FontSize = MyDevice.FontSizeSmall,
				WidthRequest = MyDevice.GetScaledSize(200),
				HeightRequest = MyDevice.GetScaledSize(60)
			};

			var checkoutButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(493),
				HeightRequest = MyDevice.GetScaledSize(60),
				BackgroundColor = Color.FromRgb(253,59,47)
			};

			var checkoutTapRecogniser = new TapGestureRecognizer ();
			checkoutTapRecogniser.Tapped += async (sender, e) => {
				var hour = Time.GetTime();

				if( hour < 8 || hour > 23 ) 
				{
					await DisplayAlert("Sorry","Market is closed between 8 AM and 11 PM ","OK");
				}
				else if( Cart.ProductTotalPrice == 0 )
					await DisplayAlert("Sorry","Please add products in your basket","OK");
				else if( mAddressModel.GetActiveAddress(mUserModel.GetUser().ActiveRegion) == null )
				{					
					await DisplayAlert("Sorry","Please Enter Your Address On Settings Page","OK");
					mParent.LoadSettingsPage();
				}
				else if( Cart.ProductTotalPrice < 50 )
				{
					await DisplayAlert("Sorry","Your orders must exceed 50 AED, as it is the minimum amount.","OK");
				}
				else
					mParent.LoadReceiptPage();
			};
			checkoutButton.GestureRecognizers.Add (checkoutTapRecogniser);

			mainRelativeLayout.Children.Add (mCartLayout,
				Constraint.Constant (MyDevice.ScreenWidth),
				Constraint.Constant (0)
			);

			mCartLayout.Children.Add (profilePic,
				Constraint.Constant (MyDevice.GetScaledSize(mCartWidth-43.5f)),
				Constraint.Constant (MyDevice.GetScaledSize(25f))
			);

			mCartLayout.Children.Add (titleLabel,
				Constraint.RelativeToView (profilePic, (parent,sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize(268);	
				} ),
				Constraint.Constant (0)
			);

			mCartLayout.Children.Add (userNameLabel,
				Constraint.RelativeToView (titleLabel, (parent,sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize(190);	
				} ),
				Constraint.Constant (0)
			);

			mCartLayout.Children.Add (firstLine,
				Constraint.Constant(0),
				Constraint.RelativeToView (userNameLabel, (parent,sibling) => {
					return sibling.Bounds.Bottom + MyDevice.GetScaledSize(2);
				})
			);

			mCartLayout.Children.Add (cartListView,
				Constraint.Constant(MyDevice.GetScaledSize(0)),
				Constraint.RelativeToView (firstLine, (parent,sibling) => {
					return sibling.Bounds.Bottom;
				}),
				Constraint.Constant(MyDevice.GetScaledSize(mCartWidth)),
				Constraint.Constant(MyDevice.ScreenHeight - MyDevice.GetScaledSize(324))
			);

			mCartLayout.Children.Add (bottomLayout,
				Constraint.Constant(0),
				Constraint.RelativeToView( mCartLayout, (parent,sibling) =>
					{
						return sibling.Bounds.Bottom - MyDevice.GetScaledSize(239);
					})
			);

			bottomLayout.Children.Add (subtotalLabel,
				Constraint.Constant(MyDevice.GetScaledSize(55)),	
				Constraint.Constant(MyDevice.GetScaledSize(25))
			);

			bottomLayout.Children.Add (subtotalPriceLabel,
				Constraint.Constant(MyDevice.GetScaledSize(mCartWidth-179)),	
				Constraint.Constant(MyDevice.GetScaledSize(25))
			);

			bottomLayout.Children.Add (deliveryFeeLabel,
				Constraint.RelativeToView( subtotalLabel, (parent,sibling) => {
					return sibling.Bounds.Left;	
				}),	
				Constraint.RelativeToView( subtotalLabel, (parent,sibling) => {
					return sibling.Bounds.Bottom;	
				})
			);

			bottomLayout.Children.Add (deliveryFeePriceLabel,
				Constraint.RelativeToView( subtotalPriceLabel, (parent,sibling) => {
					return sibling.Bounds.Left;	
				}),	
				Constraint.RelativeToView( subtotalPriceLabel, (parent,sibling) => {
					return sibling.Bounds.Bottom;	
				})
			);

			bottomLayout.Children.Add (checkoutButton,
				Constraint.RelativeToView (deliveryFeeLabel, (parent, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize(22);	
				}),	
				Constraint.RelativeToView (deliveryFeeLabel, (parent, sibling) => {
					return sibling.Bounds.Bottom;	
				})
			);

			bottomLayout.Children.Add (checkoutLabel,
				Constraint.RelativeToView( deliveryFeeLabel, (parent,sibling) => {
					return sibling.Bounds.Left;	
				}),	
				Constraint.RelativeToView( deliveryFeeLabel, (parent,sibling) => {
					return sibling.Bounds.Bottom;	
				})
			);

			bottomLayout.Children.Add (checkoutPriceLabel,
				Constraint.RelativeToView( checkoutLabel, (parent,sibling) => {
					return sibling.Bounds.Right;	
				}),	
				Constraint.RelativeToView( deliveryFeePriceLabel, (parent,sibling) => {
					return sibling.Bounds.Bottom;	
				})
			);
		}
        public NewsLetterCellTemplate()
        {
            var publishLabel = new Label () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            publishLabel.SetBinding (Label.TextProperty, new Binding ("PublicationDate", converter: new DateConverter ()));

            var nameLabel = new CustomLabel () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.StartAndExpand,
                //LineBreakMode = LineBreakMode.TailTruncation,
            };
            nameLabel.SetBinding (Label.TextProperty, "FileName");

            var descriptionLabel = new CustomLabel () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.StartAndExpand,
                //LineBreakMode = LineBreakMode.TailTruncation,
            };
            descriptionLabel.SetBinding (Label.TextProperty, "Description");

            Device.OnPlatform (iOS: () => {
                nameLabel.LineBreakMode = LineBreakMode.TailTruncation;
                descriptionLabel.LineBreakMode = LineBreakMode.TailTruncation;
            });

            var thumbnailImage = new CachedImage () {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions = LayoutOptions.StartAndExpand,
                HeightRequest = UIConstants.GetThumbnailHeight (),
                WidthRequest = UIConstants.GetThumbnailWidth (),
                BackgroundColor = ColorConstants.SemiOpaqueBackground,

                CacheDuration = TimeSpan.FromDays (30),
                DownsampleHeight = UIConstants.GetThumbnailHeight () - 100,
                RetryCount = 3,
                RetryDelay = 250,
                TransparencyEnabled = false,
                ErrorPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png"),
                LoadingPlaceholder = Device.OnPlatform (iOS: "corningimages/loading.png", Android: "loading.png", WinPhone: "loading.png")

            };

            thumbnailImage.SetBinding (CachedImage.SourceProperty, new Binding ("ThumbPath", converter: new NoCacheConverter ()));

            var downloadLabel = new Label () {
                FontSize = (Device.Idiom == TargetIdiom.Phone)
                    ? Device.GetNamedSize (NamedSize.Small, typeof(Label))
                    : Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            downloadLabel.SetBinding (Label.TextProperty, new Binding ("DownloadDate", converter: new DownloadDateConverter ()));

            //Read Online Button
            var readOnline = new Button () {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.Center,
                BackgroundColor = Color.FromHex ("#006699"),
                TextColor = Color.White,
                HeightRequest = UIConstants.GetButtonHeight (),
                WidthRequest = UIConstants.GetButtonWidth (),
            };
            readOnline.SetBinding (Button.TextProperty, new Binding ("ButtonText"));
            readOnline.SetBinding (Button.CommandParameterProperty, new Binding ("."));

            readOnline.Clicked += (sender, e) => {

                var btn = ((Button)sender);
                var ViewModel = (NewsLetterViewModel)this.Parent.BindingContext;
                var currentItem = (ProductCatalog)btn.CommandParameter;
                var fileItem = ViewModel.Files.ToList ().FirstOrDefault (i => i.Id == currentItem.Id);

                var pdfService = DependencyService.Get<IPdfService> ();
                if (pdfService == null)
                    return;

                if (fileItem.CategoryCode == "newsletter") {
                    pdfService.OpenPDF (LibraryType.NewsLetter, fileItem.FilePath, fileItem.FileName, 0, null);
                } else {
                    pdfService.OpenPDF (LibraryType.All, fileItem.FilePath, fileItem.FileName, 0, null);

                }

            };

            //Download Button
            var download = new Button () {
                Text = Translation.Localize ("DownloadText"),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.Center,
                BackgroundColor = Color.FromHex ("#006699"),
                TextColor = Color.White,
                HeightRequest = UIConstants.GetButtonHeight (),
                WidthRequest = UIConstants.GetButtonWidth (),
            };
            download.SetBinding (Button.TextProperty, new Binding ("DownloadDate", converter: new DownloadTextConverter ()));
            download.SetBinding (Button.CommandParameterProperty, new Binding ("."));

            download.Clicked += async (sender, e) => {

                var btn = ((Button)sender);
                var currentItem = (ProductCatalog)btn.CommandParameter;

                var ViewModel = (NewsLetterViewModel)this.Parent.BindingContext;
                var parent = (NewsletterView)this.ParentView.ParentView.Parent;

                var fileItem = ViewModel.Files.ToList ().FirstOrDefault (i => i.Id == currentItem.Id);
                if (fileItem.DownloadDate == null) {

                    if (GlobalVariables.WifiDownloadOnly) {
                        if (!App.IsWifiReachable ()) {
                            await parent.DisplayAlert ("", GlobalVariables.WifiConnectionOnlyAlert, Translation.Localize ("Ok"));
                            return;
                        }
                    }

                    var textToDisplay =
                        currentItem.MimeType.StartsWith ("mp4")
                        ? Translation.Localize ("DownloadVideoMessage")
                        : Translation.Localize ("DownloadDocumentMessage");

                    var confirm = await parent.DisplayAlert ("", textToDisplay, Translation.Localize ("Yes"), Translation.Localize ("No"));

                    if (confirm) {
                        var pdfService = DependencyService.Get<IDownloadService> ();
                        if (pdfService == null)
                            return;

                        pdfService.DownloadData (fileItem, (string filePath) => {
                            if (filePath != "") {
                                fileItem.FilePath = filePath;
                                fileItem.ThumbPath = filePath.Replace (".pdf", ".jpeg").Replace (".mp4", ".jpeg");
                                if (fileItem.MimeType.StartsWith ("mp4"))
                                    readOnline.Text = Translation.Localize ("PlayOfflineText");
                                else
                                    readOnline.Text = Translation.Localize ("ReadOfflineText");
                                //
                                download.Text = Translation.Localize ("DeleteText");
                                downloadLabel.Text = DateTime.Now.ToString ("d");
                                ViewModel.fileItem = fileItem;
                                ViewModel.InsertDocumentsCommand.Execute (null);
                            }
                        });
                    }
                } else {
                    var textToDisplay = currentItem.MimeType.StartsWith ("mp4")
                        ? Translation.Localize ("DeleteVideoMessage")
                        : Translation.Localize ("DeleteDocumentMessage");
                    var confirm = await parent.DisplayAlert ("", textToDisplay, Translation.Localize ("Yes"), Translation.Localize ("No"));
                    if (confirm) {
                        var deleteService = DependencyService.Get<IDeleteService> ();
                        if (deleteService == null)
                            return;

                        deleteService.DeleteFile (fileItem.FilePath, (bool completed) => {
                            if (completed == true) {

                                if (fileItem.MimeType.StartsWith ("mp4"))
                                    readOnline.Text = Translation.Localize ("PlayOnlineText");
                                else
                                    readOnline.Text = Translation.Localize ("ReadOnlineText");
                                //
                                download.Text = Translation.Localize ("DownloadText");
                                downloadLabel.Text = "";
                                ViewModel.DocFileID = fileItem.Id;
                                ViewModel.DeleteDocumentsCommand.Execute (null);
                            }
                        });
                    }
                }

            };

            Grid details = new Grid {
                Padding = 5,
                VerticalOptions = LayoutOptions.Start,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },

                }
            };

            details.Children.Add (publishLabel, 0, 0);
            details.Children.Add (nameLabel, 0, 1);
            details.Children.Add (descriptionLabel, 0, 2);
            details.Children.Add (readOnline, 0, 3);
            details.Children.Add (download, 0, 4);

            Grid leftdetails = new Grid {
                Padding = 5,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                }
            };

            leftdetails.Children.Add (thumbnailImage, 0, 0);
            leftdetails.Children.Add (downloadLabel, 0, 1);

            Grid grid = new Grid {
                Padding = 5,
                VerticalOptions = LayoutOptions.Center,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = GridLength.Auto },
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                }
            };
            grid.Children.Add (leftdetails, 0, 0);
            grid.Children.Add (details, 1, 0);

            var frame = new Frame {
                OutlineColor = Color.FromRgba (255, 255, 255, 0.5),
                HasShadow = true,
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor = Color.FromRgba (255, 255, 255, 0.1),
                VerticalOptions = LayoutOptions.StartAndExpand,
                Padding = 5
            };

            Device.OnPlatform (
                iOS: () => {
                    frame.Content = new StackLayout {
                        Padding = 0,
                        Children = {
                            grid
                        }
                    };
                },
                Android: () => {
                    frame.Content = new AbsoluteLayout {
                        Padding = 0,
                        Children = {
                            grid
                        }
                    };
                }
            );
            this.View = frame;
        }
Beispiel #26
0
		private void InitializeHeaderLayout ()
		{
			mTopLayout = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(640),
				HeightRequest = MyDevice.GetScaledSize(87),
				BackgroundColor = Color.FromRgb(27,184,105)
			};

			var menuIcon = new Image () {
				WidthRequest = MyDevice.GetScaledSize(36),
				HeightRequest = MyDevice.GetScaledSize(37),
				Source = "CategoriesPage_MenuIcon.png"
			};

			var categoryLabel = new Label (){ 
				Text = "Search",
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeLarge
			};

			PriceLabel = new Label () {
				Text = "0\nAED",	
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeSmall,
				HorizontalTextAlignment = TextAlignment.End,
				WidthRequest = MyDevice.GetScaledSize(130)
			};

			var verticalLine = new CachedImage () {
				WidthRequest = MyDevice.GetScaledSize(1),
				HeightRequest = MyDevice.GetScaledSize(63),
				CacheDuration = TimeSpan.FromDays(30),
				DownsampleToViewSize = true,
				RetryCount = 10,
				RetryDelay = 250,
				TransparencyEnabled = false,
				FadeAnimationEnabled = false,
				Source = "CategoriesPage_VerticalLine.png"
			};

			mCartImage = new Image () {
				WidthRequest = MyDevice.GetScaledSize(71),
				HeightRequest = MyDevice.GetScaledSize(57),
				Source = "ProductsPage_BasketIcon.png"
			};

			ProductCountLabel = new Label () {					
				TextColor = Color.White,
				FontSize = MyDevice.FontSizeMicro,
				HorizontalTextAlignment = TextAlignment.Center,
				VerticalTextAlignment = TextAlignment.Center,
				WidthRequest = MyDevice.GetScaledSize(37),
				HeightRequest = MyDevice.GetScaledSize(27)
			};

			var menuButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(72),
				HeightRequest = MyDevice.GetScaledSize(86)
			};

			var cartButton = new RelativeLayout () {
				WidthRequest = MyDevice.GetScaledSize(90),
				HeightRequest = MyDevice.GetScaledSize(90),
				Padding = 0
			};

			var menuTapRecognizer= new TapGestureRecognizer ();
			menuTapRecognizer.Tapped += (sender, e) => {				
				ActivateOrDeactivateMenu();
			};
			menuButton.GestureRecognizers.Add(menuTapRecognizer);

			var cartTapRecognizer= new TapGestureRecognizer ();
			cartTapRecognizer.Tapped += (sender, e) => {				
				ActivateOrDeactivateCart();
			};
			cartButton.GestureRecognizers.Add(cartTapRecognizer);

			mMidLayout.Children.Add (mTopLayout,
				Constraint.Constant (0),
				Constraint.Constant (0)
			);

			mMidLayout.Children.Add (menuIcon, 
				Constraint.RelativeToParent (parent => {
					return parent.Bounds.Left +  MyDevice.GetScaledSize(20);
				}),
				Constraint.RelativeToParent (parent => {
					return parent.Bounds.Top + MyDevice.GetScaledSize(27);
				})
			);

			mMidLayout.Children.Add (categoryLabel,
				Constraint.RelativeToView (menuIcon, (parent, sibling) => {
					return sibling.Bounds.Right + MyDevice.GetScaledSize (22);
				}),
				Constraint.RelativeToView (menuIcon, (parent, sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize (3);
				})
			);

			mMidLayout.Children.Add (mCartImage, 
				Constraint.Constant( MyDevice.GetScaledSize(561) ),
				Constraint.Constant( MyDevice.GetScaledSize(16) )
			);

			mMidLayout.Children.Add (verticalLine,
				Constraint.RelativeToView (mCartImage, (parent, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (14);
				}),
				Constraint.RelativeToView (mCartImage, (parent, sibling) => {
					return sibling.Bounds.Top - MyDevice.GetScaledSize (5);
				})
			);

			mMidLayout.Children.Add (PriceLabel,
				Constraint.RelativeToView (verticalLine, (parent, sibling) => {
					return sibling.Bounds.Left - MyDevice.GetScaledSize (150);
				}),
				Constraint.RelativeToView (mCartImage, (parent, sibling) => {
					return sibling.Bounds.Top;
				})
			);

			mMidLayout.Children.Add (ProductCountLabel,
				Constraint.RelativeToView (mCartImage, (parent, sibling) => {
					return sibling.Bounds.Right - MyDevice.GetScaledSize (37);
				}),
				Constraint.RelativeToView (mCartImage, (parent, sibling) => {
					return sibling.Bounds.Bottom - MyDevice.GetScaledSize (27);
				})
			);	

			mMidLayout.Children.Add (menuButton,
				Constraint.Constant (0),
				Constraint.Constant (0));

			mMidLayout.Children.Add (cartButton,
				Constraint.Constant(MyDevice.GetScaledSize(550)),
				Constraint.Constant (0)
			);

			UpdateProductCountLabel ();
			UpdatePriceLabel ();
		}
Beispiel #27
0
        public HistoryCell(HistoryClass history, TrackPage rootPage)
        {
            mRootPage = rootPage;
            mHistoryClass = history;

            var mainLayout = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(600),
                HeightRequest = MyDevice.GetScaledSize(138),
                BackgroundColor = Color.White,
                Padding = 0
            };

            var backgroundImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(32),
                HeightRequest = MyDevice.GetScaledSize(32),
                Aspect = Aspect.Fill,
                Source = "TrackPage_HistroyBackground.png",
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false
            };

            var totalPriceLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (455),
                HeightRequest = MyDevice.GetScaledSize(26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb(98,98,98),
                Text = "Total Price: " + history.TotalPrice + " AED",
                FontSize = MyDevice.FontSizeMicro
            };

            DateTime historyDate = DateTime.Now;

            DateTime.TryParse(history.Date,out historyDate);
            DateTime addedHistoryDate = historyDate.AddHours (2);

            var dateLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (455),
                HeightRequest = MyDevice.GetScaledSize(26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb(98,98,98),
                Text = "Date: " + addedHistoryDate.ToString("MM/dd/yyyy") +" - Time: " + addedHistoryDate.ToString("hh:mm:ss"),
                FontSize = MyDevice.FontSizeMicro
            };

            var regionLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (455),
                HeightRequest = MyDevice.GetScaledSize(26),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Start,
                TextColor = Color.FromRgb(98,98,98),
                Text = "Region: " + history.Region,
                FontSize = MyDevice.FontSizeMicro
            };

            var line = new BoxView () {
                WidthRequest = MyDevice.GetScaledSize(600),
                HeightRequest = MyDevice.GetScaledSize(1),
                Color = Color.FromRgb(181,185,187)
            };

            mainLayout.Children.Add (backgroundImage,
                Constraint.Constant(MyDevice.GetScaledSize(51)),
                Constraint.Constant(MyDevice.GetScaledSize(51))
            );

            mainLayout.Children.Add (totalPriceLabel,
                Constraint.Constant(MyDevice.GetScaledSize(140)),
                Constraint.Constant(MyDevice.GetScaledSize(28))
            );

            mainLayout.Children.Add (dateLabel,
                Constraint.RelativeToView (totalPriceLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (totalPriceLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(2);
                })
            );

            mainLayout.Children.Add (regionLabel,
                Constraint.RelativeToView (dateLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (dateLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize(2);
                })
            );

            mainLayout.Children.Add (line,
                Constraint.Constant(0),
                Constraint.Constant(MyDevice.GetScaledSize(137))
            );

            var tapGestureRecognizer = new TapGestureRecognizer ();
            tapGestureRecognizer.Tapped +=  (sender, e) => {
                mRootPage.mParent.LoadReceiptPage(mHistoryClass);
            };
            mainLayout.GestureRecognizers.Add (tapGestureRecognizer);

            this.View = mainLayout;
        }