Ejemplo n.º 1
0
        public MainPage(string uri = null, bool myVault = false)
        {
            TintColor = Color.FromHex("3c8dbc");

            var settingsNavigation  = new ExtendedNavigationPage(new SettingsPage());
            var favoritesNavigation = new ExtendedNavigationPage(new VaultListLoginsPage(true, uri));
            var vaultNavigation     = new ExtendedNavigationPage(new VaultListLoginsPage(false, uri));
            var toolsNavigation     = new ExtendedNavigationPage(new ToolsPage());

            favoritesNavigation.Title = AppResources.Favorites;
            favoritesNavigation.Icon  = "star.png";

            vaultNavigation.Title = AppResources.MyVault;
            vaultNavigation.Icon  = "fa_lock.png";

            toolsNavigation.Title = AppResources.Tools;
            toolsNavigation.Icon  = "tools.png";

            settingsNavigation.Title = AppResources.Settings;
            settingsNavigation.Icon  = "cogs.png";

            Children.Add(favoritesNavigation);
            Children.Add(vaultNavigation);
            Children.Add(toolsNavigation);
            Children.Add(settingsNavigation);

            if (myVault || uri != null)
            {
                SelectedItem = vaultNavigation;
            }
        }
Ejemplo n.º 2
0
        public MainPage()
        {
            TintColor = Color.FromHex("3c8dbc");

            var settingsNavigation  = new ExtendedNavigationPage(new SettingsPage());
            var favoritesNavigation = new ExtendedNavigationPage(new VaultListLoginsPage(true));
            var vaultNavigation     = new ExtendedNavigationPage(new VaultListLoginsPage(false));
            var toolsNavigation     = new ExtendedNavigationPage(new ToolsPage());

            favoritesNavigation.Title = AppResources.Favorites;
            favoritesNavigation.Icon  = "star";

            vaultNavigation.Title = AppResources.MyVault;
            vaultNavigation.Icon  = "fa_lock";

            toolsNavigation.Title = AppResources.Tools;
            toolsNavigation.Icon  = "tools";

            settingsNavigation.Title = AppResources.Settings;
            settingsNavigation.Icon  = "cogs";

            Children.Add(favoritesNavigation);
            Children.Add(vaultNavigation);
            Children.Add(toolsNavigation);
            Children.Add(settingsNavigation);
        }
Ejemplo n.º 3
0
        public App(
            string uri,
            IAuthService authService,
            IConnectivity connectivity,
            IUserDialogs userDialogs,
            IDatabaseService databaseService,
            ISyncService syncService,
            IFingerprint fingerprint,
            ISettings settings,
            ILockService lockService,
            IGoogleAnalyticsService googleAnalyticsService,
            ILocalizeService localizeService,
            IAppInfoService appInfoService)
        {
            _uri                    = uri;
            _databaseService        = databaseService;
            _connectivity           = connectivity;
            _userDialogs            = userDialogs;
            _syncService            = syncService;
            _authService            = authService;
            _fingerprint            = fingerprint;
            _settings               = settings;
            _lockService            = lockService;
            _googleAnalyticsService = googleAnalyticsService;
            _localizeService        = localizeService;
            _appInfoService         = appInfoService;

            SetCulture();
            SetStyles();

            if (authService.IsAuthenticated && _uri != null)
            {
                MainPage = new ExtendedNavigationPage(new VaultAutofillListLoginsPage(_uri));
            }
            else if (authService.IsAuthenticated)
            {
                MainPage = new MainPage();
            }
            else
            {
                MainPage = new ExtendedNavigationPage(new HomePage());
            }

            MessagingCenter.Subscribe <Application, bool>(Current, "Resumed", async(sender, args) =>
            {
                Device.BeginInvokeOnMainThread(async() => await CheckLockAsync(args));
                await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
            });

            MessagingCenter.Subscribe <Application, bool>(Current, "Lock", (sender, args) =>
            {
                Device.BeginInvokeOnMainThread(async() => await CheckLockAsync(args));
            });

            MessagingCenter.Subscribe <Application, string>(Current, "Logout", (sender, args) =>
            {
                Logout(args);
            });
        }
