Example #1
0
        public MenuPageXaml()
        {
            InitializeComponent();
            MenuListData.LoadItems();

            Title = "Menu";

            _menuListViewTop.ItemsSource    = MenuListData.TopItems;
            _menuListViewBottom.ItemsSource = MenuListData.BottomItems;

            int MenuItemsHeight = 48;

            int TopMenuItemsHeightRequest    = (MenuItemsHeight + 2) * MenuListData.TopItems.Count;
            int BottomMenuItemsHeightRequest = (MenuItemsHeight + 2) * MenuListData.BottomItems.Count;

            _menuListViewTop.HeightRequest    = TopMenuItemsHeightRequest;
            _menuListViewBottom.HeightRequest = BottomMenuItemsHeightRequest;

            //_menuListViewTop.RowHeight = MenuItemsHeight;
            //_menuListViewBottom.RowHeight = MenuItemsHeight;

            _menuListViewTop.ItemTapped    += (s, i) => { MenusItemTapped?.Invoke(s, i); };
            _menuListViewBottom.ItemTapped += (s, i) => { MenusItemTapped?.Invoke(s, i); };

            imgUser.Source   = Helpers.Settings.DisplayUserPhoto;
            lblUserName.Text = Helpers.Settings.DisplayUserName;

            if (Device.RuntimePlatform == "iOS")
            {
                lblVersion.Text = CrossDeviceInfo.Current.AppBuild;
            }
            else
            {
                lblVersion.Text = CrossDeviceInfo.Current.AppVersion;
            }
        }
Example #2
0
        void CreateLayout()
        {
            var cell = new DataTemplate(typeof(ImageCell));

            cell.SetBinding(TextCell.TextProperty, "Title");
            cell.SetBinding(ImageCell.ImageSourceProperty, "Icon");
            cell.SetBinding(ImageCell.TextColorProperty, "TextColor");
            cell.SetBinding(ImageCell.DetailColorProperty, "DescriptionColor");

            int MenuItemsHeight = 48;

            int TopMenuItemsHeightRequest    = (MenuItemsHeight + 2) * MenuListData.TopItems.Count;
            int BottomMenuItemsHeightRequest = (MenuItemsHeight + 2) * MenuListData.BottomItems.Count;

            #region Account

            var userImage = new CachedImage()
            {
                HorizontalOptions     = LayoutOptions.Start,
                HeightRequest         = 64,
                WidthRequest          = 64,
                DownsampleToViewSize  = true,
                DownsampleUseDipUnits = true,
                TransparencyEnabled   = true,
                Aspect             = Aspect.AspectFill,
                CacheDuration      = TimeSpan.FromDays(30),
                RetryCount         = 3,
                RetryDelay         = 500,
                LoadingPlaceholder = "icon",
                ErrorPlaceholder   = "icon",
                Transformations    = new List <FFImageLoading.Work.ITransformation> {
                    new CircleTransformation(0, "#e5e5e5")
                }
            };
            //userImage.SetBinding(CachedImage.SourceProperty,
            //    Binding.Create<MenuViewModel>(vm => vm.CurrentUser.ImageUri, BindingMode.Default, new ImageToPlaceholderConverter()));

            var userFullName = new Label
            {
                TextColor = Color.White,
                FontSize  = 16,
                Text      = "Full name"
            };
            //userFullName.SetBinding(Label.TextProperty, Binding.Create<MenuViewModel>(vm => vm.CurrentUser.FullName));

            var userEmail = new Label
            {
                TextColor = Color.White,
                FontSize  = 14,
                Text      = "Email"
            };
            //userEmail.SetBinding(Label.TextProperty, Binding.Create<MenuViewModel>(vm => vm.CurrentUser.UserName));

            #endregion

            var _menuImage = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Fill,
            };

            var accountDetails = new StackLayout
            {
                Padding  = 0,
                Children =
                {
                    userImage,
                    new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Spacing         = 0,
                        Children        =
                        {
                            userFullName,
                            userEmail
                        }
                    }
                }
            };
            AbsoluteLayout.SetLayoutBounds(accountDetails, new Rectangle(.07, .75, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            AbsoluteLayout.SetLayoutFlags(accountDetails, AbsoluteLayoutFlags.PositionProportional);

            var _imageLayout = new AbsoluteLayout
            {
                BackgroundColor   = StyleKit.Current.WindowColor,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 185,
                Children          =
                {
                    _menuImage,
                    accountDetails
                }
            };
            AbsoluteLayout.SetLayoutBounds(_imageLayout, new Rectangle(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            AbsoluteLayout.SetLayoutFlags(_imageLayout, AbsoluteLayoutFlags.PositionProportional);


            MenusItemTapped += MenuListViewItemTapped;

            _menuListViewTop = new ListView
            {
                ItemsSource         = MenuListData.TopItems,
                ItemTemplate        = cell,
                SeparatorVisibility = SeparatorVisibility.None,
                SeparatorColor      = Color.Transparent,
                HorizontalOptions   = LayoutOptions.Fill,
                VerticalOptions     = LayoutOptions.Fill,
                HeightRequest       = TopMenuItemsHeightRequest,
                RowHeight           = MenuItemsHeight
            };
            _menuListViewTop.ItemTapped += (s, i) => { MenusItemTapped?.Invoke(s, i); };

            _menuListViewBottom = new ListView
            {
                ItemsSource         = MenuListData.BottomItems,
                ItemTemplate        = cell,
                SeparatorVisibility = SeparatorVisibility.None,
                SeparatorColor      = Color.Transparent,
                HorizontalOptions   = LayoutOptions.Fill,
                VerticalOptions     = LayoutOptions.Fill,
                HeightRequest       = BottomMenuItemsHeightRequest,
                RowHeight           = MenuItemsHeight
            };
            _menuListViewBottom.ItemTapped += (s, i) => { MenusItemTapped?.Invoke(s, i); };


            var _mainLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HeightRequest     = TopMenuItemsHeightRequest,
                Children          =
                {
                    _menuListViewTop
                }
            };

            var _bottomLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HeightRequest     = BottomMenuItemsHeightRequest,
                Children          =
                {
                    _menuListViewBottom
                }
            };

            var _rootLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Spacing           = 0,
                Children          =
                {
                    _imageLayout,
                    _mainLayout,
                    _bottomLayout
                }
            };

            Content = _rootLayout;
        }
