public void InitializeComponents()
        {
            Title = AppConfig.ApplicationName;
            //Icon = "drawer_button.png";
            _mainLayout = new RelativeLayout {
                BackgroundColor = Styles.Colors.PlaceholderColor,
            };

            _placesListView = new ListView {
                HasUnevenRows          = true,
                ItemTemplate           = new DataTemplate(typeof(PlaceViewCell)),
                IsPullToRefreshEnabled = true,
                //Header = listTitle,
            };
            _placesListView.SeparatorVisibility = SeparatorVisibility.None;
            _placesListView.ItemTapped         += _places_ItemTapped;
            _placesListView.Refreshing         += ListView_Refreshing;
            _mainLayout.Children.Add(_placesListView,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height)
                                     );

            _loadingLayoutPlaces = DynamicsLayouts.Loading(AppResources.RetrievingPlaces, Styles.Colors.PlaceholderColor);
            _mainLayout.Children.Add(_loadingLayoutPlaces,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height)
                                     );

            Content = _mainLayout;
        }
        public void InitializeComponents()
        {
            Title = _place.Name;

            _mainLayout = new RelativeLayout();

            _emptyLabel = new Label {
                Style = Styles.Subtitle,
                HorizontalTextAlignment = TextAlignment.Center
            };
            _mainLayout.Children.Add(_emptyLabel,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height)
                                     );

            _loadingLayoutLikes = DynamicsLayouts.Loading(AppResources.RetrievingLikes, Color.Transparent);
            _mainLayout.Children.Add(_loadingLayoutLikes,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height)
                                     );

            _titleLablel = new Label {
                Text      = AppResources.UsersWhoLikes,
                Style     = Styles.Title,
                TextColor = Styles.Colors.SecondaryColor,
                IsVisible = false,
            };
            _mainLayout.Children.Add(_titleLablel,
                                     Constraint.Constant(20),
                                     Constraint.Constant(20),
                                     Constraint.RelativeToParent(p => p.Width - 40),
                                     Constraint.Constant(40)
                                     );

            _userList = new ListView {
                RowHeight    = 80,
                ItemTemplate = new DataTemplate(typeof(UserViewCell)),
                IsVisible    = false,
            };
            _userList.ItemTapped += _userList_ItemTapped;
            _mainLayout.Children.Add(_userList,
                                     Constraint.Constant(0),
                                     Constraint.RelativeToView(_titleLablel, (p, v) => v.Y + v.Height),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToView(_titleLablel, (p, v) => p.Height - v.Height)
                                     );

            Content = _mainLayout;
        }
