Native.Button GetToolbarButton(ToolbarButtonPosition position) { ToolbarItem item = _toolbarTracker.ToolbarItems.Where( i => (position == ToolbarButtonPosition.Right && i.Order <= ToolbarItemOrder.Primary) || (position == ToolbarButtonPosition.Left && i.Order == ToolbarItemOrder.Secondary)) .OrderBy(i => i.Priority).FirstOrDefault(); if (item == default(ToolbarItem)) { return(null); } Native.Button button = new Native.Button(Forms.NativeParent); button.Clicked += (s, e) => { IMenuItemController control = item; control.Activate(); }; button.Text = item.Text; button.BackgroundColor = Color.Transparent.ToNative(); if (string.IsNullOrEmpty(item.Icon)) { if (string.IsNullOrEmpty(item.Text)) { // We assumed the default toolbar icon is "naviframe/drawer" if there are no icon and text. button.Style = StyleDefaultToolbarIcon; } else { if (position == ToolbarButtonPosition.Right) { button.Style = StyleRightToolbarButton; } else { button.Style = StyleLeftToolBarButton; } } } else { Native.Image iconImage = new Native.Image(Forms.NativeParent); var task = iconImage.LoadFromImageSourceAsync(item.Icon); button.Image = iconImage; } return(button); }
void UpdateToolbarItem(Page page, NaviItem item = null) { if (item == null) { item = GetNaviItemForPage(page); } if (_naviFrame.NavigationStack.Count == 0 || item == null || item != _naviFrame.NavigationStack.Last()) { return; } Native.Button rightButton = GetToolbarButton(ToolbarButtonPosition.Right); item.SetPartContent(PartRightToolbar, rightButton); Native.Button leftButton = GetToolbarButton(ToolbarButtonPosition.Left); item.SetPartContent(PartLeftToolbar, leftButton); UpdateHasBackButton(page, item); }
void OnActionSheetRequest(Page sender, ActionSheetArguments arguments) { // Verify that the page making the request is child of this platform if (!_platform.PageIsChildOfPlatform(sender)) { return; } var alert = Native.Dialog.CreateDialog(Forms.NativeParent); alert.Title = arguments.Title; var box = new Box(alert); if (null != arguments.Destruction) { var destruction = new Native.Button(alert) { Text = arguments.Destruction, Style = ButtonStyle.Text, TextColor = EColor.Red, AlignmentX = -1 }; destruction.Clicked += (s, evt) => { arguments.SetResult(arguments.Destruction); alert.Dismiss(); }; destruction.Show(); box.PackEnd(destruction); } foreach (string buttonName in arguments.Buttons) { var button = new Native.Button(alert) { Text = buttonName, Style = ButtonStyle.Text, AlignmentX = -1 }; button.Clicked += (s, evt) => { arguments.SetResult(buttonName); alert.Dismiss(); }; button.Show(); box.PackEnd(button); } box.Show(); alert.Content = box; if (null != arguments.Cancel) { var cancel = new EButton(Forms.NativeParent) { Text = arguments.Cancel }; alert.NegativeButton = cancel; cancel.Clicked += (s, evt) => { alert.Dismiss(); }; } alert.BackButtonPressed += (s, evt) => { alert.Dismiss(); }; alert.Show(); _alerts.Add(alert); alert.Dismissed += (s, e) => _alerts.Remove(alert); }
void ActionSheetSignalNameHandler(XPage sender, ActionSheetArguments arguments) { Native.Dialog dialog = Native.Dialog.CreateDialog(Forms.NativeParent); dialog.Title = arguments.Title; Box box = new Box(dialog); if (null != arguments.Destruction) { Native.Button destruction = new Native.Button(dialog) { Text = arguments.Destruction, Style = ButtonStyle.Text, TextColor = EColor.Red, AlignmentX = -1 }; destruction.Clicked += (s, evt) => { arguments.SetResult(arguments.Destruction); dialog.Dismiss(); }; destruction.Show(); box.PackEnd(destruction); } foreach (string buttonName in arguments.Buttons) { Native.Button button = new Native.Button(dialog) { Text = buttonName, BackgroundColor = buttonName.ToColor(), AlignmentX = -1, MinimumWidth = 400 }; if (button.BackgroundColor == EColor.White || button.BackgroundColor == ColorExtensions.Azure) { button.TextColor = EColor.Black; } button.Clicked += (s, evt) => { arguments.SetResult(buttonName); dialog.Dismiss(); }; button.Show(); box.PackEnd(button); } box.Show(); dialog.Content = box; if (null != arguments.Cancel) { EButton cancel = new EButton(dialog) { Text = arguments.Cancel }; dialog.NegativeButton = cancel; cancel.Clicked += (s, evt) => { dialog.Dismiss(); }; } dialog.BackButtonPressed += (s, evt) => { dialog.Dismiss(); }; dialog.Show(); }
void ActionSheetSignalNameHandler(Page sender, ActionSheetArguments arguments) { // Verify that the page making the request is child of this platform if (!PageIsChildOfPlatform(sender)) { return; } Native.Dialog alert = new Native.Dialog(Forms.NativeParent); alert.Title = arguments.Title; Box box = new Box(alert); if (null != arguments.Destruction) { Native.Button destruction = new Native.Button(alert) { Text = arguments.Destruction, TextColor = EColor.Red, AlignmentX = -1 }; destruction.Clicked += (s, evt) => { arguments.SetResult(arguments.Destruction); alert.Dismiss(); }; destruction.Show(); box.PackEnd(destruction); } foreach (string buttonName in arguments.Buttons) { Native.Button button = new Native.Button(alert) { Text = buttonName, AlignmentX = -1 }; button.Clicked += (s, evt) => { arguments.SetResult(buttonName); alert.Dismiss(); }; button.Show(); box.PackEnd(button); } box.Show(); alert.Content = box; if (null != arguments.Cancel) { EButton cancel = new EButton(Forms.NativeParent) { Text = arguments.Cancel }; alert.NegativeButton = cancel; cancel.Clicked += (s, evt) => { alert.Dismiss(); }; } alert.BackButtonPressed += (s, evt) => { alert.Dismiss(); }; alert.Show(); }
static void ActionSheetSignalNameHandler(Page sender, ActionSheetArguments arguments) { Native.Dialog alert = new Native.Dialog(Forms.Context.MainWindow); alert.Title = arguments.Title; Box box = new Box(alert); if (null != arguments.Destruction) { Native.Button destruction = new Native.Button(alert) { Text = arguments.Destruction, TextColor = EColor.Red, AlignmentX = -1 }; destruction.Clicked += (s, evt) => { arguments.SetResult(arguments.Destruction); alert.Dismiss(); }; destruction.Show(); box.PackEnd(destruction); } foreach (string buttonName in arguments.Buttons) { Native.Button button = new Native.Button(alert) { Text = buttonName, AlignmentX = -1 }; button.Clicked += (s, evt) => { arguments.SetResult(buttonName); alert.Dismiss(); }; button.Show(); box.PackEnd(button); } box.Show(); alert.Content = box; if (null != arguments.Cancel) { EButton cancel = new EButton(Forms.Context.MainWindow) { Text = arguments.Cancel }; alert.NegativeButton = cancel; cancel.Clicked += (s, evt) => { alert.Dismiss(); }; } alert.BackButtonPressed += (s, evt) => { alert.Dismiss(); }; alert.Show(); }