Ejemplo n.º 4
0
        public App(
            AppOptions options,
            IAuthService authService,
            IConnectivity connectivity,
            IDatabaseService databaseService,
            ISyncService syncService,
            ISettings settings,
            ILockService lockService,
            ILocalizeService localizeService,
            IAppInfoService appInfoService,
            IAppSettingsService appSettingsService,
            IDeviceActionService deviceActionService)
        {
            _options             = options ?? new AppOptions();
            _authService         = authService;
            _databaseService     = databaseService;
            _connectivity        = connectivity;
            _syncService         = syncService;
            _settings            = settings;
            _lockService         = lockService;
            _localizeService     = localizeService;
            _appInfoService      = appInfoService;
            _appSettingsService  = appSettingsService;
            _deviceActionService = deviceActionService;

            SetCulture();
            SetStyles();

            if (authService.IsAuthenticated)
            {
                if (_options.FromAutofillFramework && _options.SaveType.HasValue)
                {
                    MainPage = new ExtendedNavigationPage(new VaultAddCipherPage(_options));
                }
                else if (_options.Uri != null)
                {
                    MainPage = new ExtendedNavigationPage(new VaultAutofillListCiphersPage(_options));
                }
                else
                {
                    MainPage = new MainPage();
                }
            }
            else
            {
                MainPage = new ExtendedNavigationPage(new HomePage());
            }

            if (Device.RuntimePlatform == Device.iOS)
            {
                MessagingCenter.Subscribe <Application, bool>(Current, "Resumed", async(sender, args) =>
                {
                    Device.BeginInvokeOnMainThread(async() => await _lockService.CheckLockAsync(args));
                    await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
                });
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            SetupNavBar(NavigationController.NavigationBar.Bounds.Size);
            SetTitlePosition(ExtendedNavigationPage.GetTitlePosition(Element), ExtendedNavigationPage.GetTitlePadding(Element), ExtendedNavigationPage.GetTitleMargin(Element), new CGRect(0, 0, Math.Max(subtitleLabel.IntrinsicContentSize.Width, titleLabel.IntrinsicContentSize.Width), (titleLabel.IntrinsicContentSize.Height + subtitleLabel.IntrinsicContentSize.Height + (subtitleLabel.IntrinsicContentSize.Height > 0.0f ? 3.0f : 0.0f))));

            System.Diagnostics.Debug.WriteLine("Preparing");
        }
        public async Task NavigateModalAsync(PageEnum pageKey, object parameter, bool animated = true)
        {
            var page = GetPage(pageKey, parameter);

            ExtendedNavigationPage.SetHasNavigationBar(page, false);

            var modalNavigationPage = new ExtendedNavigationPage(page);

            await CurrentNavigationPage.Navigation.PushModalAsync(modalNavigationPage, animated);

            _navigationPageStack.Push(modalNavigationPage);
        }
        public Page SetRootPage(PageEnum rootPageKey)
        {
            var rootPage = GetPage(rootPageKey);

            _navigationPageStack.Clear();

            var mainPage = new ExtendedNavigationPage(rootPage);

            _navigationPageStack.Push(mainPage);

            return(mainPage);
        }
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            if (lastNavBarWidth != NavigationController?.NavigationBar?.Bounds.Size.Width || lastNavBarHeight != NavigationController?.NavigationBar?.Bounds.Size.Height)
            {
                lastNavBarHeight = NavigationController?.NavigationBar?.Bounds.Size.Height ?? 0.0f;
                lastNavBarWidth  = NavigationController?.NavigationBar?.Bounds.Size.Width ?? 0.0f;
                SetupNavBar(new CGSize(lastNavBarWidth, lastNavBarHeight));
            }

            SetTitlePosition(ExtendedNavigationPage.GetTitlePosition(Element), ExtendedNavigationPage.GetTitlePadding(Element), ExtendedNavigationPage.GetTitleMargin(Element), new CGRect(0, 0, Math.Max(subtitleLabel.IntrinsicContentSize.Width, titleLabel.IntrinsicContentSize.Width), (titleLabel.IntrinsicContentSize.Height + subtitleLabel.IntrinsicContentSize.Height + (subtitleLabel.IntrinsicContentSize.Height > 0.0f ? 3.0f : 0.0f))));

            System.Diagnostics.Debug.WriteLine("didSubViews");
        }
 private void SetupBackground()
 {
     if (string.IsNullOrEmpty(ExtendedNavigationPage.GetBarBackground(Element)) && ExtendedNavigationPage.GetGradientColors(Element) == null)
     {
         SetupBackground(null, ExtendedNavigationPage.GetBarBackgroundOpacity(Element));
     }
     else
     {
         if (!string.IsNullOrEmpty(ExtendedNavigationPage.GetBarBackground(Element)))
         {
             SetupBackground(UIImage.FromBundle(ExtendedNavigationPage.GetBarBackground(Element)), ExtendedNavigationPage.GetBarBackgroundOpacity(Element));
         }
         else if (ExtendedNavigationPage.GetGradientColors(Element) != null)
         {
             SetupBackground(CreateGradientBackground(ExtendedNavigationPage.GetGradientColors(Element).Item1, ExtendedNavigationPage.GetGradientColors(Element).Item2, ExtendedNavigationPage.GetGradientDirection(Element)), ExtendedNavigationPage.GetBarBackgroundOpacity(Element));
         }
     }
 }
