public CustomerOrdersPage() { #region activity indicator ActivityIndicator activityIndicator = new ActivityIndicator() { HeightRequest = Sizes.LargeRowHeight }; activityIndicator.SetBinding(IsEnabledProperty, "IsBusy"); activityIndicator.SetBinding(IsVisibleProperty, "IsBusy"); activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); #endregion #region header Label companyTitleLabel = new Label() { Text = TextResources.Customers_Orders_EditOrder_CompanyTitle, TextColor = Palette._007, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), XAlign = TextAlignment.Start, YAlign = TextAlignment.End, LineBreakMode = LineBreakMode.TailTruncation }; Label companyNameLabel = new Label() { TextColor = Palette._006, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), XAlign = TextAlignment.Start, YAlign = TextAlignment.Start, LineBreakMode = LineBreakMode.TailTruncation }; companyNameLabel.SetBinding(Label.TextProperty, "Account.Company"); Image addNewOrderImage = new Image() { Aspect = Aspect.AspectFit }; Device.OnPlatform( iOS: () => addNewOrderImage.Source = new FileImageSource() { File = "add_ios_blue" }, Android: () => addNewOrderImage.Source = new FileImageSource() { File = "add_android_blue" } ); addNewOrderImage.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(AddNewOrderTapped), NumberOfTapsRequired = 1 }); AbsoluteLayout headerAbsoluteLayout = new AbsoluteLayout() { HeightRequest = Sizes.LargeRowHeight }; headerAbsoluteLayout.Children.Add( view: new UnspacedStackLayout() { Children = { companyTitleLabel, companyNameLabel } }, bounds: new Rectangle(0, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), flags: AbsoluteLayoutFlags.PositionProportional ); headerAbsoluteLayout.Children.Add( view: addNewOrderImage, bounds: new Rectangle(1, .5, AbsoluteLayout.AutoSize, Device.OnPlatform(.5, .4, .5)), flags: AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.HeightProportional ); ContentView headerLabelsView = new ContentView() { Content = headerAbsoluteLayout, Padding = new Thickness(20, 0) }; headerLabelsView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); headerLabelsView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); #endregion #region order list view CustomerOrderListView customerOrderListView = new CustomerOrderListView() { IsGroupingEnabled = true }; customerOrderListView.GroupDisplayBinding = new Binding("Key"); customerOrderListView.GroupHeaderTemplate = new DataTemplate(typeof(CustomerOrderListViewGroupHeaderCell)); customerOrderListView.SetBinding(ListView.ItemsSourceProperty, "OrderGroups"); customerOrderListView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); customerOrderListView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); customerOrderListView.ItemTapped += async(sender, e) => { var order = (Order)e.Item; await Navigation.PushAsync(new CustomerOrderDetailPage() { BindingContext = new OrderDetailViewModel(ViewModel.Account, order) { Navigation = Navigation }, }); }; #endregion #region compose view hierarchy Content = new UnspacedStackLayout() { Children = { activityIndicator, new ContentViewWithBottomBorder() { Content = headerLabelsView }, customerOrderListView } }; #endregion }
public CustomerOrdersPage() { #region toolbar items if (Device.OS != TargetPlatform.Android) { ToolbarItems.Add(new ToolbarItem { Text = "Add", Icon = "add.png", Command = new Command(AddNewOrderTapped) }); } #endregion #region activity indicator ActivityIndicator activityIndicator = new ActivityIndicator() { HeightRequest = Sizes.LargeRowHeight }; activityIndicator.SetBinding(IsEnabledProperty, "IsBusy"); activityIndicator.SetBinding(IsVisibleProperty, "IsBusy"); activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); #endregion #region header Label companyTitleLabel = new Label() { Text = TextResources.Customers_Orders_EditOrder_CompanyTitle, TextColor = Palette._007, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), XAlign = TextAlignment.Start, YAlign = TextAlignment.End, LineBreakMode = LineBreakMode.TailTruncation }; Label companyNameLabel = new Label() { TextColor = Palette._006, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), XAlign = TextAlignment.Start, YAlign = TextAlignment.Start, LineBreakMode = LineBreakMode.TailTruncation }; companyNameLabel.SetBinding(Label.TextProperty, "Account.Company"); Image addNewOrderImage = new Image() { Aspect = Aspect.AspectFit }; Device.OnPlatform( iOS: () => addNewOrderImage.Source = new FileImageSource() { File = "add_ios_blue" }, Android: () => addNewOrderImage.Source = new FileImageSource() { File = "add_android_blue" } ); addNewOrderImage.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(AddNewOrderTapped), NumberOfTapsRequired = 1 }); addNewOrderImage.IsVisible = Device.OS != TargetPlatform.Android; AbsoluteLayout headerAbsoluteLayout = new AbsoluteLayout() { HeightRequest = Sizes.LargeRowHeight }; headerAbsoluteLayout.Children.Add( view: new UnspacedStackLayout() { Children = { companyTitleLabel, companyNameLabel } }, bounds: new Rectangle(0, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), flags: AbsoluteLayoutFlags.PositionProportional ); headerAbsoluteLayout.Children.Add( view: addNewOrderImage, bounds: new Rectangle(1, .5, AbsoluteLayout.AutoSize, Device.OnPlatform(.5, .4, .5)), flags: AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.HeightProportional ); ContentView headerLabelsView = new ContentView() { Content = headerAbsoluteLayout, Padding = new Thickness(20, 0) }; headerLabelsView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); headerLabelsView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); #endregion #region order list view var customerOrderListView = new CustomerOrderListView() { IsGroupingEnabled = true }; customerOrderListView.GroupDisplayBinding = new Binding("Key"); customerOrderListView.GroupHeaderTemplate = new DataTemplate(typeof(CustomerOrderListViewGroupHeaderCell)); customerOrderListView.SetBinding(ListView.ItemsSourceProperty, "OrderGroups"); customerOrderListView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); customerOrderListView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); customerOrderListView.ItemTapped += async(sender, e) => { var order = (Order)e.Item; await Navigation.PushAsync(new CustomerOrderDetailPage() { BindingContext = new OrderDetailViewModel(ViewModel.Account, order) { Navigation = Navigation }, }); }; #endregion #region compose view hierarchy var stack = new UnspacedStackLayout() { Children = { activityIndicator, customerOrderListView } }; if (Device.OS == TargetPlatform.Android) { var fab = new FloatingActionButtonView { ImageName = "fab_add.png", ColorNormal = Palette._001, ColorPressed = Palette._002, ColorRipple = Palette._001, Clicked = (sender, args) => AddNewOrderTapped(), }; var absolute = new AbsoluteLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; // Position the pageLayout to fill the entire screen. // Manage positioning of child elements on the page by editing the pageLayout. AbsoluteLayout.SetLayoutFlags(stack, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(stack, new Rectangle(0f, 0f, 1f, 1f)); absolute.Children.Add(stack); // Overlay the FAB in the bottom-right corner AbsoluteLayout.SetLayoutFlags(fab, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(fab, new Rectangle(1f, 1f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); absolute.Children.Add(fab); Content = absolute; } else { Content = stack; } #endregion }