public TodayPage() { homeTopPanel = new HomeTopPanel (DateTime.Today); homeTopPanel.SelectedDateChanged += (sender, e) => SetDate(homeTopPanel.SelectedDate); pageLayout = new StackLayout { BackgroundColor = StyleManager.MainColor, Children = {homeTopPanel, homeTopPanel.BottomPanel, tasksTableView} }; var floatingButton = new FloatingActionButton {Source = "floating_button.png"}; var addTaskButton = new FloatingActionControl { Padding = new Thickness(15, 0), Tooltip = "Add a task", IsVisible = false, TapAction = () => { floatingButton.CloseAction.Dispatch(); ShowPopup(new TodoTask { title = "", category = CategoryHelper.HomeCategory.Name, isDone = false, date = selectedDate, isFavorite = false, isDeleted = false }); popup.OnPopupShown(); } }; floatingButton.OpenAction += () => { FadeOut(); floatingButton.Source = FloatingActionButton.OPENED_BUTTON_IMAGE_SOURCE; addTaskButton.IsVisible = true; }; floatingButton.CloseAction += () => { FadeIn(); floatingButton.Source = FloatingActionButton.CLOSED_BUTTON_IMAGE_SOURCE; addTaskButton.IsVisible = false; }; // Main layout with the popup and floating buttons. popupLayout.Content = pageLayout; popupLayout.BackgroundColor = Color.Black; // If popup is opened - do not allow tap on floating button. popupLayout.AllowAction += value => floatingButton.AllowTap = value; popupLayout.AddChild(floatingButton, Constraint.RelativeToParent(layout => layout.Width - 50), Constraint.RelativeToParent(layout => layout.Height - 50)); popupLayout.AddChild(addTaskButton, Constraint.RelativeToParent(layout => layout.Width - addTaskButton.Width), Constraint.RelativeToParent(layout => layout.Height - 100)); Content = popupLayout; selectedDate = DateTime.Now; UpdateList (); }
public FloatingActionControl() { Spacing = 10; Orientation = StackOrientation.Horizontal; HorizontalOptions = LayoutOptions.End; _floatingActionButton = new FloatingActionButton { HorizontalOptions = LayoutOptions.End, Source = FLOATING_BUTTON_IMAGE, SizeRequest = 30 }; _tooltipLabel = new CustomFontLabel {TextColor = Color.Black, CustomFontSize = NamedSize.Micro}; _tooltipLayout = new Frame { BackgroundColor = Color.White, Padding = new Thickness(10, 0), HasShadow = false, Content = _tooltipLabel }; Children.Add(_tooltipLayout); Children.Add(_floatingActionButton); }