Ejemplo n.º 10
0
        public MainPage()
        {
            TintColor = Color.FromHex("3c8dbc");

            _vaultPage = new ExtendedNavigationPage(new VaultListGroupingsPage());
            var passwordGeneratorNavigation = new ExtendedNavigationPage(new ToolsPasswordGeneratorPage(this));
            var toolsNavigation             = new ExtendedNavigationPage(new ToolsPage(this));
            var settingsNavigation          = new ExtendedNavigationPage(new SettingsPage(this));

            _vaultPage.Icon = "fa_lock.png";
            passwordGeneratorNavigation.Icon = "refresh.png";
            toolsNavigation.Icon             = "tools.png";
            settingsNavigation.Icon          = "cogs.png";

            Children.Add(_vaultPage);
            Children.Add(passwordGeneratorNavigation);
            Children.Add(toolsNavigation);
            Children.Add(settingsNavigation);
        }
        private void SetupNavBar(CGSize size)
        {
            if (NavigationController != null && titleView != null)
            {
                var page = Element as Page;
                containerView.Frame = new CGRect(0, 0, size.Width, size.Height);


                titleView.Layer.BorderWidth = ExtendedNavigationPage.GetTitleBorderWidth(Element);

                titleView.Layer.CornerRadius = ExtendedNavigationPage.GetTitleBorderCornerRadius(Element);

                titleView.Layer.BorderColor = ExtendedNavigationPage.GetTitleBorderColor(Element)?.ToCGColor() ?? UIColor.Clear.CGColor;


                SetupTextFont(titleLabel, ExtendedNavigationPage.GetTitleFont(page), ExtendedNavigationPage.GetTitleColor(page));

                SetupBackground();

                if (!string.IsNullOrEmpty(ExtendedNavigationPage.GetTitleBackground(Element)))
                {
                    try
                    {
                        var image = UIImage.FromBundle(ExtendedNavigationPage.GetTitleBackground(Element));
                        titleView.Frame = new CGRect(titleView.Frame.X, titleView.Frame.Y, titleView.Frame.Width == 0?Math.Min(size.Width, image.Size.Width): Math.Min(titleView.Frame.Width, image.Size.Width), titleView.Frame.Height == 0 ? Math.Min(size.Height, image.Size.Height) : Math.Min(titleView.Frame.Height, image.Size.Height));

                        titleView.BackgroundColor = UIColor.FromPatternImage(image);
                    }
                    catch (Exception ex)
                    {
                        titleView.BackgroundColor = ExtendedNavigationPage.GetTitleFillColor(Element)?.ToUIColor() ?? UIColor.Clear;
                    }
                }
                else
                {
                    titleView.BackgroundColor = ExtendedNavigationPage.GetTitleFillColor(Element)?.ToUIColor() ?? UIColor.Clear;
                }


                ParentViewController.NavigationItem.TitleView = containerView;
                ParentViewController.NavigationItem.TitleView.SetNeedsDisplay();
            }
        }
        private void SetupTextFont(UILabel label, Font font, Color?titleColor)
        {
            if (Element is ContentPage cPage)
            {
                var formattedTitle = CustomPage.GetFormattedTitle(cPage);
                if (formattedTitle != null && formattedTitle.Spans.Count > 0)
                {
                    SetupFormattedText(titleLabel, formattedTitle, cPage.Title);
                }

                var formattedSubtitle = CustomPage.GetFormattedSubtitle(cPage);
                var subtitle          = CustomPage.GetSubtitle(cPage);
                if (formattedSubtitle != null && formattedSubtitle.Spans.Count > 0)
                {
                    subtitleLabel.Hidden = false;
                    SetupFormattedText(subtitleLabel, formattedSubtitle, subtitle);
                }
                else if (!string.IsNullOrWhiteSpace(subtitle))
                {
                    subtitleLabel.Hidden = false;
                    SetupText(subtitleLabel, subtitle, ExtendedNavigationPage.GetSubtitleColor(cPage), ExtendedNavigationPage.GetSubtitleFont(Element));

                    subtitleLabel.SetNeedsDisplay();
                }
            }
            else
            {
                SetupText(label, (Element as Page).Title, titleColor, ExtendedNavigationPage.GetTitleFont(Element));
                subtitleLabel.Text   = string.Empty;
                subtitleLabel.Frame  = CGRect.Empty;
                subtitleLabel.Hidden = true;
            }

            label.SizeToFit();
            subtitleLabel.SizeToFit();
            titleView.SizeToFit();
        }
