public LeadsView() { #region leads list activity inidicator ActivityIndicator leadListActivityIndicator = new ActivityIndicator() { HeightRequest = Sizes.MediumRowHeight }; leadListActivityIndicator.SetBinding(IsEnabledProperty, "IsBusy"); leadListActivityIndicator.SetBinding(IsVisibleProperty, "IsBusy"); leadListActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); #endregion #region loading label Label loadingLabel = new Label() { Text = TextResources.SalesDashboard_Leads_LoadingLabel, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HeightRequest = Sizes.MediumRowHeight, XAlign = TextAlignment.Center, YAlign = TextAlignment.End, TextColor = Palette._007 }; loadingLabel.SetBinding(IsEnabledProperty, "IsBusy"); loadingLabel.SetBinding(IsVisibleProperty, "IsBusy"); #endregion #region leads list header // LeadListHeaderView is an example of a custom view composed with Xamarin.Forms. // It takes an action as a constructor parameter, which will be used by the add new lead button ("+"). LeadListHeaderView leadListHeaderView = new LeadListHeaderView(new Command(ExecutePushLeadDetailsTabbedPageCommand)); leadListHeaderView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); leadListHeaderView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); #endregion #region leadsListView LeadListView leadListView = new LeadListView(); leadListView.SetBinding(LeadListView.ItemsSourceProperty, "Leads"); leadListView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); leadListView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); leadListView.ItemTapped += (sender, e) => { Account leadListItem = (Account)e.Item; ExecutePushLeadDetailsTabbedPageCommand(leadListItem); }; #endregion #region compose view hierarchy Content = new UnspacedStackLayout() { Children = { leadListHeaderView, loadingLabel, leadListActivityIndicator, leadListView } }; #endregion }
public ProductListPage(string title, bool isPerformingProductSelection = false) { Title = title; #region product list ProductListView productListView = new ProductListView(); productListView.SetBinding(ProductListView.ItemsSourceProperty, "Products"); productListView.IsPullToRefreshEnabled = true; productListView.SetBinding(CategoryListView.RefreshCommandProperty, "LoadProductsCommand"); productListView.SetBinding(CategoryListView.IsRefreshingProperty, "IsBusy", mode: BindingMode.OneWay); productListView.ItemTapped += async(sender, e) => { Product catalogProduct = ((Product)e.Item); await Navigation.PushAsync(new ProductDetailPage(catalogProduct, isPerformingProductSelection)); }; #endregion #region compase view hierarchy Content = new UnspacedStackLayout() { Children = { productListView } }; #endregion }
public CustomerDetailPage() { StackLayout stackLayout = new UnspacedStackLayout() { Children = { new CustomerDetailHeaderView(), new CustomerDetailContactView(), new CustomerDetailPhoneView(this), new CustomerDetailAddressView() } }; Content = new ScrollView() { Content = stackLayout }; }
public ProductListPage(string title, bool isPerformingProductSelection = false) { Title = title; #region product list ProductListView productListView = new ProductListView(); productListView.SetBinding(ProductListView.ItemsSourceProperty, "Products"); productListView.IsPullToRefreshEnabled = true; productListView.SetBinding(CategoryListView.RefreshCommandProperty, "LoadProductsCommand"); productListView.SetBinding(CategoryListView.IsRefreshingProperty, "IsBusy", mode: BindingMode.OneWay); productListView.ItemTapped += async(sender, e) => await App.ExecuteIfConnected(async() => { CatalogProduct catalogProduct = ((CatalogProduct)e.Item); await Navigation.PushAsync(new ProductDetailPage(catalogProduct, isPerformingProductSelection)); }); productListView.SetBinding(CategoryListView.HeaderProperty, "."); productListView.HeaderTemplate = new DataTemplate(() => { Label loadingLabel = new Label() { Text = TextResources.Products_ProductList_LoadingLabel, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), XAlign = TextAlignment.Center, YAlign = TextAlignment.End, TextColor = Palette._007 }; loadingLabel.SetBinding(Label.IsEnabledProperty, "IsBusy", mode: BindingMode.OneWay); loadingLabel.SetBinding(Label.IsVisibleProperty, "IsBusy", mode: BindingMode.OneWay); return(loadingLabel); }); #endregion #region compase view hierarchy Content = new UnspacedStackLayout() { Children = { productListView } }; #endregion }
public CustomersPage() { #region customer list activity inidicator ActivityIndicator customerListActivityIndicator = new ActivityIndicator() { HeightRequest = Sizes.MediumRowHeight }; customerListActivityIndicator.SetBinding(IsEnabledProperty, "IsBusy"); customerListActivityIndicator.SetBinding(IsVisibleProperty, "IsBusy"); customerListActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); #endregion #region customer list CustomerListView customerListView = new CustomerListView(); customerListView.SetBinding(CustomerListView.ItemsSourceProperty, "Accounts"); customerListView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); customerListView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); customerListView.ItemTapped += async(sender, e) => { Account account = (Account)e.Item; await PushTabbedPage(account); }; #endregion #region compose view hierarchy Content = new UnspacedStackLayout() { Children = { customerListActivityIndicator, customerListView }, Padding = Device.OnPlatform(Thicknesses.IosStatusBar, Thicknesses.Empty, Thicknesses.Empty) }; #endregion #region wire up MessagingCenter // Catch the login success message from the MessagingCenter. // This is really only here for Android, which doesn't fire the OnAppearing() method in the same way that iOS does (every time the page appears on screen). Device.OnPlatform(Android: () => MessagingCenter.Subscribe <CustomersPage>(this, MessagingServiceConstants.AUTHENTICATED, sender => OnAppearing())); #endregion }
public CategoryListPage(string title = null, bool isPerformingProductSelection = false) { if (title == null) { Title = "Products"; } SetBinding(Page.TitleProperty, new Binding("Category", converter: new CategoryTitleConverter(Title))); #region category list CategoryListView categoryListView = new CategoryListView(); categoryListView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, "SubCategories"); categoryListView.IsPullToRefreshEnabled = true; categoryListView.SetBinding(ListView.RefreshCommandProperty, "LoadCategoriesCommand"); categoryListView.SetBinding(ListView.IsRefreshingProperty, "IsBusy", mode: BindingMode.OneWay); categoryListView.ItemTapped += async(sender, e) => { Category catalogCategory = ((Category)e.Item); if (catalogCategory.HasSubCategories) { await Navigation.PushAsync(new CategoryListPage(catalogCategory.Name, isPerformingProductSelection) { BindingContext = new CategoriesViewModel(catalogCategory) }); } else { await Navigation.PushAsync(new ProductListPage(catalogCategory.Name, isPerformingProductSelection) { BindingContext = new ProductsViewModel(catalogCategory.Id) }); } }; #endregion #region compose view hierarchy Content = new UnspacedStackLayout() { Children = { categoryListView } }; #endregion }
public CustomersPage() { #region customer list activity inidicator ActivityIndicator customerListActivityIndicator = new ActivityIndicator() { HeightRequest = Sizes.MediumRowHeight }; customerListActivityIndicator.SetBinding(IsEnabledProperty, "IsBusy"); customerListActivityIndicator.SetBinding(IsVisibleProperty, "IsBusy"); customerListActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); #endregion #region customer list CustomerListView customerListView = new CustomerListView(); customerListView.SetBinding(CustomerListView.ItemsSourceProperty, "Accounts"); customerListView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); customerListView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); customerListView.ItemTapped += async(sender, e) => await App.ExecuteIfConnected(async() => { Account account = (Account)e.Item; await PushTabbedPage(account); }); #endregion #region compose view hierarchy Content = new UnspacedStackLayout() { Children = { customerListActivityIndicator, customerListView }, Padding = Device.OnPlatform(Thicknesses.IosStatusBar, Thicknesses.Empty, Thicknesses.Empty) }; #endregion }
public SalesDashboardChartView() { #region sales graph header SalesChartHeaderView chartHeaderView = new SalesChartHeaderView() { HeightRequest = Sizes.MediumRowHeight, Padding = new Thickness(20, 10, 20, 0) }; chartHeaderView.WeeklyAverageValueLabel.SetBinding(Label.TextProperty, "WeeklySalesAverage"); chartHeaderView.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); chartHeaderView.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); #endregion #region activity indicator ActivityIndicator chartActivityIndicator = new ActivityIndicator() { HeightRequest = Sizes.MediumRowHeight }; chartActivityIndicator.SetBinding(IsEnabledProperty, "IsBusy"); chartActivityIndicator.SetBinding(IsVisibleProperty, "IsBusy"); chartActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); #endregion #region loading label Label loadingLabel = new Label() { Text = TextResources.SalesDashboard_SalesChart_LoadingLabel, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HeightRequest = Sizes.MediumRowHeight, XAlign = TextAlignment.Center, YAlign = TextAlignment.End, TextColor = Palette._007 }; loadingLabel.SetBinding(IsEnabledProperty, "IsBusy"); loadingLabel.SetBinding(IsVisibleProperty, "IsBusy"); #endregion #region the sales graph const double chartHeight = 190; ColumnSeries columnSeries = new ColumnSeries() { YAxis = new NumericalAxis() { OpposedPosition = false, ShowMajorGridLines = true, MajorGridLineStyle = new ChartLineStyle() { StrokeColor = MajorAxisAndLableColor }, ShowMinorGridLines = true, MinorTicksPerInterval = 1, MinorGridLineStyle = new ChartLineStyle() { StrokeColor = MajorAxisAndLableColor }, LabelStyle = new ChartAxisLabelStyle() { TextColor = MajorAxisAndLableColor, LabelFormat = "$0" } }, Color = Palette._003 }; columnSeries.SetBinding(ColumnSeries.ItemsSourceProperty, "WeeklySalesChartDataPoints"); SfChart chart = new SfChart() { HeightRequest = chartHeight, PrimaryAxis = new CategoryAxis() { EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Center, LabelPlacement = LabelPlacement.BetweenTicks, TickPosition = AxisElementPosition.Inside, ShowMajorGridLines = false, LabelStyle = new ChartAxisLabelStyle() { TextColor = MajorAxisAndLableColor } }, BackgroundColor = Color.Transparent }; chart.Series.Add(columnSeries); chart.SetBinding(IsEnabledProperty, "IsBusy", converter: new InverseBooleanConverter()); chart.SetBinding(IsVisibleProperty, "IsBusy", converter: new InverseBooleanConverter()); // The chart has uncontrollable white space on it's left in iOS, so we're // wrapping it in a ContentView and adding some right padding to compensate. ContentView chartWrapper = new ContentView() { Content = chart }; StackLayout stackLayout = new UnspacedStackLayout() { Children = { chartHeaderView, loadingLabel, chartActivityIndicator, chartWrapper } }; #endregion #region platform adjustments Device.OnPlatform( iOS: () => { chartWrapper.Padding = new Thickness(0, 0, 30, 0); stackLayout.BackgroundColor = Color.Transparent; stackLayout.Padding = new Thickness(0, 20, 0, 0); }, Android: () => { stackLayout.BackgroundColor = Palette._009; Font androidChartLabelFont = Font.SystemFontOfSize(Device.GetNamedSize(NamedSize.Large, typeof(Label)) * 1.5); columnSeries.YAxis.LabelStyle.Font = androidChartLabelFont; chart.PrimaryAxis.LabelStyle.Font = androidChartLabelFont; }); #endregion Content = stackLayout; }
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 CustomerDetailAddressView() { #region labels Label addressTitleLabel = new Label() { Text = TextResources.Customers_Detail_Address, TextColor = Device.OnPlatform(Palette._005, Palette._007, Palette._006), FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; Label addressStreetLabel = new Label() { TextColor = Palette._006, FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Default, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; addressStreetLabel.SetBinding(Label.TextProperty, "Account.Street"); Label addressCityLabel = new Label() { TextColor = Palette._006, FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Default, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; addressCityLabel.SetBinding(Label.TextProperty, "Account.City"); Label addressStatePostalLabel = new Label() { TextColor = Palette._006, FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Default, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; addressStatePostalLabel.SetBinding(Label.TextProperty, "Account.StatePostal"); #endregion #region map marker image Image mapMarkerImage = new Image() { Source = new FileImageSource { File = Device.OnPlatform("map_marker_ios", "map_marker_android", null) }, Aspect = Aspect.AspectFit, HeightRequest = 25 }; // an expanded view to catch touches, because the image is a bit small AbsoluteLayout mapMarkerImageTouchView = new AbsoluteLayout() { WidthRequest = Sizes.MediumRowHeight, HeightRequest = Sizes.MediumRowHeight }; mapMarkerImageTouchView.GestureRecognizers.Add( new TapGestureRecognizer() { Command = new Command(MapMarkerIconTapped) }); mapMarkerImageTouchView.Children.Add(mapMarkerImage, new Rectangle(.5, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional); #endregion #region compose view hierarchy StackLayout stackLayout = new UnspacedStackLayout() { Children = { addressTitleLabel, addressStreetLabel, addressCityLabel, addressStatePostalLabel }, Padding = new Thickness(20) }; AbsoluteLayout absoluteLayout = new AbsoluteLayout(); absoluteLayout.Children.Add(stackLayout, new Rectangle(0, .5, 1, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional); absoluteLayout.Children.Add(mapMarkerImageTouchView, new Rectangle(.95, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional); #endregion Content = absoluteLayout; }
public CustomerOrderDetailPage() { // Hide the back button, because we have ToolBarItems to control navigtion on this page. // A back button would be confusing here in this modally presented tab page. NavigationPage.SetHasBackButton(this, false); NavigationPage.SetBackButtonTitle(this, string.Empty); #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"); RelativeLayout headerLabelsRelativeLayout = new RelativeLayout() { HeightRequest = Sizes.LargeRowHeight }; headerLabelsRelativeLayout.Children.Add( view: companyTitleLabel, widthConstraint: Constraint.RelativeToParent(parent => parent.Width), heightConstraint: Constraint.RelativeToParent(parent => parent.Height / 2)); headerLabelsRelativeLayout.Children.Add( view: companyNameLabel, yConstraint: Constraint.RelativeToParent(parent => parent.Height / 2), widthConstraint: Constraint.RelativeToParent(parent => parent.Width), heightConstraint: Constraint.RelativeToParent(parent => parent.Height / 2)); ContentView headerLabelsView = new ContentView() { Padding = new Thickness(20, 0), Content = headerLabelsRelativeLayout }; #endregion #region grid setup Grid orderDetailsGrid = new Grid() { Padding = new Thickness(20), RowDefinitions = new RowDefinitionCollection() { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = new ColumnDefinitionCollection() { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; #endregion #region product selection _ProductSelectionEntry = new Entry() { Placeholder = TextResources.Customers_Orders_EditOrder_ProductEntryPlaceholder }; _ProductSelectionEntry.SetBinding(Entry.TextProperty, "Order.Item", BindingMode.TwoWay); _ProductSelectionEntry.SetBinding(IsEnabledProperty, "Order.IsOpen"); _ProductSelectionEntry.SetBinding(IsVisibleProperty, "Order.IsOpen"); Label productSelectionLabel = new Label() { HeightRequest = RowHeight, YAlign = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; productSelectionLabel.SetBinding(Label.TextProperty, "Order.Item"); productSelectionLabel.SetBinding(IsEnabledProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); productSelectionLabel.SetBinding(IsVisibleProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); StackLayout productSelectionStack = new UnspacedStackLayout() { Children = { _ProductSelectionEntry, productSelectionLabel } }; #endregion #region price Entry priceEntry = new Entry() { Placeholder = TextResources.Customers_Orders_EditOrder_PriceEntryPlaceholder, Keyboard = Keyboard.Numeric }; priceEntry.SetBinding(Entry.TextProperty, "Order.Price", BindingMode.TwoWay, new CurrencyDoubleConverter()); priceEntry.SetBinding(IsEnabledProperty, "Order.IsOpen"); priceEntry.SetBinding(IsVisibleProperty, "Order.IsOpen"); Label priceLabel = new Label() { HeightRequest = RowHeight, YAlign = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; priceLabel.SetBinding(Label.TextProperty, "Order.Price", converter: new CurrencyDoubleConverter()); priceLabel.SetBinding(IsEnabledProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); priceLabel.SetBinding(IsVisibleProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); StackLayout priceStack = new UnspacedStackLayout() { Children = { priceEntry, priceLabel } }; #endregion #region order date Label orderDateLabel = new Label() { HeightRequest = RowHeight, YAlign = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; orderDateLabel.SetBinding(Label.TextProperty, "Order.OrderDate", converter: new ShortDatePatternConverter()); #endregion #region due date DatePicker dueDateEntry = new DatePicker(); dueDateEntry.SetBinding(DatePicker.DateProperty, "Order.DueDate", BindingMode.TwoWay); dueDateEntry.SetBinding(IsEnabledProperty, "Order.IsOpen"); dueDateEntry.SetBinding(IsVisibleProperty, "Order.IsOpen"); Label dueDateLabel = new Label() { HeightRequest = RowHeight, YAlign = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; dueDateLabel.SetBinding(Label.TextProperty, "Order.DueDate", converter: new ShortDatePatternConverter()); dueDateLabel.SetBinding(IsEnabledProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); dueDateLabel.SetBinding(IsVisibleProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); StackLayout dueDateStack = new UnspacedStackLayout(); dueDateStack.Children.Add(dueDateEntry); dueDateStack.Children.Add(dueDateLabel); #endregion #region closed date Label closedDateLabel = new Label() { HeightRequest = RowHeight, YAlign = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; closedDateLabel.SetBinding(Label.TextProperty, "Order.ClosedDate", converter: new ShortDatePatternConverter()); closedDateLabel.SetBinding(IsEnabledProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); closedDateLabel.SetBinding(IsVisibleProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); #endregion #region product image _OrderItemImage = new Image() { Aspect = Aspect.AspectFit }; _OrderItemImage.SetBinding(Image.SourceProperty, "OrderItemImageUrl"); #endregion #region loading label Label loadingImageUrlLabel = new Label() { Text = TextResources.Customers_Orders_EditOrder_LoadingImageLabel, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HeightRequest = Sizes.MediumRowHeight, XAlign = TextAlignment.Center, YAlign = TextAlignment.End, TextColor = Palette._007 }; loadingImageUrlLabel.SetBinding(IsEnabledProperty, "IsBusy"); loadingImageUrlLabel.SetBinding(IsVisibleProperty, "IsBusy"); #endregion #region loading label Label loadingImageLabel = new Label() { Text = TextResources.Customers_Orders_EditOrder_LoadingImageLabel, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HeightRequest = Sizes.MediumRowHeight, XAlign = TextAlignment.Center, YAlign = TextAlignment.End, TextColor = Palette._007 }; loadingImageLabel.SetBinding(IsEnabledProperty, new Binding("IsLoading", source: _OrderItemImage)); loadingImageLabel.SetBinding(IsVisibleProperty, new Binding("IsLoading", source: _OrderItemImage)); #endregion #region image url fetching activity indicator ActivityIndicator imageUrlFetchingActivityIndicator = new ActivityIndicator() { HeightRequest = Sizes.LargeRowHeight }; imageUrlFetchingActivityIndicator.SetBinding(IsEnabledProperty, "IsBusy"); imageUrlFetchingActivityIndicator.SetBinding(IsVisibleProperty, "IsBusy"); imageUrlFetchingActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); #endregion #region image fetching activity indicator ActivityIndicator imageFetchingActivityIndicator = new ActivityIndicator() { HeightRequest = Sizes.LargeRowHeight }; imageFetchingActivityIndicator.SetBinding(IsEnabledProperty, new Binding("IsLoading", source: _OrderItemImage)); imageFetchingActivityIndicator.SetBinding(IsVisibleProperty, new Binding("IsLoading", source: _OrderItemImage)); imageFetchingActivityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsLoading", source: _OrderItemImage)); #endregion #region deliver action button Button deliverButton = new Button() { Text = "Deliver Order" }; deliverButton.Clicked += DeliverButton_Clicked; deliverButton.SetBinding(IsEnabledProperty, "Order.IsOpen"); deliverButton.SetBinding(IsVisibleProperty, "Order.IsOpen"); #endregion #region compose grid contents orderDetailsGrid.Children.Add(GetFieldLabelContentView(TextResources.Customers_Orders_EditOrder_ProductTitleLabel), 0, 0); orderDetailsGrid.Children.Add(GetFieldLabelContentView(TextResources.Customers_Orders_EditOrder_PriceTitleLabel), 0, 1); orderDetailsGrid.Children.Add(GetFieldLabelContentView(TextResources.Customers_Orders_EditOrder_OrderDateTitleLabel), 0, 2); orderDetailsGrid.Children.Add(GetFieldLabelContentView(TextResources.Customers_Orders_EditOrder_DueDateTitleLabel), 0, 3); var closedDateFieldLabelView = GetFieldLabelContentView(TextResources.Customers_Orders_EditOrder_ClosedDateTitleLabel); closedDateFieldLabelView.SetBinding(IsVisibleProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); closedDateFieldLabelView.SetBinding(IsEnabledProperty, "Order.IsOpen", converter: new InverseBooleanConverter()); orderDetailsGrid.Children.Add(closedDateFieldLabelView, 0, 4); orderDetailsGrid.Children.Add(productSelectionStack, 1, 0); orderDetailsGrid.Children.Add(priceStack, 1, 1); orderDetailsGrid.Children.Add(orderDateLabel, 1, 2); orderDetailsGrid.Children.Add(dueDateStack, 1, 3); orderDetailsGrid.Children.Add(closedDateLabel, 1, 4); orderDetailsGrid.Children.Add(deliverButton, 0, 5); Grid.SetColumnSpan(deliverButton, 2); #endregion #region compose view hierarchy Content = new ScrollView() { Content = new UnspacedStackLayout() { Children = { new ContentViewWithBottomBorder() { Content = headerLabelsView }, new ContentViewWithBottomBorder() { Content = orderDetailsGrid }, loadingImageUrlLabel, imageUrlFetchingActivityIndicator, loadingImageLabel, imageFetchingActivityIndicator, new ContentView() { Content = _OrderItemImage, Padding = new Thickness(20) } } } }; #endregion }
public CustomerDetailHeaderView() { #region company image Image companyImage = new Image() { Aspect = Aspect.AspectFill }; companyImage.SetBinding(Image.SourceProperty, "Account.ImageUrl"); #endregion #region gradient image Image gradientImage = new Image() { Aspect = Aspect.Fill, Source = new FileImageSource() { File = "bottom_up_gradient" }, HeightRequest = 75, BindingContext = companyImage }; gradientImage.SetBinding(Image.IsVisibleProperty, "IsLoading", converter: new InverseBooleanConverter()); #endregion #region activity indicator ActivityIndicator imageLoadingIndicator = new ActivityIndicator() { BindingContext = companyImage }; imageLoadingIndicator.SetBinding(ActivityIndicator.IsEnabledProperty, "IsLoading"); imageLoadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsLoading"); // here, since we're bound to the companyImage already, we can just reference the IsLoading property imageLoadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading"); // here, since we're bound to the companyImage already, we can just reference the IsLoading property #endregion #region company label Label companyLabel = new Label() { TextColor = Color.White, FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Large, typeof(Label)), Device.GetNamedSize(NamedSize.Large, typeof(Label)), Device.GetNamedSize(NamedSize.Large, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; companyLabel.SetBinding(Label.TextProperty, "Account.Company"); companyLabel.SetBinding(Label.TextColorProperty, new Binding("IsLoading", source: companyImage, converter: new CompanyLabelBooleanToColorConverter())); #endregion #region industry label Label industryLabel = new Label() { TextColor = Palette._008, FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; industryLabel.SetBinding(Label.TextProperty, "Account.Industry"); industryLabel.SetBinding(Label.TextColorProperty, new Binding("IsLoading", source: companyImage, converter: new IndustryLabelBooleanToColorConverter())); #endregion #region compose view hierarchy StackLayout stackLayout = new UnspacedStackLayout() { Children = { companyLabel, industryLabel }, Padding = new Thickness(20) }; AbsoluteLayout absoluteLayout = new AbsoluteLayout() { HeightRequest = 150 }; absoluteLayout.Children.Add(companyImage, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All); absoluteLayout.Children.Add(imageLoadingIndicator, new Rectangle(0, .5, 1, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.WidthProportional | AbsoluteLayoutFlags.PositionProportional); absoluteLayout.Children.Add(gradientImage, new Rectangle(0, 1, 1, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.WidthProportional | AbsoluteLayoutFlags.PositionProportional); absoluteLayout.Children.Add(stackLayout, new Rectangle(0, 1, 1, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.WidthProportional | AbsoluteLayoutFlags.PositionProportional); #endregion Content = absoluteLayout; }
public CategoryListPage(string title = null, bool isPerformingProductSelection = false) { if (title == null) { Title = "Products"; } SetBinding(CategoryListPage.TitleProperty, new Binding("Category", converter: new CategoryTitleConverter(Title))); #region category list CategoryListView categoryListView = new CategoryListView(); categoryListView.SetBinding(CategoryListView.ItemsSourceProperty, "SubCategories"); categoryListView.IsPullToRefreshEnabled = true; categoryListView.SetBinding(CategoryListView.RefreshCommandProperty, "LoadCategoriesCommand"); categoryListView.SetBinding(CategoryListView.IsRefreshingProperty, "IsBusy", mode: BindingMode.OneWay); categoryListView.ItemTapped += async(sender, e) => await App.ExecuteIfConnected(async() => { CatalogCategory catalogCategory = ((CatalogCategory)e.Item); if (catalogCategory.HasSubCategories) { await Navigation.PushAsync(new CategoryListPage(catalogCategory.Name, isPerformingProductSelection) { BindingContext = new CategoriesViewModel(catalogCategory) }); } else { await Navigation.PushAsync(new ProductListPage(catalogCategory.Name, isPerformingProductSelection) { BindingContext = new ProductsViewModel(catalogCategory.Id) }); } }); categoryListView.SetBinding(CategoryListView.HeaderProperty, "."); categoryListView.HeaderTemplate = new DataTemplate(() => { Label loadingLabel = new Label() { Text = TextResources.Products_CategoryList_LoadingLabel, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), XAlign = TextAlignment.Center, YAlign = TextAlignment.End, TextColor = Palette._007 }; loadingLabel.SetBinding(Label.IsEnabledProperty, "IsBusy", mode: BindingMode.OneWay); loadingLabel.SetBinding(Label.IsVisibleProperty, "IsBusy", mode: BindingMode.OneWay); return(loadingLabel); }); #endregion #region compose view hierarchy Content = new UnspacedStackLayout() { Children = { categoryListView } }; #endregion }
public CustomerDetailPage(Account account) { if (Device.OS == TargetPlatform.iOS) { var orders = new ImageCell { Text = TextResources.Customers_Orders_Tab_Title, ImageSource = new FileImageSource() { File = "ProductsTab" }, StyleId = "disclosure", Command = new Command(async() => await Navigation.PushAsync(new CustomerOrdersPage() { BindingContext = new OrdersViewModel(account) { Navigation = this.Navigation }, Title = TextResources.Customers_Orders_Tab_Title, Icon = new FileImageSource() { File = "ProductsTab" } // only used on iOS })) }; var sales = new ImageCell { Text = TextResources.Customers_Sales_Tab_Title, ImageSource = new FileImageSource() { File = "SalesTab" }, StyleId = "disclosure", Command = new Command(async() => await Navigation.PushAsync(new CustomerSalesPage() { BindingContext = new CustomerSalesViewModel(account) { Navigation = this.Navigation }, Title = TextResources.Customers_Sales_Tab_Title, Icon = new FileImageSource() { File = "SalesTab" } // only used on iOS })) }; var infoStack = new UnspacedStackLayout() { Children = { new CustomerDetailContactView(), new CustomerDetailPhoneView(this), new CustomerDetailAddressView(), } }; var table = new TableView() { Intent = TableIntent.Menu, HasUnevenRows = true, Root = new TableRoot() { new TableSection("Details") { new ViewCell { View = infoStack, Height = 280 } }, new TableSection("More") { orders, sales } } }; Content = new UnspacedStackLayout { Children = { new CustomerDetailHeaderView(), table } }; } else { var stackLayout = new UnspacedStackLayout() { Children = { new CustomerDetailHeaderView(), new CustomerDetailContactView(), new CustomerDetailPhoneView(this), new CustomerDetailAddressView(), } }; Content = new ScrollView() { Content = stackLayout }; } }
public CustomerDetailPhoneView(Page page) { _Page = page; #region labels Label phoneTitleLabel = new Label() { Text = TextResources.Phone, TextColor = Device.OnPlatform(Palette._005, Palette._007, Palette._006), FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; Label phoneLabel = new Label() { TextColor = Palette._006, FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Default, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))), LineBreakMode = LineBreakMode.TailTruncation }; phoneLabel.SetBinding(Label.TextProperty, "Account.Phone"); #endregion #region phone image Image phoneImage = new Image() { Source = new FileImageSource { File = Device.OnPlatform("phone_ios", "phone_android", null) }, Aspect = Aspect.AspectFit, HeightRequest = 25 }; // an expanded view to catch touches, because the image is a bit small AbsoluteLayout phoneImageTouchView = new AbsoluteLayout() { WidthRequest = Sizes.MediumRowHeight, HeightRequest = Sizes.MediumRowHeight }; phoneImageTouchView.Children.Add(phoneImage, new Rectangle(.5, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional); phoneImageTouchView.GestureRecognizers.Add( new TapGestureRecognizer() { Command = new Command(() => OnPhoneTapped(phoneLabel, null)) }); #endregion #region compose view hierarchy StackLayout stackLayout = new UnspacedStackLayout() { Children = { phoneTitleLabel, phoneLabel }, Padding = new Thickness(20) }; AbsoluteLayout absoluteLayout = new AbsoluteLayout(); absoluteLayout.Children.Add(stackLayout, new Rectangle(0, .5, 1, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional); absoluteLayout.Children.Add(phoneImageTouchView, new Rectangle(.95, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional); #endregion Content = new ContentViewWithBottomBorder() { Content = absoluteLayout }; }
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 }