Exemple #1
0
 protected override void OnBindingContextChanged()
 {
     base.OnBindingContextChanged();
     this.bindedData = BindingContext as HScrollViewCell2Data;
     if (this.bindedData != null)
     {
         //string imageSource = "HScrollDemo.Resources." + this.bindedData.icon;
         string imageSource = this.bindedData.profileImage;
         this.profileImage.Source        = ImageSource.FromFile(imageSource);
         this.profileImage.HeightRequest = profileImageWidth;
         this.profileImage.WidthRequest  = profileImageHeight;
     }
 }
Exemple #2
0
        protected override View CreateContent()
        {
            var searchBarHeight       = MainPage.PageHeight * 0.07;
            var peopleListHeight      = MainPage.PageHeight * 0.15;
            var currentLocationHeight = MainPage.PageHeight * 0.06;
            var placesHeight          = MainPage.PageHeight * 0.20;
            var morePlacesHeight      = MainPage.PageHeight * 0.34;



            var searchImageSize         = MainPage.PageHeight / 25.001;
            var searchContentleftOffset = MainPage.PageHeight / 68.342;
            var searchContenttopOffset  = MainPage.PageHeight / 17.855;

            var addPeopleLabelFontSize    = MainPage.PageHeight / 60.6364;
            var addPeopleImageWidthHeight = MainPage.PageHeight / 18.5;
            var addPeopleConytentWidth    = MainPage.PageHeight / 6.8342;
            // var peopleListHeight = 130;

            var currentLocationImageWidthHeight        = MainPage.PageHeight / 30.171;
            var currentLocationLabelSize               = MainPage.PageHeight / 45.636;
            var currentLocationContentDetailLeftOffset = MainPage.PageHeight / 38.342;
            var currentLocationContentLeftRightOffset  = MainPage.PageHeight / 68.342;

            var placesLabelFontSize = MainPage.PageHeight / 45.636;
            var placesImageWidth    = MainPage.PageHeight / 30.171;
            var placesImageHeight   = MainPage.PageHeight / 30.171;
            var placesOffset        = MainPage.PageHeight / 38.342;

            var placesContentOffset = MainPage.PageHeight / 68.342;

            var searchImageWidth  = MainPage.PageHeight / 30.171;
            var searchImageHeight = MainPage.PageHeight / 30.171;
            var searchOffset      = MainPage.PageHeight / 68.342;

            var morePlacesSearchOffset = MainPage.PageHeight / 32.345;


            #region Page Background
            this.BackgroundColor = Color.LightGray;
            this.Opacity         = 1.0;


            #endregion


            #region Сontent

            #region SearchBar

            var searchEntry = new AppSearchEntryEditor
            {
                ImageSize         = searchImageSize,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Placeholder       = "Search People and Places",
                WidthRequest      = 280,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
            };


            searchPeopleContent = new StackLayout
            {
                Margin          = new Thickness(searchContentleftOffset, searchContenttopOffset, 10, 0),
                BackgroundColor = Color.White,
                HeightRequest   = searchBarHeight,
                Children        =
                {
                    searchEntry
                }
            };


            #endregion



            #region People List
            var addPeopleLabel = new AppLabel
            {
                FontSize = addPeopleLabelFontSize,
                Text     = "Add People",
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.End,
            };



            var addPeopleImage = new AppImageCommand
            {
                Source        = "plus_gray",
                WidthRequest  = addPeopleImageWidthHeight,
                HeightRequest = addPeopleImageWidthHeight,
            };

            addPeopleImage.SetBinding(AppImageCommand.CommandProperty, "AddPeopleCommand");



            var addPeopleContent = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
                WidthRequest      = addPeopleConytentWidth,
                Children          =
                {
                    addPeopleImage, addPeopleLabel
                }
            };

            var dataHScroll2 = new HScrollViewCell2Data[] {
                new HScrollViewCell2Data {
                    name = "jamie luna", profileImage = "default_user", strokeColor = Color.Red
                },
                new HScrollViewCell2Data {
                    name = "barde luna", profileImage = "default_user", strokeColor = Color.Yellow
                },
                new HScrollViewCell2Data {
                    name = "gerald luna", profileImage = "default_user"
                },
                new HScrollViewCell2Data {
                    name = "jamie luna", profileImage = "default_user"
                },
                new HScrollViewCell2Data {
                    name = "gerald luna", profileImage = "default_user"
                },
                new HScrollViewCell2Data {
                    name = "barde luna", profileImage = "default_user"
                },
            };



            HorizontalScrollLayout peopleList = new HorizontalScrollLayout
            {
                ItemSource    = dataHScroll2,
                ItemTemplate  = new DataTemplate(typeof(HScrollViewCell2)),
                HeightRequest = 130,
                //WidthRequest = 170,
                SelectionBackGroundColor = Color.FromHex("#0040FF"),
                MultiSelection           = false,
            };



            peopleListContent = new StackLayout
            {
                BackgroundColor = Color.White,
                HeightRequest   = peopleListHeight,
                Orientation     = StackOrientation.Horizontal,
                Children        =
                {
                    addPeopleContent, peopleList
                }
            };



            #endregion


            #region CurrentLocation


            currentLocationImage = new AppImageCommand
            {
                Source        = "map_gray",
                HeightRequest = currentLocationImageWidthHeight,
                WidthRequest  = currentLocationImageWidthHeight,
            };

            currentLocationImage.SetBinding(AppImageCommand.CommandProperty, "CurrentLocationCommand");

            currentLocationLabel = new AppLabel
            {
                Text = "Current Location",
                VerticalTextAlignment = TextAlignment.Center,
                FontSize = currentLocationLabelSize,
            };



            currentLocationContentDetails = new StackLayout
            {
                Orientation     = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Padding         = new Thickness(currentLocationContentDetailLeftOffset, 0, 0, 0),
                Children        =
                {
                    currentLocationImage, currentLocationLabel
                }
            };


            currentLocationContent = new StackLayout
            {
                Margin          = new Thickness(currentLocationContentLeftRightOffset, 0, currentLocationContentLeftRightOffset, 0),
                BackgroundColor = Color.White,
                HeightRequest   = currentLocationHeight,
                Children        =
                {
                    currentLocationContentDetails
                }
            };

            #endregion

            #region  Places

            schoolImage = new AppImage
            {
                Source        = "star_gray",
                HeightRequest = placesImageHeight,
                WidthRequest  = placesImageHeight,
            };

            schoolLabel = new AppLabel
            {
                Text = "School",
                VerticalTextAlignment = TextAlignment.Center,
                FontSize = placesLabelFontSize,
            };

            schoolContent = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    schoolImage, schoolLabel
                }
            };

            homeLabel = new AppLabel
            {
                Text = "Home",
                VerticalTextAlignment = TextAlignment.Center,
                FontSize = placesLabelFontSize,
            };

            homeImage = new AppImage
            {
                Source        = "star_gray",
                HeightRequest = placesImageHeight,
                WidthRequest  = placesImageWidth,
            };

            homeContent = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    homeImage, homeLabel
                }
            };

            workLabel = new AppLabel
            {
                Text = "Work",
                VerticalTextAlignment = TextAlignment.Center,
                FontSize = placesLabelFontSize,
            };

            workImage = new AppImage
            {
                Source        = "star_gray",
                HeightRequest = placesImageHeight,
                WidthRequest  = placesImageWidth,
            };

            workContent = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    workImage, workLabel
                }
            };


            moreStarredPlacesLabel = new AppTextCommand
            {
                Text = "More Starred Places",
                VerticalTextAlignment = TextAlignment.Center,
                FontSize = placesLabelFontSize,
            };

            moreStarredPlacesLabel.SetBinding(AppCommand.TextProperty, new Binding("MoreStarredPlaces", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage));

            moreStarredPlacesLabel.SetBinding(AppTextCommand.CommandProperty, "MoreStarredPlacesCommand");



            moreStarredPlacesImage = new AppImage
            {
                Source        = "star_gray",
                HeightRequest = placesImageHeight,
                WidthRequest  = placesImageWidth,
            };

            moreStarredPlacesContent = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    moreStarredPlacesImage, moreStarredPlacesLabel
                }
            };


            placesWrapperContent = new StackLayout
            {
                Padding  = new Thickness(placesOffset, placesContentOffset, 0, 0),
                Children =
                {
                    schoolContent, homeContent, workContent, moreStarredPlacesContent
                }
            };

            placesContent = new StackLayout
            {
                Margin          = new Thickness(placesContentOffset, 0, placesContentOffset, 0),
                BackgroundColor = Color.White,
                HeightRequest   = placesHeight,
                Children        =
                {
                    placesWrapperContent
                }
            };

            #endregion


            #region Search



            searchListView = new ListView
            {
                Margin         = new Thickness(searchOffset, 0, searchOffset, 0),
                HasUnevenRows  = true,
                ItemTemplate   = new DataTemplate(typeof(SearchesTemplate)),
                ItemsSource    = SearchData.GetData(),
                SeparatorColor = Color.White,
            };

            searchListView.HasUnevenRows = true;



            morePreviousSerchesImage = new AppImage
            {
                Source        = "clock_gray",
                WidthRequest  = searchImageWidth,
                HeightRequest = searchImageHeight,
            };

            morePreviousSearchesLabel = new AppTextCommand
            {
                Text = "More Previous Searches"
            };

            morePreviousSearchesLabel.SetBinding(AppTextCommand.CommandProperty, "MoreStarredPlacesCommand");

            morePreviousSearchesContent = new StackLayout
            {
                Padding     = new Thickness(morePlacesSearchOffset, 0, 0, searchOffset),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    morePreviousSerchesImage, morePreviousSearchesLabel
                }
            };



            searchContent = new StackLayout
            {
                Margin          = new Thickness(searchOffset, 0, searchOffset, 0),
                BackgroundColor = Color.White,
                HeightRequest   = morePlacesHeight,
                Children        =
                {
                    searchListView, morePreviousSearchesContent
                }
            };



            #endregion

            finalContent = new StackLayout
            {
                Spacing = searchOffset,

                Children =
                {
                    searchPeopleContent, peopleListContent, currentLocationContent, placesContent, searchContent
                }
            };


            #endregion



            _scroll = new ScrollView
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Content           = finalContent
            };

            return(_scroll);
        }