private void BuildStep1() { mainText.Text = "get started by \r\n creating an account"; bottomLayout.Children.Clear(); bottomLayout.Orientation = StackOrientation.Vertical; bottomLayout.Spacing = 0; bottomLayout.BackgroundColor = Color.White; phoneEntry = UIUtils.MakeEntry("Phone", UIUtils.FONT_SFUIDISPLAY_BOLD); bottomLayout.Children.Add(phoneEntry); bottomLayout.Children.Add(UIUtils.MakeSeparator()); //addressEntry = UIUtils.MakeEntry("Location/Address", UIUtils.FONT_SFUIDISPLAY_BOLD); //bottomLayout.Children.Add(addressEntry); //bottomLayout.Children.Add(UIUtils.MakeSeparator()); var addressACEntry = new AutoCompleteView(); addressEntry = addressACEntry.EntryText; addressEntry.FontFamily = UIUtils.FONT_SFUIDISPLAY_BOLD; addressEntry.HeightRequest = 45; addressEntry.FontSize = 17; addressEntry.BackgroundColor = Color.White; addressEntry.Margin = new Thickness(20, 10, 20, 0); addressEntry.Placeholder = "Location/Address"; addressEntry.PlaceholderColor = Color.FromHex("787878"); addressEntry.TextColor = Color.Black; bottomLayout.Children.Add(addressACEntry); bottomLayout.Children.Add(UIUtils.MakeSeparator()); var sh = new PlaceSearchHelper(addressACEntry); sh.OnSelected += (o, p) => { lastLocation = p; }; emailEntry = UIUtils.MakeEntry("Email", UIUtils.FONT_SFUIDISPLAY_BOLD); bottomLayout.Children.Add(emailEntry); bottomLayout.Children.Add(UIUtils.MakeSeparator()); pswdEntry = UIUtils.MakeEntry("Password", UIUtils.FONT_SFUIDISPLAY_BOLD); pswdEntry.IsPassword = true; bottomLayout.Children.Add(pswdEntry); bottomLayout.Children.Add(UIUtils.MakeSeparator()); fnameEntry = UIUtils.MakeEntry("First Name", UIUtils.FONT_SFUIDISPLAY_BOLD); bottomLayout.Children.Add(fnameEntry); bottomLayout.Children.Add(UIUtils.MakeSeparator()); lnameEntry = UIUtils.MakeEntry("Last Name", UIUtils.FONT_SFUIDISPLAY_BOLD); bottomLayout.Children.Add(lnameEntry); bottomLayout.Children.Add(UIUtils.MakeSeparator()); var continueButton = UIUtils.MakeButton("CONTINUE", UIUtils.FONT_SFUIDISPLAY_REGULAR); continueButton.Clicked += OnContinue; continueButton.Margin = new Thickness(0, 40, 0, 0); bottomLayout.Children.Add(continueButton); bottomLayout.ForceLayout(); currentStep = 1; MakeEntryVisibleWithKeybord(new Entry[] { phoneEntry, addressEntry, emailEntry, pswdEntry, lnameEntry, fnameEntry }); }
private void BuildLayout() { var main = new StackLayout(); main.BackgroundColor = Color.White; main.Spacing = 0; var rl = new RelativeLayout(); rl.Children.Add(main, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(p => p.Width), Constraint.RelativeToParent(p => p.Height)); this.Content = rl; var header = UIUtils.MakeHeader(this, "My Services"); var addButton = UIUtils.MakeButton("ADD SERVICE", UIUtils.FONT_BEBAS_REGULAR); addButton.VerticalOptions = LayoutOptions.EndAndExpand; addButton.Clicked += AddButton_Clicked; list = new ListView(); list.RowHeight = Device.OnPlatform(140, 140, 100); list.SeparatorColor = Color.Transparent; list.SeparatorVisibility = SeparatorVisibility.None; list.ItemTemplate = new DataTemplate(() => new ServiceViewCell(OnEditClick, OnDeleteClick)); list.VerticalOptions = LayoutOptions.FillAndExpand; main.Children.Add(header); main.Children.Add(UIUtils.MakeSeparator(true)); main.Children.Add(list); main.Children.Add(addButton); list.HeightRequest = App.ScreenHeight - Utils.GetControlSize(header).Height - Utils.GetControlSize(addButton).Height - 1; main.ForceLayout(); }
//----------------------------------------------------------------------------- public ListPage() { try { InitializeComponent(); // adjust size of icons in menu bar IScreenMetrics metrics = DependencyService.Get <IScreenMetrics>(); double adjustedDensity = metrics.AdjustedDensity(); StackLayout titlebar = (StackLayout)FindByName("titlebar"); foreach (VisualElement child in titlebar.Children) { // if (child.GetType().Equals (typeof(ImageButton))) { if (child.HeightRequest != -1) { child.HeightRequest = child.HeightRequest * adjustedDensity; } if (child.WidthRequest != -1) { child.WidthRequest = child.WidthRequest * adjustedDensity; } } } titlebar.ForceLayout(); LoadList(); DetailList.ItemsSource = nodes; } catch (Exception e) { Debug.WriteLine("ListPage(): ", e.ToString()); } }
private void BuildLayout() { var main = new StackLayout(); main.BackgroundColor = Color.White; main.Spacing = 0; var rl = new RelativeLayout(); rl.Children.Add(main, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(p => p.Width), Constraint.RelativeToParent(p => p.Height)); this.Content = rl; var header = UIUtils.MakeHeader(this, "My Services"); var addButton = UIUtils.MakeButton("ADD A SERVICE +", UIUtils.FONT_BEBAS_REGULAR); addButton.VerticalOptions = LayoutOptions.EndAndExpand; addButton.Clicked += AddButton_Clicked; servicesHolder = new StackLayout(); servicesHolder.Spacing = 0; var scrollView = new ScrollView(); scrollView.Content = servicesHolder; main.Children.Add(header); main.Children.Add(UIUtils.MakeSeparator(true)); main.Children.Add(addButton); main.Children.Add(scrollView); scrollView.HeightRequest = App.ScreenHeight - Utils.GetControlSize(header).Height - Utils.GetControlSize(addButton).Height - 1; main.ForceLayout(); }
private async void AcBtn_Clicked(object sender, EventArgs e) { AccordionButton btn = (AccordionButton)sender; StackLayout f = btn.ContentFrame; await btn.RotateTo((btn.FrameOpen ? 0 : 180), 200, Easing.CubicInOut); if (btn.FrameOpen) { await Task.WhenAll(new List <Task> { f.FadeTo(0, 200, Easing.Linear) }); f.IsVisible = false; f.ForceLayout(); btn.FrameOpen = false; } else { f.IsVisible = true; //await Task.WhenAll(new List<Task> { f.LayoutTo(new Rectangle(f.Bounds.X, f.Bounds.Y, f.Bounds.Width, 300), 500, Easing.CubicOut)}); await Task.WhenAll(new List <Task> { f.FadeTo(1, 400, Easing.Linear) }); //f.Opacity = 1; btn.FrameOpen = true; } }
void ResizeStackLayout(double heightRequest) { Device.BeginInvokeOnMainThread(() => { _adjustableStackLayout.HeightRequest = heightRequest; _adjustableStackLayout.ForceLayout(); this.ForceLayout(); }); }
public void addpage(ContentView e) { StackLayout v = ((StackLayout)App.getmain.Content).FindByName <StackLayout>("center"); if (v != null) { if (v.Children.Count > 0) { v.Children.RemoveAt(0); } v.Children.Add(e); v.ForceLayout(); } }
/// <summary> /// Update postfix label /// </summary> private void UpdatePostFix() { _postFix.Text = string.IsNullOrWhiteSpace(PostfixIcon) ? Postfix : PostfixIcon; _postFix.FontFamily = string.IsNullOrWhiteSpace(PostfixIcon) ? null : FontAwesomeLabel.FontAwesomeName; //_postFix.FontSize = string.IsNullOrWhiteSpace(PostfixIcon) // ? Device.OnPlatform<int>(14, 14, 14) // : Device.OnPlatform<int>(18, 18, 18); if (_layout == null) { return; } _layout.ForceLayout(); _entryAndPostfixLayout.ForceLayout(); }
public void IntegrationTest() { var parent = new StackLayout { Spacing = 0, IsPlatformEnabled = true, }; var handler = Substitute.For <IViewHandler>(); parent.Handler = handler; var child1 = new Button { Text = "Test", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start, IsPlatformEnabled = true, }; var child2 = new Button { Text = "Test", IsPlatformEnabled = true, }; child2.Margin = new Thickness(5, 10, 15, 20); parent.Children.Add(child1); parent.Children.Add(child2); parent.Layout(new Rectangle(0, 0, 1000, 1000)); Assert.AreEqual(new Rectangle(0, 0, 100, 50), child1.Bounds); Assert.AreEqual(new Rectangle(5, 60, 980, 50), child2.Bounds); child1.Margin = new Thickness(10, 20, 30, 40); // Verify that the margin change invalidated the layout, and simulate a native layout change AssertInvalidated(handler); parent.ForceLayout(); Assert.AreEqual(new Rectangle(10, 20, 100, 50), child1.Bounds); Assert.AreEqual(new Rectangle(5, 120, 980, 50), child2.Bounds); }
public void PaddingResizeTest() { var child = new BoxView { IsPlatformEnabled = true, WidthRequest = 20, HeightRequest = 20, }; var innerStack = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, IsPlatformEnabled = true, Children = { child } }; var outerLayout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, IsPlatformEnabled = true, Children = { innerStack } }; var handler = Substitute.For <IViewHandler>(); outerLayout.Handler = handler; outerLayout.Layout(new Rectangle(0, 0, 100, 100)); var beforeSize = innerStack.Bounds.Size; innerStack.Padding = new Thickness(30); // Verify that the Padding change invalidated the layout, and simulate a native layout update AssertInvalidated(handler); outerLayout.ForceLayout(); var afterSize = innerStack.Bounds.Size; Assert.AreNotEqual(beforeSize, afterSize, "Padding was grow, so Size should be bigger"); }
protected override void OnPropertyChanged(string propertyName = null) { base.OnPropertyChanged(); if (propertyName == null) { return; } if (Equals(propertyName, "IndicatorImage")) { _buttonImage.Source = IndicatorImage; } if (Equals(propertyName, "HeaderText")) { _headerText.Text = HeaderText; } if (Equals(propertyName, "HeaderTextColor")) { _headerText.TextColor = HeaderTextColor; } if (Equals(propertyName, "HeaderTextSize")) { _headerText.FontSize = HeaderTextSize; } if (Equals(propertyName, "HeaderFontAttributes")) { _headerText.FontAttributes = HeaderFontAttributes; } if (Equals(propertyName, "CollapseContent")) { _collapseContent = CollapseContent; Children.Add(_collapseContent, 0, 1); } if (Equals(propertyName, "Collapsed")) { _collapseContent.IsVisible = !Collapsed; _collapseContent.ForceLayout(); } if (Equals(propertyName, "HeaderBackgroundColor")) { _headerGrid.BackgroundColor = HeaderBackgroundColor; } }
void ItemsSourceChanged() { _stack.Children.Clear(); if (ItemsSource == null) { return; } foreach (IAssessmentItemData item in ItemsSource) { var view = (View)ItemTemplate.CreateContent(); var bindableObject = view as QuestionView; if (bindableObject != null) { bindableObject.BindingContext = item; } _stack.Children.Add(view); } _stack.ForceLayout(); this.UpdateChildrenLayout(); this.ForceLayout(); }
public void TestVisibility() { View child1, child2; var stack = new StackLayout { IsPlatformEnabled = true, Children = { (child1 = new View { IsPlatformEnabled = true }), (child2 = new View { IsPlatformEnabled = true }) } }; var handler = Substitute.For <IViewHandler>(); stack.Handler = handler; stack.Layout(new Rectangle(0, 0, 100, 100)); var size = stack.Measure(double.PositiveInfinity, double.PositiveInfinity).Request; Assert.AreEqual(new Rectangle(0, 0, 100, 20), child1.Bounds); Assert.AreEqual(new Rectangle(0, 26, 100, 20), child2.Bounds); Assert.AreEqual(new Size(100, 46), size); child1.IsVisible = false; // Verify that the visibility change invalidated the layout, and simulate a native layout update AssertInvalidated(handler); stack.ForceLayout(); Assert.False(child1.IsVisible); Assert.AreEqual(new Rectangle(0, 0, 100, 20), child2.Bounds); size = stack.Measure(double.PositiveInfinity, double.PositiveInfinity).Request; Assert.AreEqual(new Size(100, 20), size); }
public SignedDocumentsPage() { NavigationPage.SetHasBackButton(this, false); listView = new CustomListView { ItemsSource = requests, RowHeight = 100, IsPullToRefreshEnabled = true, Margin = new Thickness(Device.OnPlatform(0, 5, 5), Device.OnPlatform(5, 0, 0), 5, 0), HasUnevenRows = true, ItemTemplate = new DataTemplate(() => { Grid gridTitle = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = 80 } } }; Grid gridStatus = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Star } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = 150 } } }; gridTitle.HorizontalOptions = LayoutOptions.FillAndExpand; Label labelTitle = new Label(); labelTitle.SetBinding(Label.TextProperty, "Title"); labelTitle.HorizontalOptions = LayoutOptions.FillAndExpand; labelTitle.VerticalOptions = LayoutOptions.FillAndExpand; labelTitle.FontSize = 18; labelTitle.LineBreakMode = LineBreakMode.WordWrap; Label labelData = new Label(); labelData.SetBinding(Label.TextProperty, "DateStr"); labelData.HorizontalOptions = LayoutOptions.EndAndExpand; labelData.FontSize = 12; labelData.HorizontalTextAlignment = TextAlignment.End; labelData.TextColor = Color.FromHex("#0A80D0"); labelData.Margin = new Thickness(0, 2, 0, 0); Label labelDescription = new Label(); labelDescription.SetBinding(Label.TextProperty, "Description"); labelDescription.FontSize = 14; labelDescription.HorizontalOptions = LayoutOptions.FillAndExpand; labelDescription.VerticalOptions = LayoutOptions.FillAndExpand; labelDescription.LineBreakMode = LineBreakMode.TailTruncation; Label labelAuthors = new Label(); labelAuthors.SetBinding(Label.TextProperty, "Author"); labelAuthors.TextColor = Color.FromHex("#0A80D0"); labelAuthors.FontSize = 12; labelAuthors.HorizontalOptions = LayoutOptions.FillAndExpand; labelAuthors.VerticalOptions = LayoutOptions.FillAndExpand; labelAuthors.VerticalTextAlignment = TextAlignment.End; labelAuthors.Margin = new Thickness(0, 5, 0, 0); Label labelStatus = new Label(); labelStatus.SetBinding(Label.TextProperty, "Status"); //labelStatus.TextColor = Color.FromHex("#0A80D0"); labelStatus.FontAttributes = FontAttributes.Italic; labelStatus.FontSize = 12; labelStatus.HorizontalOptions = LayoutOptions.FillAndExpand; labelStatus.VerticalOptions = LayoutOptions.FillAndExpand; labelStatus.HorizontalTextAlignment = TextAlignment.End; labelStatus.VerticalTextAlignment = TextAlignment.End; labelStatus.Margin = new Thickness(0, 5, 0, 0); gridTitle.Children.Add(labelTitle, 0, 0); gridTitle.Children.Add(labelData, 1, 0); gridTitle.HorizontalOptions = LayoutOptions.FillAndExpand; gridTitle.VerticalOptions = LayoutOptions.FillAndExpand; gridStatus.Children.Add(labelAuthors, 0, 0); gridStatus.Children.Add(labelStatus, 1, 0); gridStatus.VerticalOptions = LayoutOptions.FillAndExpand; gridStatus.HorizontalOptions = LayoutOptions.FillAndExpand; var vc = new ViewCell { View = new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(Device.OnPlatform(10, 0, 0), 5), Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new StackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0, Children = { gridTitle, labelDescription, gridStatus } } } } }; return(vc); }) }; Label labelEmpty = new Label(); labelEmpty.Text = AppResources.NO_REQUESTS; labelEmpty.HorizontalOptions = LayoutOptions.FillAndExpand; labelEmpty.VerticalOptions = LayoutOptions.Start; labelEmpty.Margin = new Thickness(20); labelEmpty.HorizontalTextAlignment = TextAlignment.Center; labelEmpty.FontSize = 16; this.Title = AppResources.FINISHED_REQUESTS; var view = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { labelEmpty, listView } }; this.Content = view; requests.CollectionChanged += (sender, e) => { Device.BeginInvokeOnMainThread(() => { labelEmpty.IsVisible = requests.Count == 0; view.ForceLayout(); }); }; Action refreshSignatures = async() => { try { listView.IsRefreshing = true; await LoadSignatureRequests(0); listView.IsRefreshing = false; } catch (Exception e) { listView.IsRefreshing = false; Device.BeginInvokeOnMainThread(() => { DialogHelper.ShowAlertOK(AppResources.APP_TITLE, AppResources.ERROR_UNABLE_TO_REACH_REQUEST_LIST_API); }); } }; listView.RefreshCommand = new Command(refreshSignatures); listView.ItemSelected += async delegate(object sender, SelectedItemChangedEventArgs e) { SignedDocument signedDocument = (SignedDocument)e.SelectedItem; ((ListView)sender).SelectedItem = null; if (signedDocument == null) { return; } if (signedDocument.Documents.Count > 1) { var childPage = new ChildDocumentPage(signedDocument, false); await Navigation.PushAsync(childPage); await childPage.PageClosedTask; } else { try { Document doc = signedDocument.Documents.First(); using (var progress = DialogHelper.ShowProgress(AppResources.LOADING_DOCUMENT)) { await doc.LoadXmlDocument(); } SignaturePage assinarPage = new SignaturePage(doc.Title, signedDocument, doc, false); await Navigation.PushAsync(assinarPage); await assinarPage.PageClosedTask; } catch (Exception ex) { UserDialogs.Instance.Alert(AppResources.DOCUMENT_LOADING_FAILED, AppResources.APP_TITLE, AppResources.OK); } } }; listView.ItemAppearing += async(sender, e) => { var selected = e.Item as SignedDocument; if (requests.MoreAvailable && requests.ToList().Last() == selected) { await LoadSignatureRequests(requests.CurrentPage + 1); } }; bool showingActionSheet = false; listView.LongClicked += async(sender, e) => { if (showingActionSheet) { return; } SignedDocument selected = (SignedDocument)e.Item; List <string> buttons = new List <string> { AppResources.DOCUMENT_METADATA }; if (selected.AttachmentCount > 0) { buttons.Add(AppResources.ATTACHMENTS); } Dictionary <string, InboxMessageAction> dictActions = selected.Actions. Where(a => AppResources.ResourceManager.GetString(a.Name) != null). ToDictionary(x => AppResources.ResourceManager.GetString(x.Name), x => x); if (dictActions.Keys.Count > 0) { buttons.AddRange(dictActions.Keys); } showingActionSheet = true; var selectedActionName = await this.DisplayActionSheet(AppResources.ACTIONS, AppResources.CANCEL, null, buttons.ToArray()); showingActionSheet = false; if (string.IsNullOrEmpty(selectedActionName)) { return; } if (selectedActionName == AppResources.ATTACHMENTS) { await Navigation.PushAsync(new AttachmentsPage(selected)); } else if (selectedActionName == AppResources.DOCUMENT_METADATA) { await Navigation.PushAsync(new DocumentInfo(selected)); } else if (dictActions.ContainsKey(selectedActionName)) { var action = dictActions[selectedActionName]; if (action != null) { await actionController.ExecuteAction(action, async() => await LoadSignatureRequests(0)); } } }; Device.BeginInvokeOnMainThread(() => { LoadSignatureRequests(0); }); }
/// <summary> /// Initializes a new instance of the <see cref="NControl.Controls.TabStripControl"/> class. /// </summary> public TabStripControl() { _mainLayout = new RelativeLayout(); Content = _mainLayout; // Create tab control _buttonStack = new StackLayoutEx { Orientation = StackOrientation.Horizontal, Padding = 0, Spacing = 0, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.FillAndExpand, }; _indicator = new TabBarIndicator { VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Start, BackgroundColor = (Color)TabIndicatorColorProperty.DefaultValue, HeightRequest = 6, WidthRequest = 0, }; _tabControl = new NControlView { BackgroundColor = TabBackColor, Content = new Grid { Padding = 0, ColumnSpacing = 0, RowSpacing = 0, Children = { _buttonStack, _indicator, } } }; _mainLayout.Children.Add(_tabControl, () => new Rectangle( 0, 0, _mainLayout.Width, TabHeight) ); // Create content control _contentView = new Grid { ColumnSpacing = 0, RowSpacing = 0, Padding = 0, BackgroundColor = Color.Transparent, }; _mainLayout.Children.Add(_contentView, () => new Rectangle( 0, TabHeight, _mainLayout.Width, _mainLayout.Height - TabHeight) ); _children.CollectionChanged += (sender, e) => { _contentView.Children.Clear(); _buttonStack.Children.Clear(); foreach (var tabChild in Children) { var tabItemControl = new TabBarButton(tabChild.Title); if (FontFamily != null) { tabItemControl.FontFamily = FontFamily; } tabItemControl.FontSize = FontSize; tabItemControl.SelectedColor = TabIndicatorColor; _buttonStack.Children.Add(tabItemControl); } if (Children.Any()) { Activate(Children.First(), false); } }; // Border var border = new NControlView { DrawingFunction = (canvas, rect) => { canvas.DrawPath(new NGraphics.PathOp[] { new NGraphics.MoveTo(0, 0), new NGraphics.LineTo(rect.Width, 0) }, NGraphics.Pens.Gray, null); }, }; _mainLayout.Children.Add(border, () => new Rectangle( 0, TabHeight, _mainLayout.Width, 1)); // Shadow _shadow = new NControlView { DrawingFunction = (canvas, rect) => { canvas.DrawRectangle(rect, null, new NGraphics.LinearGradientBrush( new NGraphics.Point(0.5, 0.0), new NGraphics.Point(0.5, 1.0), Color.Black.MultiplyAlpha(0.3).ToNColor(), NGraphics.Colors.Clear, NGraphics.Colors.Clear)); } }; _mainLayout.Children.Add(_shadow, () => new Rectangle( 0, TabHeight, _mainLayout.Width, 6)); _shadow.IsVisible = false; SizeChanged += (object sender, EventArgs e) => { _buttonStack.ForceLayout(); ForceLayout(); }; }
public MainPage() { var visibleImage = new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, HeightRequest = 50 }; var invisibleImage = new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, IsVisible = false, HeightRequest = 50 }; var transparentImage = new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, Opacity = 0, HeightRequest = 50 }; var offScreenImage = new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, TranslationX = 1000, TranslationY = 1000, HeightRequest = 50 }; var visibleContainer = new StackLayout { Children = { new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, HeightRequest = 50 } } }; var invisibleContainer = new StackLayout { Children = { new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, HeightRequest = 50 } }, IsVisible = false }; var transparentContainer = new StackLayout { Children = { new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, HeightRequest = 50 } }, Opacity = 0 }; var offScreenContainer = new StackLayout { Children = { new Image { Source = "song_entry_premium_symbol.png", HorizontalOptions = LayoutOptions.Start, HeightRequest = 50 } }, TranslationX = 1000, TranslationY = 1000 }; var contentWrapper = new StackLayout(); contentWrapper.Children.Add(visibleImage); contentWrapper.Children.Add(invisibleImage); contentWrapper.Children.Add(transparentImage); contentWrapper.Children.Add(offScreenImage); contentWrapper.Children.Add(visibleContainer); contentWrapper.Children.Add(invisibleContainer); contentWrapper.Children.Add(transparentContainer); contentWrapper.Children.Add(offScreenContainer); Task.Run(async() => { await Task.Delay(2000); await MainThread.InvokeOnMainThreadAsync(async() => { invisibleImage.IsVisible = true; await Task.WhenAll(transparentImage.FadeTo(1), offScreenImage.TranslateTo(0, 0)); invisibleContainer.IsVisible = true; await Task.WhenAll(transparentContainer.FadeTo(1), offScreenContainer.TranslateTo(0, 0)); //when forcing layout on parent layout, it works. But that is not an acceptable solution transparentContainer.ForceLayout(); }); }); Content = contentWrapper; }
public DocumentListPage(DocumentListType documentType, String icon, RefreshItems refreshCallback, MessageCollection <SignatureRequest> requestsGroup) { mySignatureRequests = requestsGroup; NavigationPage.SetHasBackButton(this, false); listView = new CustomListView { ItemsSource = mySignatureRequests, RowHeight = 100, IsPullToRefreshEnabled = true, Margin = new Thickness(Device.OnPlatform(0, 5, 5), Device.OnPlatform(5, 0, 0), 5, 0), ItemTemplate = new DataTemplate(() => { Grid gridTitle = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = 80 } } }; Grid gridStatus = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Star } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = 120 } } }; Label labelTitle = new Label(); labelTitle.SetBinding(Label.TextProperty, "Title"); labelTitle.HorizontalOptions = LayoutOptions.FillAndExpand; labelTitle.FontSize = 18; labelTitle.LineBreakMode = LineBreakMode.TailTruncation; labelTitle.SetBinding(Label.FontAttributesProperty, "Read", BindingMode.Default, new ReadFontAttributeConverter()); Label labelData = new Label(); labelData.SetBinding(Label.TextProperty, "DateStr"); labelData.HorizontalOptions = LayoutOptions.FillAndExpand; labelData.FontSize = 12; labelData.HorizontalTextAlignment = TextAlignment.End; labelData.TextColor = Color.FromHex("#0A80D0"); labelData.Margin = new Thickness(0, 2, 0, 0); labelData.SetBinding(Label.FontAttributesProperty, "Read", BindingMode.Default, new ReadFontAttributeConverter()); Label labelDescription = new Label(); labelDescription.SetBinding(Label.TextProperty, "Description"); labelDescription.FontSize = 14; labelDescription.HorizontalOptions = LayoutOptions.FillAndExpand; labelDescription.VerticalOptions = LayoutOptions.FillAndExpand; labelDescription.LineBreakMode = LineBreakMode.TailTruncation; labelDescription.SetBinding(Label.FontAttributesProperty, "Read", BindingMode.Default, new ReadFontAttributeConverter()); Label labelAuthors = new Label(); labelAuthors.SetBinding(Label.TextProperty, "Author"); labelAuthors.TextColor = Color.FromHex("#0A80D0"); labelAuthors.FontSize = 12; labelAuthors.HorizontalOptions = LayoutOptions.FillAndExpand; labelAuthors.VerticalOptions = LayoutOptions.EndAndExpand; labelAuthors.Margin = new Thickness(0, 5, 0, 0); labelAuthors.LineBreakMode = LineBreakMode.TailTruncation; labelAuthors.VerticalTextAlignment = TextAlignment.End; labelAuthors.HorizontalTextAlignment = TextAlignment.Start; labelAuthors.SetBinding(Label.FontAttributesProperty, "Read", BindingMode.Default, new ReadFontAttributeConverter()); Label labelStatus = new Label(); labelStatus.SetBinding(Label.TextProperty, "Status"); labelStatus.FontAttributes = FontAttributes.Italic; labelStatus.FontSize = 12; labelStatus.HorizontalOptions = LayoutOptions.FillAndExpand; labelStatus.VerticalOptions = LayoutOptions.EndAndExpand; labelStatus.HorizontalTextAlignment = TextAlignment.End; labelStatus.VerticalTextAlignment = TextAlignment.End; labelStatus.Margin = new Thickness(0, 5, 0, 0); gridTitle.Children.Add(labelTitle, 0, 0); gridTitle.Children.Add(labelData, 1, 0); gridStatus.Children.Add(labelAuthors, 0, 0); gridStatus.Children.Add(labelStatus, 1, 0); gridStatus.HeightRequest = 50; var vc = new ViewCell { View = new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(Device.OnPlatform(10, 0, 0), 5), Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0, Children = { gridTitle, labelDescription, gridStatus } } } } }; /*var mine = documentType == DocumentListType.PENDING_MINE; * var ignoreAction = new MenuItem { Text = mine ? AppResources.CANCEL : AppResources.IGNORE, IsDestructive = true }; * ignoreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); * ignoreAction.Clicked += async (sender, e) => { * * var mi = ((MenuItem)sender); * var sig = (SignatureRequest)mi.CommandParameter; * * if (mine) * { * await CancelRequest(sig); * } * else * { * await IgnoreRequest(sig); * } * }; * * //TODO: Check https://bugzilla.xamarin.com/show_bug.cgi?id=45027 * vc.ContextActions.Add(ignoreAction);*/ return(vc); }) }; Label labelEmpty = new Label(); labelEmpty.Text = AppResources.NO_REQUESTS; labelEmpty.HorizontalOptions = LayoutOptions.FillAndExpand; labelEmpty.VerticalOptions = LayoutOptions.Start; labelEmpty.Margin = new Thickness(20); labelEmpty.HorizontalTextAlignment = TextAlignment.Center; labelEmpty.FontSize = 16; this.documentType = documentType; this.Title = (documentType == DocumentListType.PENDING_MINE ? AppResources.MY_DOCUMENTS:AppResources.OTHER_DOCUMENTS); if (Device.OS == TargetPlatform.iOS) { this.Icon = (FileImageSource)FileImageSource.FromFile(icon); } var view = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { labelEmpty, listView } }; this.Content = view; mySignatureRequests.CollectionChanged += (sender, e) => { Device.BeginInvokeOnMainThread(() => { reloadBadgeCount(); labelEmpty.IsVisible = mySignatureRequests.Count == 0; view.ForceLayout(); Refreshing = false; }); }; refreshSignatures = async() => { try { await refreshCallback(DocumentListType.ALL, 0); } catch (Exception e) { Device.BeginInvokeOnMainThread(() => { UserDialogs.Instance.Alert(AppResources.ERROR_UNABLE_TO_REACH_REQUEST_LIST_API, AppResources.APP_TITLE, AppResources.OK); }); } }; listView.RefreshCommand = new Command(() => refreshSignatures()); listView.ItemSelected += async delegate(object sender, SelectedItemChangedEventArgs e) { SignatureRequest signatureRequest = (SignatureRequest)e.SelectedItem; ((ListView)sender).SelectedItem = null; if (signatureRequest == null) { return; } bool reload = false; if (!signatureRequest.Read) { signatureRequest.Read = true; signatureRequestController.MarkAsRead(signatureRequest); mySignatureRequests.NotReadCount--; reloadBadgeCount(); } if (signatureRequest.Documents.Count > 1) { var childPage = new ChildDocumentPage(signatureRequest, signatureRequest.CanBeSigned); await Navigation.PushAsync(childPage); reload = await childPage.PageClosedTask; } else { try { Document doc = signatureRequest.Documents.First(); using (var progress = DialogHelper.ShowProgress(AppResources.LOADING_DOCUMENT)) { await doc.LoadXmlDocument(); } SignaturePage assinarPage = new SignaturePage(AppResources.SIGN_DOCUMENT, signatureRequest, doc, signatureRequest.CanBeSigned); await Navigation.PushAsync(assinarPage); reload = await assinarPage.PageClosedTask; } catch (Exception ex) { UserDialogs.Instance.Alert(AppResources.DOCUMENT_LOADING_FAILED, AppResources.APP_TITLE, AppResources.OK); } } if (reload) { await refreshSignatures(); } }; listView.ItemAppearing += (sender, e) => { var selected = e.Item as SignatureRequest; if (mySignatureRequests.MoreAvailable && mySignatureRequests.ToList().Last() == selected) { refreshCallback(documentType, mySignatureRequests.CurrentPage + 1); } }; bool showingActionSheet = false; listView.LongClicked += async(sender, e) => { if (showingActionSheet) { return; } SignatureRequest selected = (SignatureRequest)e.Item; List <string> buttons = new List <string> { AppResources.DOCUMENT_METADATA }; if (selected.AttachmentCount > 0) { buttons.Add(AppResources.ATTACHMENTS); } if (!selected.Archived) { buttons.Add(AppResources.ARCHIVE); } Dictionary <string, InboxMessageAction> dictActions = selected.Actions. Where(a => AppResources.ResourceManager.GetString(a.Name) != null). ToDictionary(x => AppResources.ResourceManager.GetString(x.Name), x => x); if (dictActions.Keys.Count > 0) { buttons.AddRange(dictActions.Keys); } showingActionSheet = true; var selectedActionName = await this.DisplayActionSheet(AppResources.ACTIONS, AppResources.CLOSE, null, buttons.ToArray()); showingActionSheet = false; if (string.IsNullOrEmpty(selectedActionName)) { return; } if (selectedActionName == AppResources.ATTACHMENTS) { await Navigation.PushAsync(new AttachmentsPage(selected)); } else if (selectedActionName == AppResources.DOCUMENT_METADATA) { await Navigation.PushAsync(new DocumentInfo(selected)); } else if (selectedActionName == AppResources.ARCHIVE) { await ArchiveRequest(selected); } else if (dictActions.ContainsKey(selectedActionName)) { var action = dictActions[selectedActionName]; if (action != null) { await actionController.ExecuteAction(action, refreshSignatures); } } }; //CreateFilterToolbar(this); MessagingCenter.Subscribe <string>(this, "Notification", s => refreshSignatures(), null); }