Ejemplo n.º 13
0
        public MainPage(bool myVault = false)
        {
            TintColor = Color.FromHex("3c8dbc");

            var settingsNavigation  = new ExtendedNavigationPage(new SettingsPage());
            var favoritesNavigation = new ExtendedNavigationPage(new VaultListCiphersPage(favorites: true));
            var vaultNavigation     = new ExtendedNavigationPage(new VaultListGroupingsPage());
            var toolsNavigation     = new ExtendedNavigationPage(new ToolsPage());

            favoritesNavigation.Icon = "star.png";
            vaultNavigation.Icon     = "fa_lock.png";
            toolsNavigation.Icon     = "tools.png";
            settingsNavigation.Icon  = "cogs.png";

            Children.Add(favoritesNavigation);
            Children.Add(vaultNavigation);
            Children.Add(toolsNavigation);
            Children.Add(settingsNavigation);

            if (myVault || Resolver.Resolve <IAppSettingsService>().DefaultPageVault)
            {
                SelectedItem = vaultNavigation;
            }
        }
Ejemplo n.º 14
0
 private async void CustomFieldsCell_Tapped(object sender, EventArgs e)
 {
     var page = new ExtendedNavigationPage(new VaultCustomFieldsPage(_cipherId));
     await Navigation.PushModalAsync(page);
 }
        private void Element_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var page = sender as Page;

            System.Diagnostics.Debug.WriteLine(e.PropertyName);

            switch (e.PropertyName)
            {
            case Page.TitleProperty.PropertyName:
            case ExtendedNavigationPage.TitleFontProperty.PropertyName:
            case CustomPage.SubtitleProperty.PropertyName:
            case ExtendedNavigationPage.SubtitleFontProperty.PropertyName:
                SetupTextFont(titleLabel, ExtendedNavigationPage.GetTitleFont(page), ExtendedNavigationPage.GetTitleColor(page));

                SetTitlePosition(ExtendedNavigationPage.GetTitlePosition(page), ExtendedNavigationPage.GetTitlePadding(Element), ExtendedNavigationPage.GetTitleMargin(Element), new CGRect(0, 0, Math.Max(subtitleLabel.IntrinsicContentSize.Width, titleLabel.IntrinsicContentSize.Width), (titleLabel.IntrinsicContentSize.Height + subtitleLabel.IntrinsicContentSize.Height + (subtitleLabel.IntrinsicContentSize.Height > 0.0f ? 3.0f : 0.0f))));
                break;

            case ExtendedNavigationPage.TitleColorProperty.PropertyName:
                var titleColor = ExtendedNavigationPage.GetTitleColor(page);
                if (titleColor.HasValue)
                {
                    titleLabel.TextColor = titleColor.Value.ToUIColor();
                }
                break;

            case ExtendedNavigationPage.SubtitleColorProperty.PropertyName:
                var subtitleColor = ExtendedNavigationPage.GetSubtitleColor(page);
                if (subtitleColor.HasValue)
                {
                    subtitleLabel.TextColor = subtitleColor.Value.ToUIColor();
                }
                break;

            case ExtendedNavigationPage.TitlePositionProperty.PropertyName:
            case ExtendedNavigationPage.TitlePaddingProperty.PropertyName:
            case ExtendedNavigationPage.TitleMarginProperty.PropertyName:
                SetTitlePosition(ExtendedNavigationPage.GetTitlePosition(Element), ExtendedNavigationPage.GetTitlePadding(Element), ExtendedNavigationPage.GetTitleMargin(Element), new CGRect(0, 0, Math.Max(subtitleLabel.IntrinsicContentSize.Width, titleLabel.IntrinsicContentSize.Width), (titleLabel.IntrinsicContentSize.Height + subtitleLabel.IntrinsicContentSize.Height + (subtitleLabel.IntrinsicContentSize.Height > 0.0f ? 3.0f : 0.0f))));
                break;

            case ExtendedNavigationPage.GradientColorsProperty.PropertyName:
            case ExtendedNavigationPage.GradientDirectionProperty.PropertyName:
            case ExtendedNavigationPage.BarBackgroundProperty.PropertyName:
            case ExtendedNavigationPage.BarBackgroundOpacityProperty.PropertyName:
                SetupBackground();
                break;

            case ExtendedNavigationPage.HasShadowProperty.PropertyName:
                SetupShadow(ExtendedNavigationPage.GetHasShadow(page));
                break;

            case ExtendedNavigationPage.TitleBackgroundProperty.PropertyName:
                if (!string.IsNullOrEmpty(ExtendedNavigationPage.GetTitleBackground(Element)))
                {
                    titleView.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle(ExtendedNavigationPage.GetTitleBackground(Element)));
                }
                else
                {
                    titleView.BackgroundColor = null;
                }
                break;

            case nameof(ExtendedNavigationPage.TitleBorderWidth):
                titleView.Layer.BorderWidth = ExtendedNavigationPage.GetTitleBorderWidth(Element);
                break;

            case nameof(ExtendedNavigationPage.TitleBorderCornerRadius):
                titleView.Layer.CornerRadius = ExtendedNavigationPage.GetTitleBorderCornerRadius(Element);
                break;

            case nameof(ExtendedNavigationPage.TitleBorderColor):
                titleView.Layer.BorderColor = ExtendedNavigationPage.GetTitleBorderColor(Element)?.ToCGColor() ?? UIColor.Clear.CGColor;
                break;

            case nameof(ExtendedNavigationPage.TitleFillColor):
                titleView.BackgroundColor = ExtendedNavigationPage.GetTitleFillColor(Element)?.ToUIColor() ?? UIColor.Clear;
                break;

            case nameof(CustomPage.FormattedTitle):
                if (page is ContentPage cPage)
                {
                    SetupFormattedText(titleLabel, CustomPage.GetFormattedTitle(cPage), cPage.Title);
                }
                break;
            }
        }
