private BorderBox CreateCallButton(DiscountDetailContentUI parentContentUI, string bindingProperty) { int btnHeight = Device.OnPlatform(50, 50, 64); var imgPhone = new Image { Source = parentContentUI.IconPhone, HeightRequest = btnHeight / 1.5, WidthRequest = btnHeight / 1.5 }; var txtPhone = new Label { HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Style = (Style)App.Current.Resources[LabelStyles.DetailPhoneStyle] }; txtPhone.SetBinding(Label.TextProperty, bindingProperty); AbsoluteLayout phoneLayout = new AbsoluteLayout { BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor] }; AbsoluteLayout.SetLayoutFlags(imgPhone, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(imgPhone, new Rectangle(0.1, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize) ); AbsoluteLayout.SetLayoutFlags(txtPhone, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds( txtPhone, new Rectangle( 0.7, // X 0.5, // Y AbsoluteLayout.AutoSize, // Width AbsoluteLayout.AutoSize) // Height ); phoneLayout.Children.Add(imgPhone); phoneLayout.Children.Add(txtPhone); var borderPhone = new BorderBox(); borderPhone.HeightRequest = btnHeight - 8; borderPhone.BorderWidth = 1; borderPhone.BorderColor = (Color)App.Current.Resources[MainStyles.MainBackgroundColor]; borderPhone.Content = phoneLayout; return borderPhone; }
public MapPinDetail() { #region Back box viewGestures = new ViewGestures() { BackgroundColor = new Color(0, 0, 0, 0.01) }; SetLayoutFlags(viewGestures, AbsoluteLayoutFlags.All); SetLayoutBounds(viewGestures, new Rectangle(0f, 0f, 1f, 1f)); Children.Add(viewGestures); viewGestures.Tap += (s, e) => { Hide(); }; viewGestures.SwipeLeft += (s, e) => { Hide(); }; viewGestures.SwipeRight += (s, e) => { Hide(); }; viewGestures.SwipeUp += (s, e) => { Hide(); }; viewGestures.SwipeDown += (s, e) => { Hide(); }; #endregion Grid gridDetail = new Grid { Padding = Device.OnPlatform(new Thickness(6), new Thickness(6), new Thickness(8)), BackgroundColor = InfoPanelForegroundColor, Opacity = InfoPanelOpacity, RowDefinitions = { new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(10, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; #region Header txtTitle = new Label { Text = Title, Style = (Style)App.Current.Resources[LabelStyles.TitleStyle] }; txtCategory = new Label { Style = (Style)App.Current.Resources[LabelStyles.CategoryStyle], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Text = CategoryName.ToUpper(), }; stackCategory = new StackLayout { Padding = Device.OnPlatform(new Thickness(4), new Thickness(4), new Thickness(6)), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = CategoryColor, Children = { txtCategory } }; Grid gridHeader = new Grid { BackgroundColor = Color.Transparent, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = GridLength.Auto } //new GridLength(1, GridUnitType.Star) }, } }; gridHeader.Children.Add(txtTitle, 0, 0); gridHeader.Children.Add(stackCategory, 1, 0); #endregion #region Info txtDiscountCaption = new Label { Text = DiscountCaption, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; txtPercentValue = new Label { Text = DiscountValue, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; imgDistanceIcon = new Image { Source = DistanceIcon }; txtDistanceValue = new Label { Text = DistanceValue, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; txtDistanceCaption = new Label { Text = DistanceCaption, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; var stackInfo = new StackLayout { Spacing = Device.OnPlatform(3, 3, 3), Orientation = StackOrientation.Horizontal, Children = { txtDiscountCaption, txtPercentValue, imgDistanceIcon, txtDistanceValue, txtDistanceCaption } }; #endregion var stackDetail = new StackLayout { Spacing = Device.OnPlatform(2, 4, 8), Children = { gridHeader, stackInfo } }; gridDetail.Children.Add(stackDetail, 0, 0); imgShowDetail = new Image { Source = DetailIcon, HorizontalOptions = LayoutOptions.End }; gridDetail.Children.Add(imgShowDetail, 1, 0); borderDetail = new BorderBox(BorderBox.BorderTypeEnum.btLabel); borderDetail.HeightRequest = Device.OnPlatform(50, 58, 84); borderDetail.WidthRequest = Device.OnPlatform(210, 210, 280); borderDetail.BorderWidth = 1; borderDetail.BorderColor = (Color)App.Current.Resources[MainStyles.ListBorderColor]; borderDetail.Content = gridDetail; SetLayoutFlags(borderDetail, AbsoluteLayoutFlags.PositionProportional); SetLayoutBounds(borderDetail, Device.OnPlatform( new Rectangle(0.5, 0.365, AutoSize, AutoSize), new Rectangle(0.5, 0.360, AutoSize, AutoSize), new Rectangle(0.5, 0.355, AutoSize, AutoSize)) ); borderDetail.Scale = 0; borderDetail.AnchorY = 1; Children.Add(borderDetail); }
public DiscountTemplate(ListViewAnimation parentListView, int rowHeight) { SelectColor = (Color)App.Current.Resources[MainStyles.ListSelectColor]; Grid gridDiscountItem = new Grid { Padding = new Thickness (10), BackgroundColor = (Color)App.Current.Resources[MainStyles.ListBackgroundColor], RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(2, GridUnitType.Star) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)}, new ColumnDefinition { Width = new GridLength(4, GridUnitType.Star)} } }; var fileNameConverter = new FileNameToImageConverter(); // Company logo var imgCompanyLogo = new ImageExtended { WidthRequest = Device.OnPlatform(64, 64, 64), HeightRequest = Device.OnPlatform(64, 64, 64), Aspect = Aspect.AspectFit, }; imgCompanyLogo.SetBinding(Image.SourceProperty, new Binding("LogoFileName", BindingMode.Default, fileNameConverter)); var stackCompanyLogo = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { imgCompanyLogo } }; gridDiscountItem.Children.Add(stackCompanyLogo, 0, 1, 0, 2); // Header Grid headerLayout = new Grid { Padding = new Thickness(2, 0, 0, 0), RowDefinitions = { new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star)}, new ColumnDefinition { Width = GridLength.Auto }//new GridLength(1, GridUnitType.Star)}, } }; // Title var txtTitle = new Label { VerticalOptions = LayoutOptions.End, Style = (Style)App.Current.Resources[LabelStyles.ListTitleStyle] }; txtTitle.SetBinding(Label.TextProperty, "Name"); headerLayout.Children.Add(txtTitle, 0, 0); #region Percent label var txtPercent = new Label { Style = (Style)App.Current.Resources[LabelStyles.ListPercentStyle], VerticalOptions = LayoutOptions.End }; txtPercent.SetBinding(Label.TextProperty, "DiscountPercent"); var percentLayout = new StackLayout { Spacing = 0, Orientation = StackOrientation.Horizontal, Children = { txtPercent, new Label { Style = (Style)App.Current.Resources[LabelStyles.ListPercentSymbolStyle], VerticalOptions = LayoutOptions.End } } }; #endregion #region Category layout var txtCategory = new Label { Style = (Style)App.Current.Resources[LabelStyles.CategoryStyle], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; txtCategory.SetBinding(Label.TextProperty, "FirstCategoryName"); txtCategory.SetBinding(BackgroundColorProperty, "FirstCategoryColor"); var categoryLayout = new StackLayout { Padding = Device.OnPlatform(new Thickness(4), new Thickness(4), new Thickness(6)), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Children = { txtCategory } }; categoryLayout.SetBinding(BackgroundColorProperty, "FirstCategoryColor"); var txtCategoryMore = new Label { Text = "...", Style = (Style)App.Current.Resources[LabelStyles.CategoryStyle], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; txtCategory.SetBinding(BackgroundColorProperty, "FirstCategoryColor"); var stackCategoryMore = new StackLayout { Padding = Device.OnPlatform(new Thickness(4), new Thickness(4), new Thickness(6)), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Children = { txtCategoryMore } }; stackCategoryMore.SetBinding(BackgroundColorProperty, "FirstCategoryColor"); stackCategoryMore.SetBinding(IsVisibleProperty, "IsCategoryMore"); #endregion var infoDiscountLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { percentLayout, categoryLayout, stackCategoryMore } }; headerLayout.Children.Add(infoDiscountLayout, 1, 0); gridDiscountItem.Children.Add(headerLayout, 1, 2, 0, 1); #region Description var txtDescription = new LabelExtended { IsWrapped = true, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle], }; txtDescription.GestureRecognizers.Clear(); txtDescription.SetBinding(LabelExtended.TextProperty, new Binding("Description", BindingMode.Default, new TextHeightLimitation())); var layoutDescription = new RelativeLayout(); layoutDescription.Children.Add(txtDescription, Constraint.Constant(2), Constraint.Constant(0), Constraint.RelativeToParent(parent => { return parent.Width - 2; }), Constraint.RelativeToParent(parent => { return parent.Height; })); gridDiscountItem.Children.Add(layoutDescription, 1, 2, 1, 2); #endregion var boxBorder = new BorderBox { Padding = new Thickness(8, 4), HeightRequest = rowHeight - 16, }; boxBorder.BorderColor = (Color)App.Current.Resources[MainStyles.ListBorderColor]; boxBorder.BorderWidth = 1; boxBorder.Content = gridDiscountItem; var layout = new AbsoluteLayout { Padding = new Thickness (8, 4), }; parentListView.AnimationListAdd(layout); AbsoluteLayout.SetLayoutFlags(boxBorder, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(boxBorder, new Rectangle(0f, 0f, 1f, 1f)); layout.Children.Add(boxBorder); View = layout; }
public MapPinDetail() { #region Back box viewGestures = new ViewGestures() { BackgroundColor = new Color(0, 0, 0, 0.01) }; SetLayoutFlags(viewGestures, AbsoluteLayoutFlags.All); SetLayoutBounds(viewGestures, new Rectangle(0f, 0f, 1f, 1f)); Children.Add(viewGestures); viewGestures.Tap += (s, e) => { Hide(); }; viewGestures.SwipeLeft += (s, e) => { Hide(); }; viewGestures.SwipeRight += (s, e) => { Hide(); }; viewGestures.SwipeUp += (s, e) => { Hide(); }; viewGestures.SwipeDown += (s, e) => { Hide(); }; #endregion Grid gridDetail = new Grid { Padding = Device.OnPlatform(new Thickness(6), new Thickness(6), new Thickness(8)) , BackgroundColor = InfoPanelForegroundColor, Opacity = InfoPanelOpacity, RowDefinitions = { new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(10, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; #region Header txtTitle = new Label { Text = Title, Style = (Style)App.Current.Resources[LabelStyles.TitleStyle] }; txtCategory = new Label { Style = (Style)App.Current.Resources[LabelStyles.CategoryStyle], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Text = CategoryName.ToUpper(), }; stackCategory = new StackLayout { Padding = Device.OnPlatform(new Thickness(4), new Thickness(4), new Thickness(6)), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = CategoryColor, Children = { txtCategory } }; Grid gridHeader = new Grid { BackgroundColor = Color.Transparent, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = GridLength.Auto }//new GridLength(1, GridUnitType.Star) }, } }; gridHeader.Children.Add(txtTitle, 0, 0); gridHeader.Children.Add(stackCategory, 1, 0); #endregion #region Info txtDiscountCaption = new Label { Text = DiscountCaption, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; txtPercentValue = new Label { Text = DiscountValue, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; imgDistanceIcon = new Image { Source = DistanceIcon }; txtDistanceValue = new Label { Text = DistanceValue, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; txtDistanceCaption = new Label { Text = DistanceCaption, Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle] }; var stackInfo = new StackLayout { Spacing = Device.OnPlatform(3, 3, 3), Orientation = StackOrientation.Horizontal, Children = { txtDiscountCaption, txtPercentValue, imgDistanceIcon, txtDistanceValue, txtDistanceCaption } }; #endregion var stackDetail = new StackLayout { Spacing = Device.OnPlatform (2, 4, 8), Children = { gridHeader, stackInfo } }; gridDetail.Children.Add(stackDetail, 0, 0); imgShowDetail = new Image { Source = DetailIcon, HorizontalOptions = LayoutOptions.End }; gridDetail.Children.Add(imgShowDetail, 1, 0); borderDetail = new BorderBox(BorderBox.BorderTypeEnum.btLabel); borderDetail.HeightRequest = Device.OnPlatform(50, 58, 84); borderDetail.WidthRequest = Device.OnPlatform(210, 210, 280); borderDetail.BorderWidth = 1; borderDetail.BorderColor = (Color)App.Current.Resources[MainStyles.ListBorderColor]; borderDetail.Content = gridDetail; SetLayoutFlags(borderDetail, AbsoluteLayoutFlags.PositionProportional); SetLayoutBounds(borderDetail, Device.OnPlatform( new Rectangle(0.5, 0.365, AutoSize, AutoSize), new Rectangle(0.5, 0.360, AutoSize, AutoSize), new Rectangle(0.5, 0.355, AutoSize, AutoSize)) ); borderDetail.Scale = 0; borderDetail.AnchorY = 1; Children.Add(borderDetail); }