public void Init() { var syncButton = new ExtendedButton { Text = AppResources.SyncVaultNow, Command = new Command(async() => await SyncAsync()), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; LastSyncLabel = new Label { Style = (Style)Application.Current.Resources["text-muted"], FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalTextAlignment = TextAlignment.Center }; SetLastSync(); var stackLayout = new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Children = { syncButton, LastSyncLabel }, Padding = new Thickness(15, 0) }; if (Device.OS == TargetPlatform.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } Title = AppResources.Sync; Content = stackLayout; }
public void Init() { var syncButton = new ExtendedButton { Text = "Sync Vault Now", Command = new Command(async() => await SyncAsync()), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; LastSyncLabel = new Label { Style = (Style)Application.Current.Resources["text-muted"], FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalTextAlignment = TextAlignment.Center }; SetLastSync(); var stackLayout = new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Children = { syncButton, LastSyncLabel }, Padding = new Thickness(15, 0) }; Title = "Sync"; Content = stackLayout; }
private void Init() { SearchItem = new SearchToolBarItem(this); AddCipherItem = new AddCipherToolBarItem(this, null); ToolbarItems.Add(SearchItem); ToolbarItems.Add(AddCipherItem); ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement) { IsGroupingEnabled = true, ItemsSource = PresentationSections, HasUnevenRows = true, GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell( nameof(Section<Grouping>.Name), nameof(Section<Grouping>.Count), new Thickness(16, 12))), ItemTemplate = new GroupingOrCipherDataTemplateSelector(this) }; if(Device.RuntimePlatform == Device.iOS) { ListView.RowHeight = -1; } var noDataLabel = new Label { Text = AppResources.NoItems, HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; var addCipherButton = new ExtendedButton { Text = AppResources.AddAnItem, Command = new Command(() => Helpers.AddCipher(this, null)), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; NoDataStackLayout = new StackLayout { Children = { noDataLabel, addCipherButton }, VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(20, 0), Spacing = 20 }; LoadingIndicator = new ActivityIndicator { IsRunning = true }; if(Device.RuntimePlatform != Device.UWP) { LoadingIndicator.VerticalOptions = LayoutOptions.CenterAndExpand; LoadingIndicator.HorizontalOptions = LayoutOptions.Center; } Content = LoadingIndicator; Title = AppResources.MyVault; }
public void Init() { MessagingCenter.Send(Application.Current, "ShowStatusBar", false); var logo = new CachedImage { Source = "logo", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, WidthRequest = 282, HeightRequest = 44 }; var message = new Label { Text = AppResources.LoginOrCreateNewAccount, VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), TextColor = Color.FromHex("333333") }; var createAccountButton = new ExtendedButton { Text = AppResources.CreateAccount, Command = new Command(async() => await RegisterAsync()), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"], FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) }; var loginButton = new ExtendedButton { Text = AppResources.LogIn, Command = new Command(async() => await LoginAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], HorizontalOptions = LayoutOptions.Fill, BackgroundColor = Color.Transparent, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) }; var buttonStackLayout = new StackLayout { Padding = new Thickness(30, 40), Spacing = 10, Children = { logo, message, createAccountButton, loginButton } }; Title = AppResources.Bitwarden; NavigationPage.SetHasNavigationBar(this, false); Content = new ScrollView { Content = buttonStackLayout }; }
public RegisterView() { indicator = new ExtendedIndicator { Text = "Creating Your Native iOS App", BackgroundColor = Settings.BackgroundColor, }; BackgroundColor = Settings.BackgroundColor; stackLayout = new StackLayout { Spacing = 10, Padding = new Thickness(20, 20, 20, 20), VerticalOptions = LayoutOptions.Fill, Children = { new ExtendedLabel { Text = "Just One More Step", FontSize = Settings.FontSize.H2, }, } }; email = new ExtendedEntryField { LabelText = "Email", EntryText = "", }; companyname = new ExtendedEntryField { LabelText = "Company Name", EntryText = "", }; email.Entry.PlaceHolder = "*****@*****.**"; companyname.Entry.PlaceHolder = "Your Compnay Name"; ExtendedButton Next = new ExtendedButton { Text = "Next" }; stackLayout.Children.Add(email); stackLayout.Children.Add(companyname); stackLayout.Children.Add(Next); Next.Clicked += OnSaveClicked; this.Content = new StackLayout { Children = { new ScrollView { Content = stackLayout } } }; }
public void ExternalScript_DefaultValue() { // Arrange var testObject = new ExtendedButton(); // Act, Assert AssertNotFX1(string.Empty, testObject.ExternalScript); AssertFX1(ExternalScriptDefault, testObject.ExternalScript); }
private void Init() { var noDataLabel = new Label { Text = string.Format(AppResources.NoItemsForUri, _name ?? "--"), HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; var addCipherButton = new ExtendedButton { Text = AppResources.AddAnItem, Command = new Command(() => AddCipherAsync()), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; NoDataStackLayout = new StackLayout { Children = { noDataLabel, addCipherButton }, VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(20, 0), Spacing = 20 }; AddCipherItem = new AddCipherToolBarItem(this); ToolbarItems.Add(AddCipherItem); SearchItem = new SearchToolBarItem(this); ToolbarItems.Add(SearchItem); ListView = new ListView(ListViewCachingStrategy.RecycleElement) { IsGroupingEnabled = true, ItemsSource = PresentationCiphersGroup, HasUnevenRows = true, GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell( nameof(Section <AutofillCipher> .Name))), ItemTemplate = new DataTemplate(() => new VaultListViewCell( (VaultListPageModel.Cipher c) => Helpers.CipherMoreClickedAsync(this, c, true))) }; if (Device.RuntimePlatform == Device.iOS) { ListView.RowHeight = -1; } Title = string.Format(AppResources.ItemsForUri, _name ?? "--"); LoadingIndicator = new ActivityIndicator { IsRunning = true, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center }; Content = LoadingIndicator; }
private void Init() { var noDataLabel = new Label { Text = string.Format(AppResources.NoLoginsForUri, _name ?? "--"), HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; var addLoginButton = new ExtendedButton { Text = AppResources.AddALogin, Command = new Command(() => AddLoginAsync()), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; NoDataStackLayout = new StackLayout { Children = { noDataLabel, addLoginButton }, VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(20, 0), Spacing = 20 }; ToolbarItems.Add(new AddLoginToolBarItem(this)); ToolbarItems.Add(new SearchToolBarItem(this)); ListView = new ListView(ListViewCachingStrategy.RecycleElement) { IsGroupingEnabled = true, ItemsSource = PresentationLoginsGroup, HasUnevenRows = true, GroupHeaderTemplate = new DataTemplate(() => new HeaderViewCell()), ItemTemplate = new DataTemplate(() => new VaultListViewCell( (VaultListPageModel.Login l) => MoreClickedAsync(l))) }; if (Device.OS == TargetPlatform.iOS) { ListView.RowHeight = -1; } ListView.ItemSelected += LoginSelected; Title = string.Format(AppResources.LoginsForUri, _name ?? "--"); LoadingIndicator = new ActivityIndicator { IsRunning = true, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center }; Content = LoadingIndicator; }
private void UpdateAlignment() { ExtendedButton element = Element as ExtendedButton; if (element == null || Control == null) { return; } Control.Gravity = Android.Views.GravityFlags.Center | Android.Views.GravityFlags.Start; }
public void Init() { var biometricIcon = Helpers.OnPlatform( iOS: _deviceInfoService.HasFaceIdSupport ? "smile.png" : "fingerprint.png", Android: "fingerprint.png", Windows: "smile.png"); var biometricText = Helpers.OnPlatform( iOS: _deviceInfoService.HasFaceIdSupport ? AppResources.UseFaceIDToUnlock : AppResources.UseFingerprintToUnlock, Android: AppResources.UseFingerprintToUnlock, Windows: AppResources.UseWindowsHelloToUnlock); var biometricTitle = Helpers.OnPlatform( iOS: _deviceInfoService.HasFaceIdSupport ? AppResources.VerifyFaceID : AppResources.VerifyFingerprint, Android: AppResources.VerifyFingerprint, Windows: AppResources.VerifyWindowsHello); var fingerprintIcon = new ExtendedButton { Image = biometricIcon, BackgroundColor = Color.Transparent, Command = new Command(async() => await CheckFingerprintAsync()), VerticalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(0, 0, 0, 15) }; var fingerprintButton = new ExtendedButton { Text = biometricText, Command = new Command(async() => await CheckFingerprintAsync()), VerticalOptions = LayoutOptions.EndAndExpand, Style = (Style)Application.Current.Resources["btn-primary"] }; var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async() => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], BackgroundColor = Color.Transparent, Uppercase = false }; var stackLayout = new StackLayout { Padding = new Thickness(30, 40), Spacing = 10, Children = { fingerprintIcon, fingerprintButton, logoutButton } }; Title = biometricTitle; Content = stackLayout; }
public void ExternalScript_SetAndGetValue() { // Arrange var testObject = new ExtendedButton(); // Act testObject.ExternalScript = TestValue; // Assert testObject.ExternalScript.ShouldBe(TestValue); }
public void Init() { var serviceLabel = new Label { Text = AppResources.AutofillDescription, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; var comingSoonLabel = new Label { Text = AppResources.ComingSoon, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), TextColor = Color.Black }; var progressButton = new ExtendedButton { Text = AppResources.SeeDevProgress, Command = new Command(() => { _googleAnalyticsService.TrackAppEvent("SeeAutofillProgress"); Device.OpenUri(new Uri("https://github.com/bitwarden/mobile/issues/1")); }), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"], FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) }; var stackLayout = new StackLayout { Children = { serviceLabel, comingSoonLabel, progressButton }, Orientation = StackOrientation.Vertical, Spacing = 10, Padding = new Thickness(20, 30), VerticalOptions = LayoutOptions.FillAndExpand }; Title = AppResources.AutofillService; Content = new ScrollView { Content = stackLayout }; }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e) { System.Diagnostics.Debug.WriteLine(">>>>>>>>> OnElementChanged: ExtendedButtonButtonRenderer <<<<<<<<"); _element = (ExtendedButton)this.Element; base.OnElementChanged(e); if (e.NewElement != null) { //Subrscribe to the events stuff } else if (e.OldElement != null) { //Unsubscribe from events } }
public void Init() { var instructionLabel = new Label { Text = "Enter your PIN code.", LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalTextAlignment = TextAlignment.Center, Style = (Style)Application.Current.Resources["text-muted"] }; PinControl = new PinControl(); PinControl.OnPinEntered += PinEntered; PinControl.Label.SetBinding <PinPageModel>(Label.TextProperty, s => s.LabelText); PinControl.Entry.SetBinding <PinPageModel>(Entry.TextProperty, s => s.PIN); var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async() => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], BackgroundColor = Color.Transparent, Uppercase = false }; var stackLayout = new StackLayout { Padding = new Thickness(30, 40), Spacing = 20, Children = { PinControl.Label, instructionLabel, logoutButton, PinControl.Entry } }; var tgr = new TapGestureRecognizer(); tgr.Tapped += Tgr_Tapped; PinControl.Label.GestureRecognizers.Add(tgr); instructionLabel.GestureRecognizers.Add(tgr); Title = "Verify PIN"; Content = stackLayout; Content.GestureRecognizers.Add(tgr); BindingContext = Model; }
public AndroidInput(ExtendedButton acceleratorPedal, ExtendedButton left, ExtendedButton right, ExtendedButton brake) { acceleratorPedal.gameObject.SetActive(true); left.gameObject.SetActive(true); right.gameObject.SetActive(true); acceleratorPedal.OnButtonUp += this.OnAcceleratorPedalButtonUp; acceleratorPedal.OnButtonDown += this.OnAcceleratorPedalButtonDown; left.OnButtonDown += this.OnLeftButtonDown; left.OnButtonUp += this.OnLeftButtonUp; right.OnButtonDown += this.OnRightButtonDown; right.OnButtonUp += this.OnRightButtonUp; brake.OnButtonDown += OnBrakeDown; brake.OnButtonUp += OnBrakeUp; this.CurrentMoveDirection = MoveDirection.Idle; this.CurrentSteeringDirection = SteeringDirection.Straight; }
public void PurchaseRocket() { App.NavigationService.Navigate("http://demos.bellatrix.solutions/"); Select sortDropDown = App.ElementCreateService.CreateByNameEndingWith <Select>("orderby"); Anchor protonMReadMoreButton = App.ElementCreateService.CreateByInnerTextContaining <Anchor>("Read more"); Anchor addToCartFalcon9 = App.ElementCreateService.CreateByAttributesContaining <Anchor>("data-product_id", "28").ToBeClickable(); Anchor viewCartButton = App.ElementCreateService.CreateByClassContaining <Anchor>("added_to_cart wc-forward").ToBeClickable(); TextField couponCodeTextField = App.ElementCreateService.CreateById <TextField>("coupon_code"); Button applyCouponButton = App.ElementCreateService.CreateByValueContaining <Button>("Apply coupon"); Number quantityBox = App.ElementCreateService.CreateByClassContaining <Number>("input-text qty text"); Div messageAlert = App.ElementCreateService.CreateByClassContaining <Div>("woocommerce-message"); Button updateCart = App.ElementCreateService.CreateByValueContaining <Button>("Update cart").ToBeClickable(); // 1. Instead of the regular button, we create the ExtendedButton, this way we can use its new methods. ExtendedButton proceedToCheckout = App.ElementCreateService.CreateByClassContaining <ExtendedButton>("checkout-button button alt wc-forward"); Heading billingDetailsHeading = App.ElementCreateService.CreateByInnerTextContaining <Heading>("Billing details"); Span totalSpan = App.ElementCreateService.CreateByXpath <Span>("//*[@class='order-total']//span"); sortDropDown.SelectByText("Sort by price: low to high"); protonMReadMoreButton.Hover(); addToCartFalcon9.Focus(); addToCartFalcon9.Click(); viewCartButton.Click(); couponCodeTextField.SetText("happybirthday"); applyCouponButton.Click(); messageAlert.ToHasContent().ToBeVisible().WaitToBe(); messageAlert.ValidateInnerTextIs("Coupon code applied successfully."); App.BrowserService.WaitForAjax(); quantityBox.SetNumber(2); updateCart.Click(); App.BrowserService.WaitForAjax(); totalSpan.ValidateInnerTextIs("114.00€", 15000); // 2. Use the new custom method provided by the ExtendedButton class. proceedToCheckout.SubmitButtonWithEnter(); billingDetailsHeading.ToBeVisible().WaitToBe(); }
public void Init() { var fingerprintIcon = new ExtendedButton { Image = "fingerprint", BackgroundColor = Color.Transparent, Command = new Command(async() => await CheckFingerprintAsync()), VerticalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(0, 0, 0, 15) }; var fingerprintButton = new ExtendedButton { Text = AppResources.UseFingerprintToUnlock, Command = new Command(async() => await CheckFingerprintAsync()), VerticalOptions = LayoutOptions.EndAndExpand, Style = (Style)Application.Current.Resources["btn-primary"] }; var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async() => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], BackgroundColor = Color.Transparent, Uppercase = false }; var stackLayout = new StackLayout { Padding = new Thickness(30, 40), Spacing = 10, Children = { fingerprintIcon, fingerprintButton, logoutButton } }; Title = AppResources.VerifyFingerprint; Content = stackLayout; }
public AccelerometerInput(ExtendedButton acceleratorPedal, ExtendedButton left, ExtendedButton right, ExtendedButton brake) : base(acceleratorPedal, left, right, brake) { left.gameObject.SetActive(false); right.gameObject.SetActive(false); }
public void Init() { // Not Started var notStartedLabel = new Label { Text = "Get instant access to your passwords!", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; var notStartedSublabel = new Label { Text = "To turn on bitwarden in Safari and other apps, tap the \"more\" icon on the bottom row of the menu.", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; var notStartedImage = new Image { Source = "ext-more", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(0, -10, 0, 0) }; var notStartedButton = new ExtendedButton { Text = "Enable App Extension", Command = new Command(() => ShowExtension("NotStartedEnable")), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"] }; var notStartedStackLayout = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 20, 20, 30), Children = { notStartedLabel, notStartedSublabel, notStartedImage, notStartedButton }, VerticalOptions = LayoutOptions.FillAndExpand }; notStartedStackLayout.SetBinding <AppExtensionPageModel>(IsVisibleProperty, m => m.NotStarted); // Not Activated var notActivatedLabel = new Label { Text = "Almost done!", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; var notActivatedSublabel = new Label { Text = "Tap the bitwarden icon in the menu to launch the extension.", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; var notActivatedImage = new Image { Source = "ext-act", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(0, -10, 0, 0) }; var notActivatedButton = new ExtendedButton { Text = "Enable App Extension", Command = new Command(() => ShowExtension("NotActivatedEnable")), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"] }; var notActivatedStackLayout = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 20, 20, 30), Children = { notActivatedLabel, notActivatedSublabel, notActivatedImage, notActivatedButton }, VerticalOptions = LayoutOptions.FillAndExpand }; notActivatedStackLayout.SetBinding <AppExtensionPageModel>(IsVisibleProperty, m => m.StartedAndNotActivated); // Activated var activatedLabel = new Label { Text = "You're ready to log in!", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; var activatedSublabel = new Label { Text = "In Safari, find bitwarden using the share icon (hint: scroll to the right on the bottom row of the menu).", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, Margin = new Thickness(0, 10, 0, 0) }; var activatedImage = new Image { Source = "ext-use", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(0, -10, 0, 0) }; var activatedButton = new ExtendedButton { Text = "See Supported Apps", Command = new Command(() => { _googleAnalyticsService.TrackAppEvent("SeeSupportedApps"); Device.OpenUri(new Uri("https://bitwarden.com/ios/")); }), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"] }; var activatedButtonReenable = new ExtendedButton { Text = "Re-enable App Extension", Command = new Command(() => ShowExtension("Re-enable")), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; var activatedStackLayout = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 10, Padding = new Thickness(20, 20, 20, 30), VerticalOptions = LayoutOptions.FillAndExpand, Children = { activatedLabel, activatedSublabel, activatedImage, activatedButton, activatedButtonReenable } }; activatedStackLayout.SetBinding <AppExtensionPageModel>(IsVisibleProperty, m => m.StartedAndActivated); var stackLayout = new StackLayout { Children = { notStartedStackLayout, notActivatedStackLayout, activatedStackLayout }, VerticalOptions = LayoutOptions.FillAndExpand }; if (Device.OS == TargetPlatform.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, "Close")); } Title = "App Extension"; Content = new ScrollView { Content = stackLayout }; BindingContext = Model; }
private void Init() { MessagingCenter.Send(Application.Current, "ShowStatusBar", true); var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope", containerPadding: padding); var lastLoginEmail = _settings.GetValueOrDefault(Constants.LastLoginEmail, string.Empty); if (!string.IsNullOrWhiteSpace(_email)) { EmailCell.Entry.Text = _email; } else if (!string.IsNullOrWhiteSpace(lastLoginEmail)) { EmailCell.Entry.Text = lastLoginEmail; } PasswordCell.Entry.ReturnType = Enums.ReturnType.Go; PasswordCell.Entry.Completed += Entry_Completed; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = true, NoFooter = true, VerticalOptions = LayoutOptions.Start, Root = new TableRoot { new TableSection() { EmailCell, PasswordCell } } }; var forgotPasswordButton = new ExtendedButton { Text = AppResources.GetPasswordHint, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 25), Command = new Command(async() => await ForgotPasswordAsync()), Uppercase = false, BackgroundColor = Color.Transparent }; var layout = new StackLayout { Children = { table, forgotPasswordButton }, Spacing = Device.OnPlatform(iOS: 0, Android: 10, WinPhone: 0) }; var scrollView = new ScrollView { Content = layout }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () => { MessagingCenter.Send(Application.Current, "ShowStatusBar", false); })); } var loginToolbarItem = new ToolbarItem(AppResources.LogIn, null, async() => { await LogIn(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(loginToolbarItem); Title = AppResources.Bitwarden; Content = scrollView; NavigationPage.SetBackButtonTitle(this, AppResources.LogIn); }
private void Init() { SubscribeYubiKey(true); if (_providers.Count > 1) { var sendEmailTask = SendEmailAsync(false); } ToolbarItems.Clear(); var scrollView = new ScrollView(); var anotherMethodButton = new ExtendedButton { Text = AppResources.UseAnotherTwoStepMethod, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 25), Command = new Command(() => AnotherMethodAsync()), Uppercase = false, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start }; var instruction = new Label { LineBreakMode = LineBreakMode.WordWrap, Margin = new Thickness(15), HorizontalTextAlignment = TextAlignment.Center }; RememberCell = new ExtendedSwitchCell { Text = AppResources.RememberMe, On = false }; if (!_providerType.HasValue) { instruction.Text = AppResources.NoTwoStepAvailable; var layout = new StackLayout { Children = { instruction, anotherMethodButton }, Spacing = 0 }; scrollView.Content = layout; Title = AppResources.LoginUnavailable; Content = scrollView; } else if (_providerType.Value == TwoFactorProviderType.Authenticator || _providerType.Value == TwoFactorProviderType.Email) { var continueToolbarItem = new ToolbarItem(AppResources.Continue, Helpers.ToolbarImage("login.png"), async() => { var token = TokenCell?.Entry.Text.Trim().Replace(" ", ""); await LogInAsync(token); }, ToolbarItemOrder.Default, 0); var padding = Helpers.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), Windows: new Thickness(10, 8)); TokenCell = new FormEntryCell(AppResources.VerificationCode, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); TokenCell.Entry.Keyboard = Keyboard.Numeric; TokenCell.Entry.ReturnType = ReturnType.Go; var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { TokenCell, RememberCell }); var layout = new RedrawableStackLayout { Children = { instruction, table }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; switch (_providerType.Value) { case TwoFactorProviderType.Authenticator: instruction.Text = AppResources.EnterVerificationCodeApp; layout.Children.Add(anotherMethodButton); break; case TwoFactorProviderType.Email: var emailParams = _providers[TwoFactorProviderType.Email]; var redactedEmail = emailParams["Email"].ToString(); instruction.Text = string.Format(AppResources.EnterVerificationCodeEmail, redactedEmail); var resendEmailButton = new ExtendedButton { Text = AppResources.SendVerificationCodeAgain, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 0), Command = new Command(async() => await SendEmailAsync(true)), Uppercase = false, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start }; layout.Children.Add(resendEmailButton); layout.Children.Add(anotherMethodButton); break; default: break; } ToolbarItems.Add(continueToolbarItem); Title = AppResources.VerificationCode; Content = scrollView; TokenCell.Entry.FocusWithDelay(); } else if (_providerType == TwoFactorProviderType.Duo) { var duoParams = _providers[TwoFactorProviderType.Duo]; var host = WebUtility.UrlEncode(duoParams["Host"].ToString()); var req = WebUtility.UrlEncode(duoParams["Signature"].ToString()); var webVaultUrl = "https://vault.bitwarden.com"; if (!string.IsNullOrWhiteSpace(_appSettingsService.BaseUrl)) { webVaultUrl = _appSettingsService.BaseUrl; } else if (!string.IsNullOrWhiteSpace(_appSettingsService.WebVaultUrl)) { webVaultUrl = _appSettingsService.WebVaultUrl; } var webView = new HybridWebView { Uri = $"{webVaultUrl}/duo-connector.html?host={host}&request={req}", HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, MinimumHeightRequest = 400 }; webView.RegisterAction(async(sig) => { await LogInAsync(sig); }); var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { RememberCell }); var layout = new RedrawableStackLayout { Children = { webView, table, anotherMethodButton }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; Title = "Duo"; Content = scrollView; } else if (_providerType == TwoFactorProviderType.YubiKey) { instruction.Text = AppResources.YubiKeyInstruction; var image = new CachedImage { Source = "yubikey", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, WidthRequest = 266, HeightRequest = 160, Margin = new Thickness(0, 0, 0, 25) }; var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { RememberCell }); var layout = new RedrawableStackLayout { Children = { instruction, image, table, anotherMethodButton }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; Title = AppResources.YubiKeyTitle; Content = scrollView; } }
private void Init() { MessagingCenter.Subscribe <Application, bool>(Application.Current, "SyncCompleted", (sender, success) => { if (success) { _filterResultsCancellationTokenSource = FetchAndLoadVault(); } }); if (!_favorites) { ToolbarItems.Add(new AddSiteToolBarItem(this)); } ListView = new ListView(ListViewCachingStrategy.RecycleElement) { IsGroupingEnabled = true, ItemsSource = PresentationFolders, HasUnevenRows = true, GroupHeaderTemplate = new DataTemplate(() => new VaultListHeaderViewCell(this)), ItemTemplate = new DataTemplate(() => new VaultListViewCell(this)) }; if (Device.OS == TargetPlatform.iOS) { ListView.RowHeight = -1; } ListView.ItemSelected += SiteSelected; Search = new SearchBar { Placeholder = AppResources.SearchVault, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Button)), CancelButtonColor = Color.FromHex("3c8dbc") }; Search.TextChanged += SearchBar_TextChanged; Search.SearchButtonPressed += SearchBar_SearchButtonPressed; // Bug with searchbar on android 7, ref https://bugzilla.xamarin.com/show_bug.cgi?id=43975 if (Device.OS == TargetPlatform.Android && _deviceInfoService.Version >= 24) { Search.HeightRequest = 50; } Title = _favorites ? AppResources.Favorites : AppResources.MyVault; ResultsStackLayout = new StackLayout { Children = { Search, ListView }, Spacing = 0 }; var noDataLabel = new Label { Text = _favorites ? AppResources.NoFavorites : AppResources.NoSites, HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; NoDataStackLayout = new StackLayout { Children = { noDataLabel }, VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(20, 0), Spacing = 20 }; if (!_favorites) { var addSiteButton = new ExtendedButton { Text = AppResources.AddASite, Command = new Command(() => AddSite()), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; NoDataStackLayout.Children.Add(addSiteButton); } LoadingIndicator = new ActivityIndicator { IsRunning = true, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center }; Content = LoadingIndicator; }
private void Init() { var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); CodeCell = new FormEntryCell(AppResources.VerificationCode, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); CodeCell.Entry.Keyboard = Keyboard.Numeric; CodeCell.Entry.ReturnType = Enums.ReturnType.Go; CodeCell.Entry.Completed += Entry_Completed; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = true, NoFooter = true, VerticalOptions = LayoutOptions.Start, Root = new TableRoot { new TableSection() { CodeCell } } }; var codeLabel = new Label { Text = AppResources.EnterVerificationCode, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var lostAppButton = new ExtendedButton { Text = AppResources.Lost2FAApp, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 25), Command = new Command(() => Lost2FAApp()), Uppercase = false, BackgroundColor = Color.Transparent }; var layout = new StackLayout { Children = { table, codeLabel, lostAppButton }, Spacing = 0 }; var scrollView = new ScrollView { Content = layout }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var continueToolbarItem = new ToolbarItem(AppResources.Continue, null, async() => { await LogIn(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(continueToolbarItem); Title = AppResources.VerificationCode; Content = scrollView; }
public void Init() { var padding = Helpers.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), Windows: new Thickness(10, 8)); PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true, useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding); PasswordCell.Entry.TargetReturnType = Enums.ReturnType.Go; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = false, VerticalOptions = LayoutOptions.Start, NoFooter = true, Root = new TableRoot { new TableSection(Helpers.GetEmptyTableSectionTitle()) { PasswordCell } } }; var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async() => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], BackgroundColor = Color.Transparent, Uppercase = false }; var stackLayout = new RedrawableStackLayout { Spacing = 10, Children = { table, logoutButton } }; table.WrappingStackLayout = () => stackLayout; var scrollView = new ScrollView { Content = stackLayout }; if (Device.RuntimePlatform == Device.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var loginToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() => { await CheckPasswordAsync(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(loginToolbarItem); Title = AppResources.VerifyMasterPassword; Content = scrollView; }
public void Init() { var enabledFs = new FormattedString(); var statusSpan = new Span { Text = string.Concat(AppResources.Status, " ") }; enabledFs.Spans.Add(statusSpan); enabledFs.Spans.Add(new Span { Text = AppResources.Enabled, ForegroundColor = Color.Green, FontAttributes = FontAttributes.Bold, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }); var statusEnabledLabel = new Label { FormattedText = enabledFs, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), TextColor = Color.Black, VerticalOptions = LayoutOptions.CenterAndExpand }; var disabledFs = new FormattedString(); disabledFs.Spans.Add(statusSpan); disabledFs.Spans.Add(new Span { Text = AppResources.Disabled, ForegroundColor = Color.FromHex("c62929"), FontAttributes = FontAttributes.Bold, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }); var statusDisabledLabel = new Label { FormattedText = disabledFs, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), TextColor = Color.Black }; var enableImage = new CachedImage { Source = "autofill_enable.png", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 300, HeightRequest = 118 }; var useImage = new CachedImage { Source = "autofill_use.png", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 300, HeightRequest = 128 }; var goButton = new ExtendedButton { Text = AppResources.BitwardenAutofillServiceOpenAutofillSettings, Command = new Command(() => { _googleAnalyticsService.TrackAppEvent("OpenAutofillSettings"); _deviceActionService.OpenAutofillSettings(); }), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"] }; DisabledStackLayout = new StackLayout { Children = { BuildServiceLabel(), statusDisabledLabel, enableImage, goButton, BuildAccessibilityButton() }, Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 30), VerticalOptions = LayoutOptions.FillAndExpand }; EnabledStackLayout = new StackLayout { Children = { BuildServiceLabel(), statusEnabledLabel, useImage, BuildAccessibilityButton() }, Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 30), VerticalOptions = LayoutOptions.FillAndExpand }; ScrollView = new ScrollView { Content = DisabledStackLayout }; Title = AppResources.AutofillService; Content = ScrollView; }
/// <summary> /// Initializes a new instance of the <see cref="SelectMultipleBasePage{T}"/> class. /// </summary> /// <param name="items">The items<see cref="IEnumerable{T}"/></param> /// <param name="finish">The finish<see cref="Command"/></param> public SelectMultipleBasePage(IEnumerable <T> items, Command finish = null) { var cmFinish = finish; _wrappedItems = items.Select(item => new WrappedSelection <T>() { Item = item }).ToList(); Style = (Style)Application.Current.Resources["ContentPageType"]; if (App.AppSettings.DarkTheme) { BackgroundColor = Color.FromHex("#263238"); } var ly = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(10) }; switch (Device.Idiom) { case TargetIdiom.Tablet: ly.Padding = new Thickness(150, 30, 150, 30); break; case TargetIdiom.Desktop: ly.Padding = new Thickness(150, 30, 150, 30); break; default: ly.Padding = new Thickness(20, 20, 20, 20); break; } if (App.AppSettings.DarkTheme) { ly.BackgroundColor = Color.FromHex("#263238"); } var mainList = new ListView() { ItemsSource = _wrappedItems, ItemTemplate = new DataTemplate(typeof(WrappedItemSelectionTemplate)), SeparatorVisibility = SeparatorVisibility.None }; if (App.AppSettings.DarkTheme) { mainList.BackgroundColor = Color.FromHex("#263238"); } mainList.ItemSelected += (sender, e) => { if (e.SelectedItem == null) { return; } var o = (WrappedSelection <T>)e.SelectedItem; o.IsSelected = !o.IsSelected; ((ListView)sender).SelectedItem = null; //de-select }; var oSave = new ExtendedButton { Text = AppResources.ok, HorizontalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(10) }; oSave.Padding = new Thickness(20, 0, 20, 0); oSave.Clicked += (o, e) => { cmFinish?.Execute(null); Navigation.PopAsync(); }; ly.Children.Add(mainList); ly.Children.Add(oSave); Content = ly; mainList.RowHeight = 60; ToolbarItems.Add(new ToolbarItem(AppResources.filterOn_all, null, SelectAll, ToolbarItemOrder.Primary)); }
private void Init(VaultViewCipherPage page, VaultViewCipherPageModel.Field field, ExtendedButton copyButton) { Value.LineBreakMode = LineBreakMode.WordWrap; if (copyButton != null) { copyButton.Command = new Command(() => page.Copy(field.Value, field.Name)); } }
public void Init() { var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); PasswordCell.Entry.ReturnType = Enums.ReturnType.Go; PasswordCell.Entry.Completed += Entry_Completed; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = false, VerticalOptions = LayoutOptions.Start, NoFooter = true, Root = new TableRoot { new TableSection { PasswordCell } } }; var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async() => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], BackgroundColor = Color.Transparent, Uppercase = false }; var stackLayout = new StackLayout { Spacing = 10, Children = { table, logoutButton } }; var scrollView = new ScrollView { Content = stackLayout }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var loginToolbarItem = new ToolbarItem("Submit", null, async() => { await CheckPasswordAsync(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(loginToolbarItem); Title = "Verify Master Password"; Content = scrollView; }
/// <summary> /// Handles the collection changed. /// </summary> /// <remarks> /// The bottom could only have one sort of buttons: text or icons. /// If there are more buttons with text than the bottom could hold, than the overflow menu is shown. /// </remarks> /// <param name="sender">Sender of event.</param> /// <param name="e">Collection changed event arguments.</param> private void HandleCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { BottomLayout.Children.Clear(); var textLayout = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Fill, }; foreach (ToolButton t in buttons) { if (t is ToolTextButton) { var button = new ExtendedButton() { Text = (t is ToolTextButton) ? ((ToolTextButton)t).Text : null, TextColor = App.Colors.Tint, Image = null, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, Command = new Command((parameter) => KeyClick(t.Command, parameter)), CommandParameter = (t is ToolTextButton) ? ((ToolTextButton)t).Text : null, #if __IOS__ Font = Font.SystemFontOfSize(20), #endif IsVisible = t.IsVisibleAtStartup, }; // Save for later use t.Button = button; // If only one text button, than add to stack layout if (buttons.Count <= 1) { BottomLayout.Children.Add(button); } else { textLayout.Children.Add(button); } } if (t is ToolIconButton) { var button = new ExtendedButton() { Text = (t is ToolTextButton) ? ((ToolTextButton)t).Text : null, TextColor = App.Colors.Tint, Image = (t is ToolIconButton) ? ((ToolIconButton)t).Icon : null, HorizontalOptions = Device.OnPlatform<LayoutOptions>(LayoutOptions.FillAndExpand, LayoutOptions.CenterAndExpand, LayoutOptions.FillAndExpand), BackgroundColor = Color.Transparent, Command = new Command((parameter) => KeyClick(t.Command, parameter)), CommandParameter = (t is ToolIconButton) ? ((ToolIconButton)t).Icon : null, IsVisible = t.IsVisibleAtStartup, }; // Save for later use t.Button = button; BottomLayout.Children.Add(button); } } if (buttons.Count == 0 || buttons[0] is ToolIconButton) { // If the first button is an icon, than we are ready return; } Thickness padding = new Thickness(10, 0); double spacing = 6; // Get max size of bottom var maxWidth = (BottomLayout.Width == -1 ? DependencyService.Get<IScreen>().Width : BottomLayout.Width) - padding.Left - padding.Right; if (buttons.Count == 1) { // We only have one button, so set width to maximum width BottomLayout.Padding = padding; buttons[0].Button.WidthRequest = BottomLayout.Width - padding.Left - padding.Right; if (((ToolTextButton)buttons[0]).TextWidth > maxWidth) { // Text is wider than maxWidth, so scale font var fontSize = ((ToolTextButton)buttons[0]).Button.FontSize * maxWidth / ((ToolTextButton)buttons[0]).TextWidth - 1; ((ToolTextButton)buttons[0]).Button.FontSize = fontSize > 14 ? fontSize : 14; } return; } // So, now we know, that we have more than one text button. // Check, if all buttons fit into the bottom grid. double sumWidth = 0; // Get width of all buttons for (int i = 0; i < buttons.Count; i++) { sumWidth += ((ToolTextButton)buttons[i]).TextWidth; } // Add spacing between sumWidth += spacing * (buttons.Count - 1); // Now check, if all buttons want fit into the bottom line if (sumWidth > maxWidth) { // No. There are more buttons than space, so create an extra menu // Create button for extra menu var button = new ExtendedButton() { Text = OverflowMenuText, TextColor = App.Colors.Tint, Image = null, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, Command = new Command(HandleOverflowMenuClick), #if __IOS__ Font = Font.SystemFontOfSize(20), #endif }; BottomLayout.Children.Add(button); } else { // Yes. All buttons should fit into the bottom line. // Create grid for buttons Grid grid = new Grid() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, }, ColumnSpacing = 0, //spacing, }; // Create columns for buttons var colDefs = new ColumnDefinitionCollection(); colDefs.Add(new ColumnDefinition { Width = new GridLength(((ToolTextButton)buttons[0]).TextWidth, GridUnitType.Absolute) }); // Set layout of first button buttons[0].Button.HorizontalOptions = LayoutOptions.StartAndExpand; // Set width (autosize) and layout of all buttons between first and last for (int i = 1; i < buttons.Count - 1; i++) { colDefs.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); //((ToolTextButton)buttons[i]).TextWidth + padding.Left + padding.Right, GridUnitType.Absolute) }); buttons[i].Button.HorizontalOptions = LayoutOptions.CenterAndExpand; } if (buttons.Count == 2) { // If we only have two buttons, than add an empty col with autosize width colDefs.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); // Width = GridLength.Auto }); // colDefs.Add(new ColumnDefinition { Width = new GridLength(((ToolTextButton)buttons[buttons.Count-1]).TextWidth, GridUnitType.Absolute) }); // Width = GridLength.Auto }); // buttons[buttons.Count-1].Button.HorizontalOptions = LayoutOptions.EndAndExpand; } else { // If we have more than 2 buttons, than set width to real size of button colDefs.Add(new ColumnDefinition { Width = new GridLength(((ToolTextButton)buttons[buttons.Count-1]).TextWidth, GridUnitType.Absolute) }); // Width = GridLength.Auto }); // buttons[buttons.Count-1].Button.HorizontalOptions = LayoutOptions.EndAndExpand; } // Set column definitions for the buttons grid.ColumnDefinitions = colDefs; // Add all buttons to the grid var index = 0; for (int i = 0; i < buttons.Count; i++) { if (buttons.Count == 2 && i == 1) { // Add empty col index++; } // grid.Children.Add(new BoxView() { BackgroundColor = Color.FromRgb(i * 64, i * 64, i * 64), }, i + index, 0); grid.Children.Add(buttons[i].Button, i + index, 0); } // Add grid to BottomLayout BottomLayout.Padding = padding; BottomLayout.Children.Add(grid); } }
private void Init() { _canUseAttachments = _cryptoService.EncKey != null; SubscribeFileResult(true); var selectButton = new ExtendedButton { Text = AppResources.ChooseFile, Command = new Command(async() => await _deviceActionService.SelectFileAsync()), Style = (Style)Application.Current.Resources["btn-primaryAccent"], FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) }; FileLabel = new Label { Text = AppResources.NoFileChosen, Style = (Style)Application.Current.Resources["text-muted"], FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalTextAlignment = TextAlignment.Center }; AddNewStackLayout = new StackLayout { Children = { selectButton, FileLabel }, Orientation = StackOrientation.Vertical, Padding = new Thickness(20, Helpers.OnPlatform(iOS: 10, Android: 20), 20, 20), VerticalOptions = LayoutOptions.Start }; NewTable = new ExtendedTableView { Intent = TableIntent.Settings, HasUnevenRows = true, NoFooter = true, EnableScrolling = false, EnableSelection = false, VerticalOptions = LayoutOptions.Start, Margin = new Thickness(0, Helpers.OnPlatform(iOS: 10, Android: 30), 0, 0), WrappingStackLayout = () => NoDataStackLayout, Root = new TableRoot { new TableSection(AppResources.AddNewAttachment) { new ExtendedViewCell { View = AddNewStackLayout, BackgroundColor = Color.White } } } }; ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement) { ItemsSource = PresentationAttchments, HasUnevenRows = true, ItemTemplate = new DataTemplate(() => new VaultAttachmentsViewCell()), VerticalOptions = LayoutOptions.FillAndExpand }; NoDataLabel = new Label { Text = AppResources.NoAttachments, HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; NoDataStackLayout = new RedrawableStackLayout { VerticalOptions = LayoutOptions.Start, Spacing = 0, Margin = new Thickness(0, 40, 0, 0) }; SaveToolbarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async() => { if (_lastAction.LastActionWasRecent() || _cipher == null) { return; } _lastAction = DateTime.UtcNow; if (!_canUseAttachments) { await ShowUpdateKeyAsync(); return; } if (!_connectivity.IsConnected) { AlertNoConnection(); return; } if (_fileBytes == null) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.File), AppResources.Ok); return; } await _deviceActionService.ShowLoadingAsync(AppResources.Saving); var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text); await _deviceActionService.HideLoadingAsync(); if (saveTask.Succeeded) { _fileBytes = null; FileLabel.Text = AppResources.NoFileChosen; _deviceActionService.Toast(AppResources.AttachementAdded); _googleAnalyticsService.TrackAppEvent("AddedAttachment"); await LoadAttachmentsAsync(); } else if (saveTask.Errors.Count() > 0) { await DisplayAlert(AppResources.AnErrorHasOccurred, saveTask.Errors.First().Message, AppResources.Ok); } else { await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); Title = AppResources.Attachments; Content = ListView; if (Device.RuntimePlatform == Device.iOS) { ListView.RowHeight = -1; NewTable.RowHeight = -1; NewTable.EstimatedRowHeight = 44; NewTable.HeightRequest = 180; ListView.BackgroundColor = Color.Transparent; ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); } else if (Device.RuntimePlatform == Device.Android) { ListView.BottomPadding = 50; } }
public void Init() { // Not Started var notStartedLabel = new Label { Text = AppResources.ExtensionInstantAccess, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; var notStartedSublabel = new Label { Text = AppResources.ExtensionTurnOn, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; var notStartedImage = new CachedImage { Source = "ext-more", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(0, -10, 0, 0), WidthRequest = 290, HeightRequest = 252 }; var notStartedButton = new ExtendedButton { Text = AppResources.ExtensionEnable, Command = new Command(() => ShowExtension("NotStartedEnable")), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"] }; var notStartedStackLayout = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 20, 20, 30), Children = { notStartedLabel, notStartedSublabel, notStartedImage, notStartedButton }, VerticalOptions = LayoutOptions.FillAndExpand }; notStartedStackLayout.SetBinding(IsVisibleProperty, nameof(AppExtensionPageModel.NotStarted)); // Not Activated var notActivatedLabel = new Label { Text = AppResources.ExtensionAlmostDone, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; var notActivatedSublabel = new Label { Text = AppResources.ExtensionTapIcon, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; var notActivatedImage = new CachedImage { Source = "ext-act", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(0, -10, 0, 0), WidthRequest = 290, HeightRequest = 252 }; var notActivatedButton = new ExtendedButton { Text = AppResources.ExtensionEnable, Command = new Command(() => ShowExtension("NotActivatedEnable")), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"] }; var notActivatedStackLayout = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 20, 20, 30), Children = { notActivatedLabel, notActivatedSublabel, notActivatedImage, notActivatedButton }, VerticalOptions = LayoutOptions.FillAndExpand }; notActivatedStackLayout.SetBinding(IsVisibleProperty, nameof(AppExtensionPageModel.StartedAndNotActivated)); // Activated var activatedLabel = new Label { Text = AppResources.ExtensionReady, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; var activatedSublabel = new Label { Text = AppResources.ExtensionInSafari, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, Margin = new Thickness(0, 10, 0, 0) }; var activatedImage = new CachedImage { Source = "ext-use", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(0, -10, 0, 0), WidthRequest = 290, HeightRequest = 252 }; var activatedButton = new ExtendedButton { Text = AppResources.ExtensionSeeApps, Command = new Command(() => { _googleAnalyticsService.TrackAppEvent("SeeSupportedApps"); Device.OpenUri(new Uri("https://bitwarden.com/ios/")); }), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primary"] }; var activatedButtonReenable = new ExtendedButton { Text = AppResources.ExntesionReenable, Command = new Command(() => ShowExtension("Re-enable")), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; var activatedStackLayout = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 10, Padding = new Thickness(20, 20, 20, 30), VerticalOptions = LayoutOptions.FillAndExpand, Children = { activatedLabel, activatedSublabel, activatedImage, activatedButton, activatedButtonReenable } }; activatedStackLayout.SetBinding(IsVisibleProperty, nameof(AppExtensionPageModel.StartedAndActivated)); var stackLayout = new StackLayout { Children = { notStartedStackLayout, notActivatedStackLayout, activatedStackLayout }, VerticalOptions = LayoutOptions.FillAndExpand }; if (Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); } Title = AppResources.AppExtension; Content = new ScrollView { Content = stackLayout }; BindingContext = Model; }