Example #3
0
        void CreateLayout()
        {
            var cell = new DataTemplate(typeof(MenuCell));
            //cell.SetBinding(TextCell.TextProperty, "Title");
            //cell.SetBinding(ImageCell.ImageSourceProperty, "Icon");
            //cell.SetBinding(ImageCell.TextColorProperty, "TextColor");
            //cell.SetBinding(ImageCell.DetailColorProperty, "DescriptionColor");


            int MenuItemsHeight = 48;

            int TopMenuItemsHeightRequest    = (MenuItemsHeight + 2) * MenuListData.TopItems.Count;
            int BottomMenuItemsHeightRequest = (MenuItemsHeight + 2) * MenuListData.BottomItems.Count;

            #region Account

            var userImage = new CachedImage()
            {
                HorizontalOptions = LayoutOptions.Start,
                HeightRequest     = 64,
                WidthRequest      = 64,
                Aspect            = Aspect.AspectFill,
                Transformations   = new List <FFImageLoading.Work.ITransformation> {
                    new CircleTransformation(0, Color.Transparent.ToString())
                }
            };

            var userFullName = new Label
            {
                TextColor = Color.White,
                FontSize  = 16,
                Text      = "Full name"
            };

            var userEmail = new Label
            {
                TextColor = Color.White,
                FontSize  = 14,
                Text      = "Email"
            };

            #endregion



            var _menuImage = new CachedImage
            {
                WidthRequest = 500,
                Aspect       = Aspect.AspectFill,
                Source       = "master_header"
            };

            var accountDetails = new StackLayout
            {
                Padding  = 0,
                Children =
                {
                    userImage,
                    new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Spacing         = 0,
                        Children        =
                        {
                            userFullName,
                            userEmail
                        }
                    }
                }
            };
            AbsoluteLayout.SetLayoutBounds(accountDetails, new Rectangle(.07, .75, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            AbsoluteLayout.SetLayoutFlags(accountDetails, AbsoluteLayoutFlags.PositionProportional);

            var _imageLayout = new AbsoluteLayout
            {
                BackgroundColor   = App.StyleKit.WindowColor,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    _menuImage,
                    accountDetails
                }
            };
            AbsoluteLayout.SetLayoutBounds(_imageLayout, new Rectangle(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            AbsoluteLayout.SetLayoutFlags(_imageLayout, AbsoluteLayoutFlags.PositionProportional);


            MenusItemTapped += MenuListViewItemTapped;

            _menuListViewTop = new ListView
            {
                ItemsSource         = MenuListData.TopItems,
                ItemTemplate        = cell,
                SeparatorVisibility = SeparatorVisibility.None,
                SeparatorColor      = Color.Transparent,
                HorizontalOptions   = LayoutOptions.Fill,
                VerticalOptions     = LayoutOptions.Fill,
                HeightRequest       = TopMenuItemsHeightRequest,
                RowHeight           = MenuItemsHeight
            };
            _menuListViewTop.ItemTapped += (s, i) => { MenusItemTapped?.Invoke(s, i); };

            _menuListViewBottom = new ListView
            {
                ItemsSource         = MenuListData.BottomItems,
                ItemTemplate        = cell,
                SeparatorVisibility = SeparatorVisibility.None,
                SeparatorColor      = Color.Transparent,
                HorizontalOptions   = LayoutOptions.Fill,
                VerticalOptions     = LayoutOptions.Fill,
                HeightRequest       = BottomMenuItemsHeightRequest,
                RowHeight           = MenuItemsHeight
            };
            _menuListViewBottom.ItemTapped += (s, i) => { MenusItemTapped?.Invoke(s, i); };


            var _mainLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HeightRequest     = TopMenuItemsHeightRequest,
                Children          =
                {
                    _menuListViewTop
                }
            };

            var _bottomLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HeightRequest     = BottomMenuItemsHeightRequest,
                Children          =
                {
                    _menuListViewBottom
                }
            };

            var _rootLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Spacing           = 0,
                Children          =
                {
                    _imageLayout,
                    _mainLayout,
                    _bottomLayout
                }
            };

            Content = _rootLayout;
        }