Exemple #3
0
        private void InitializeComponents()
        {
            Icon  = "drawer_button.png";
            Title = "Starving";

            _mainLayout = new RelativeLayout {
                BackgroundColor = Color.White,
            };

            var headerBoxview = new BoxView {
                BackgroundColor = Styles.Colors.PrimaryColor,
            };

            _mainLayout.Children.Add(headerBoxview,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height / 3)
                                     );

            _picture = new RoundedImage {
                Aspect      = Aspect.AspectFill,
                BorderColor = Styles.Colors.SecondaryColor,
                BorderWidth = 1,
                Source      = "ic_user_picture_placeholder.png",
            };
            _mainLayout.Children.Add(_picture,
                                     Constraint.RelativeToParent(p => p.Width / 2 - 50),
                                     Constraint.RelativeToParent(p => p.Height / 3 - 150),
                                     Constraint.Constant(100),
                                     Constraint.Constant(100)
                                     );

            _nameLabel = new Label {
                Style                   = Styles.Subtitle,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor               = Color.White,
            };
            _mainLayout.Children.Add(_nameLabel,
                                     Constraint.Constant(20),
                                     Constraint.RelativeToView(_picture, (p, v) => v.Y + v.Height),
                                     Constraint.RelativeToParent(p => p.Width - 40),
                                     Constraint.Constant(40)
                                     );

            SearchPlaces = new Button {
                Style = Styles.ActiveButtonStyle,
                Text  = AppResources.SearchPlaces
            };
            _mainLayout.Children.Add(SearchPlaces,
                                     Constraint.RelativeToView(headerBoxview, (p, v) => v.X + 20),
                                     Constraint.RelativeToView(headerBoxview, (p, v) => v.Y + v.Height + 10),
                                     Constraint.RelativeToParent(p => p.Width - 40),
                                     Constraint.Constant(40)
                                     );
            var separator = new BoxView {
                BackgroundColor = Styles.Colors.PlaceholderColor,
            };

            _mainLayout.Children.Add(separator,
                                     Constraint.RelativeToView(SearchPlaces, (p, v) => v.X - 20),
                                     Constraint.RelativeToView(SearchPlaces, (p, v) => v.Y + v.Height + 10),
                                     Constraint.RelativeToView(SearchPlaces, (p, v) => v.Width + 40),
                                     Constraint.Constant(1)
                                     );

            _latestReviewsTitleLabel = new Label {
                Style                   = Styles.Subtitle,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor               = Styles.Colors.PrimaryColor,
            };
            _mainLayout.Children.Add(_latestReviewsTitleLabel,
                                     Constraint.RelativeToView(SearchPlaces, (p, v) => v.X),
                                     Constraint.RelativeToView(separator, (p, v) => v.Y + v.Height + 10),
                                     Constraint.RelativeToView(SearchPlaces, (p, v) => v.Width),
                                     Constraint.Constant(40)
                                     );

            _emptyReviews = new Label {
                IsVisible = false,
                Style     = Styles.Subtitle,
                HorizontalTextAlignment = TextAlignment.Center
            };
            _mainLayout.Children.Add(_emptyReviews,
                                     Constraint.Constant(0),
                                     Constraint.RelativeToView(_latestReviewsTitleLabel, (p, v) => v.Y + v.Height),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToView(_latestReviewsTitleLabel, (p, v) => p.Height - (v.Y + v.Height))
                                     );

            ReviewsList = new ListView {
                RowHeight       = 100,
                ItemTemplate    = new DataTemplate(typeof(ReviewViewCell)),
                BackgroundColor = Color.White,
                IsVisible       = false,
            };
            ReviewsList.ItemsSource = _reviewsCollection;
            _mainLayout.Children.Add(ReviewsList,
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.X),
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.Y),
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.Width),
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.Height)
                                     );

            _reviewsPlaceholderLayout = DynamicsLayouts.Loading(AppResources.RetrievingReviews, Color.Transparent);
            _mainLayout.Children.Add(_reviewsPlaceholderLayout,
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.X),
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.Y),
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.Width),
                                     Constraint.RelativeToView(_emptyReviews, (p, v) => v.Height)
                                     );

            Content = _mainLayout;
        }
        public void InitializeComponents()
        {
            Title       = _place.Name;
            _mainLayout = new RelativeLayout();

            _photo = new Image {
                Aspect = Aspect.AspectFill,
            };
            _mainLayout.Children.Add(_photo,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height / 3)
                                     );

            var photoOverlay = new BoxView {
                BackgroundColor = Color.Black,
                Opacity         = 0.6
            };

            _mainLayout.Children.Add(photoOverlay,
                                     Constraint.RelativeToView(_photo, (p, v) => v.X),
                                     Constraint.RelativeToView(_photo, (p, v) => v.Y),
                                     Constraint.RelativeToView(_photo, (p, v) => v.Width),
                                     Constraint.RelativeToView(_photo, (p, v) => v.Height)
                                     );

            _nameLabel = new Label {
                Style             = Styles.Title,
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            _openIndicator = new RoundedBoxView {
                BackgroundColor   = Color.FromHex("#95a5a6"),
                CornerRadius      = 5,
                HeightRequest     = 10,
                WidthRequest      = 10,
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Start,
            };

            _vicinityLabel = new Label {
                TextColor             = Color.White,
                Style                 = Styles.Subtitle,
                VerticalTextAlignment = TextAlignment.Start,
                VerticalOptions       = LayoutOptions.Start,
            };

            _rateButton = new Button {
                Image           = "ic_favorite_off.png",
                Style           = Styles.InactiveButtonStyle,
                Text            = "...",
                HeightRequest   = 40,
                VerticalOptions = LayoutOptions.End,
            };
            _rateButton.Clicked += _rateButton_Clicked;
            _wazeButton          = new Button {
                Image           = "ic_waze_logo.png",
                Style           = Styles.InactiveButtonStyle,
                FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label)),
                Text            = AppResources.TakeMeThere,
                HeightRequest   = 40,
                VerticalOptions = LayoutOptions.End,
            };
            _wazeButton.Clicked += _wazeButton_Clicked;
            _seeLikes            = new Button {
                Style           = Styles.InactiveButtonStyle,
                FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label)),
                Text            = AppResources.SeeLikes,
                HeightRequest   = 40,
                VerticalOptions = LayoutOptions.End,
            };
            _seeLikes.Clicked += _seeLikes_Clicked;

            var titleLayout = new StackLayout()
            {
                Orientation     = StackOrientation.Horizontal,
                Padding         = new Thickness(20, 20, 20, 0),
                VerticalOptions = LayoutOptions.Start,
                Children        = { _nameLabel, _openIndicator },
            };
            var subtitleLayout = new StackLayout {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Padding         = new Thickness(20, 0, 20, 0),
                Children        = { _vicinityLabel },
            };
            var buttonsLayout = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                Padding           = new Thickness(20, 0, 20, 20),
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.End,
                Children          = { _seeLikes, _wazeButton, _rateButton }
            };

            var headerLayout = new StackLayout {
                Children = { titleLayout, subtitleLayout, buttonsLayout }
            };

            _mainLayout.Children.Add(headerLayout,
                                     Constraint.RelativeToView(_photo, (p, v) => v.X),
                                     Constraint.RelativeToView(_photo, (p, v) => v.Y),
                                     Constraint.RelativeToView(_photo, (p, v) => v.Width),
                                     Constraint.RelativeToView(_photo, (p, v) => v.Height)
                                     );

            _map = new Map(
                MapSpan.FromCenterAndRadius(
                    new Position(_place.Geometry.Location.Latitude, _place.Geometry.Location.Longitude), Distance.FromMiles(0.3)))
            {
                IsShowingUser   = true,
                HeightRequest   = 100,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            _mainLayout.Children.Add(_map,
                                     Constraint.Constant(0),
                                     Constraint.RelativeToView(_photo, (p, v) => v.Y + v.Height),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height / 3)
                                     );

            _emptyReviews = new Label {
                IsVisible = false,
                Style     = Styles.Subtitle,
                HorizontalTextAlignment = TextAlignment.Center
            };
            _mainLayout.Children.Add(_emptyReviews,
                                     Constraint.Constant(0),
                                     Constraint.RelativeToView(_map, (p, v) => v.Y + v.Height),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height / 3)
                                     );

            _reviewsList = new ListView {
                RowHeight       = 100,
                ItemTemplate    = new DataTemplate(typeof(ReviewViewCell)),
                BackgroundColor = Color.White,
                IsVisible       = false,
            };
            _reviewsList.ItemsSource = _reviewsCollection;
            _reviewsList.ItemTapped += _reviewsList_ItemTapped;
            _mainLayout.Children.Add(_reviewsList,
                                     Constraint.Constant(0),
                                     Constraint.RelativeToView(_map, (p, v) => v.Y + v.Height),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height / 3)
                                     );

            _reviewsPlaceholderLayout = DynamicsLayouts.Loading(AppResources.RetrievingReviews, Color.Transparent);
            _mainLayout.Children.Add(_reviewsPlaceholderLayout,
                                     Constraint.Constant(0),
                                     Constraint.RelativeToView(_map, (p, v) => v.Y + v.Height),
                                     Constraint.RelativeToParent(p => p.Width),
                                     Constraint.RelativeToParent(p => p.Height / 3)
                                     );

            var createReviewImage = new Image {
                Source = "ic_create_review.png"
            };

            _mainLayout.Children.Add(createReviewImage,
                                     Constraint.RelativeToParent(p => p.Width - 100),
                                     Constraint.RelativeToParent(p => p.Height - 100),
                                     Constraint.Constant(80),
                                     Constraint.Constant(80)
                                     );
            var tapGesture = new TapGestureRecognizer();

            tapGesture.Tapped += CreateReviewImage_Clicked;
            createReviewImage.GestureRecognizers.Add(tapGesture);

            Content = _mainLayout;
        }