Ejemplo n.º 16
0
 private async void Search()
 {
     var page = new ExtendedNavigationPage(new VaultListCiphersPage());
     await Navigation.PushModalAsync(page);
 }
Ejemplo n.º 17
0
 private async void AttachmentsCell_Tapped(object sender, EventArgs e)
 {
     var page = new ExtendedNavigationPage(new VaultAttachmentsPage(_loginId));
     await Navigation.PushModalAsync(page);
 }
        private void SetTitlePosition(TitleAlignment alignment, Thickness padding, Thickness margin, CGRect vFrame)
        {
            var marginX       = margin.Top;
            var marginY       = margin.Left;
            var marginWidth   = margin.Left + margin.Right;
            var marginHeight  = margin.Top + margin.Bottom;
            var paddingWidth  = padding.Left + padding.Right;
            var paddingHeight = padding.Top + padding.Bottom;
            var paddingX      = padding.Left;
            var paddingY      = padding.Top;

            if (ExtendedNavigationPage.GetTitleBackground(Element) != null && vFrame.Width == 0 && vFrame.Height == 0)
            {
                vFrame = titleView.Frame;
            }

            marginView.Frame = new CGRect(vFrame.X, vFrame.Y, vFrame.Width, vFrame.Height);

            double offset = 0;

            titleLabel.AutoresizingMask = UIViewAutoresizing.All;
            switch (alignment)
            {
            case TitleAlignment.Start:
                marginView.Frame = new CGRect(vFrame.X, marginView.Frame.Y, marginView.Bounds.Width + marginWidth + paddingWidth, marginView.Bounds.Height + marginHeight + paddingHeight);
                var startCenter = marginView.Center;
                startCenter.Y               = marginView.Superview.Center.Y;
                marginView.Center           = startCenter;
                titleLabel.TextAlignment    = UITextAlignment.Left;
                subtitleLabel.TextAlignment = UITextAlignment.Left;
                offset = marginX;
                break;

            case TitleAlignment.Center:
                offset                      = marginX;
                marginView.Frame            = new CGRect(marginView.Frame.X, marginView.Frame.Y, marginView.Bounds.Width + marginWidth + paddingWidth, marginView.Bounds.Height + marginHeight + paddingHeight);
                marginView.Center           = marginView.Superview.Center;
                titleLabel.TextAlignment    = UITextAlignment.Center;
                subtitleLabel.TextAlignment = UITextAlignment.Center;
                break;

            case TitleAlignment.End:

                var endCenter = marginView.Center;
                endCenter.Y       = marginView.Superview.Center.Y;
                marginView.Center = endCenter;

                titleLabel.TextAlignment    = UITextAlignment.Right;
                subtitleLabel.TextAlignment = UITextAlignment.Right;
                marginView.Frame            = new CGRect(marginView.Superview.Frame.Width - marginView.Frame.Width - offset - marginWidth - paddingWidth, marginView.Frame.Y, marginView.Bounds.Width + marginWidth + paddingWidth, marginView.Bounds.Height + marginHeight + paddingHeight);
                offset = marginView.Frame.Width - vFrame.Width - paddingWidth - marginX;
                break;
            }

            titleView.Frame = new CGRect(offset, vFrame.Y + marginY, vFrame.Width + paddingWidth, vFrame.Height + paddingHeight);

            var cPage             = Element as ContentPage;
            var formattedSubtitle = CustomPage.GetFormattedSubtitle(Element);
            var subtitle          = CustomPage.GetFormattedSubtitle(Element);

            if (cPage != null && (!string.IsNullOrEmpty(subtitle) ||
                                  (formattedSubtitle != null && formattedSubtitle.Spans.Count > 0)))
            {
                titleLabel.Frame = new CGRect(paddingX, paddingY, titleView.Frame.Width, titleLabel.IntrinsicContentSize.Height);

                subtitleLabel.Frame = new CGRect(titleLabel.Frame.X, titleLabel.Frame.Y + titleLabel.Frame.Height + 3, titleView.Frame.Width, subtitleLabel.Frame.Height);
            }
            else
            {
                titleLabel.Frame = new CGRect(paddingX, paddingY, titleLabel.IntrinsicContentSize.Width, titleLabel.IntrinsicContentSize.Height);
            }
        }