static void UpdatePadding(Thickness thickness, FormsElement page) { if (page.On <iOS>().UsingSafeArea()) { page.Padding = thickness; } }
internal void Show(Forms.Page page, SnackBarOptions arguments) { var snackBarLayout = new SnackBarLayout(arguments); var pageControl = Platform.GetRenderer(page).ContainerElement.Parent; var grid = FindVisualChildByName <Border>(pageControl, "BottomCommandBarArea").Parent as Grid; var snackBarRow = new RowDefinition() { Height = GridLength.Auto }; snackBarTimer = new DispatcherTimer { Interval = arguments.Duration }; snackBarTimer.Tick += (sender, e) => { grid.Children.Remove(snackBarLayout); grid.RowDefinitions.Remove(snackBarRow); snackBarTimer.Stop(); arguments.SetResult(false); }; snackBarLayout.OnSnackBarActionExecuted += () => { grid.Children.Remove(snackBarLayout); grid.RowDefinitions.Remove(snackBarRow); snackBarTimer.Stop(); arguments.SetResult(true); }; snackBarTimer.Start(); grid.RowDefinitions.Add(snackBarRow); grid.Children.Add(snackBarLayout); Grid.SetRow(snackBarLayout, grid.RowDefinitions.Count - 1); }
public TranspatentNavigationPage(Forms.Page root) : base(root) { InitializeComponent(); MessagingService.Current.Subscribe <Color>(MessageKeys.ToolbarColor, (page, color) => { BarBackgroundColor = color; }); }
protected virtual async Task InternalNavigateToAsync(Type viewModelType, object parameter) { Forms.Page page = CreateAndBindPage(viewModelType, parameter); if (page is LoginView) { CurrentApplication.MainPage = new TranspatentNavigationPage(page); } else if (page is MainView) { CurrentApplication.MainPage = page; } else if (CurrentApplication.MainPage is MainView) { var mainPage = CurrentApplication.MainPage as MainView; var navigationPage = mainPage.Detail as TranspatentNavigationPage; if (navigationPage != null) { if (page is DetailView) { navigationPage.BarBackgroundColor = Color.Transparent; } else { navigationPage.BarBackgroundColor = Color.Black; } await navigationPage.PushAsync(page); } else { navigationPage = new TranspatentNavigationPage(page); mainPage.Detail = navigationPage; } mainPage.IsPresented = false; } else { var navigationPage = CurrentApplication.MainPage as TranspatentNavigationPage; if (navigationPage != null) { await navigationPage.PushAsync(page); } else { CurrentApplication.MainPage = new TranspatentNavigationPage(page); } } await(page.BindingContext as ViewModelBase).InitializeAsync(parameter); }
protected Forms.Page CreateAndBindPage(Type viewModelType, object parameter) { Type pageType = GetPageTypeForViewModel(viewModelType); if (pageType == null) { throw new Exception($"Mapping type for {viewModelType} is not a page"); } Forms.Page page = Activator.CreateInstance(pageType) as Forms.Page; ViewModelBase viewModel = Locator.Instance.Resolve(viewModelType) as ViewModelBase; page.BindingContext = viewModel; return(page); }
internal void Show(Forms.Page sender, SnackBarOptions arguments) { var snackBarDialog = Forms.Platform.Tizen.Native.Dialog.CreateDialog(Forms.Forms.NativeParent, arguments.Actions.Any()); snackBarDialog.Timeout = arguments.Duration.TotalSeconds; var message = arguments.MessageOptions.Message.Replace("&", "&").Replace("<", "<").Replace(">", ">") .Replace(Environment.NewLine, "<br>"); snackBarDialog.Message = message; foreach (var action in arguments.Actions) { var ok = new EButton(snackBarDialog) { Text = action.Text }; snackBarDialog.NeutralButton = ok; ok.Clicked += async(s, evt) => { snackBarDialog.Dismiss(); if (action.Action != null) { await action.Action(); } arguments.SetResult(true); }; } snackBarDialog.TimedOut += (s, evt) => DismissSnackBar(); snackBarDialog.BackButtonPressed += (s, evt) => DismissSnackBar(); snackBarDialog.Show(); void DismissSnackBar() { snackBarDialog.Dismiss(); arguments.SetResult(false); } }
public void Show(Forms.Page sender, SnackbarArguments arguments) { var snackbarDialog = Forms.Platform.Tizen.Native.Dialog.CreateDialog(Forms.Forms.NativeParent, (arguments.ActionButtonText != null)); snackbarDialog.Timeout = TimeSpan.FromMilliseconds(arguments.Duration).TotalSeconds; var message = arguments.Message.Replace("&", "&").Replace("<", "<").Replace(">", ">") .Replace(Environment.NewLine, "<br>"); snackbarDialog.Message = message; if (!string.IsNullOrEmpty(arguments.ActionButtonText) && arguments.Action != null) { var ok = new EButton(snackbarDialog) { Text = arguments.ActionButtonText }; snackbarDialog.NeutralButton = ok; ok.Clicked += async(s, evt) => { snackbarDialog.Dismiss(); await arguments.Action(); arguments.SetResult(true); }; } snackbarDialog.TimedOut += (s, evt) => { DismissSnackbar(); }; snackbarDialog.BackButtonPressed += (s, evt) => { DismissSnackbar(); }; snackbarDialog.Show(); void DismissSnackbar() { snackbarDialog.Dismiss(); arguments.SetResult(false); } }
public void Show(Forms.Page page, SnackbarArguments arguments) { var pageControl = Platform.GetRenderer(page).ContainerElement.Parent as PageControl; var sender = new ExtendedPageControl(pageControl); snackbarTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(arguments.Duration) }; snackbarTimer.Tick += delegate { sender.HideSnackBar(); snackbarTimer.Stop(); arguments.SetResult(false); }; sender.OnSnackbarActionExecuted += delegate { sender.HideSnackBar(); snackbarTimer.Stop(); arguments.SetResult(true); }; snackbarTimer.Start(); sender.ShowSnackBar(arguments.Message, arguments.ActionButtonText, arguments.Action); }