Esempio n. 1
0
        public UserPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IGoogleService googleService, IFacebookService facebookService, IAppleService appleService) : base(navigationService)
        {
            _pageDialogService = pageDialogService;
            _googleService     = googleService;
            _facebookService   = facebookService;
            _appleService      = appleService;

            _multiFactorService = new MultiFactorService(this);

            Title = "User";

            var user = _auth.CurrentUser;

            Update(user);

            Name        = new ReactivePropertySlim <string>(user?.DisplayName);
            Email       = new ReactivePropertySlim <string>(user?.Email);
            PhoneNumber = new ReactivePropertySlim <string>(user?.PhoneNumber);

            _isEnrolledMultiFactor.Value = user.MultiFactor.EnrolledFactors.Any();

            UpdateNameCommand.Subscribe(UpdateName);
            UpdateEmailCommand.Subscribe(UpdateEmail);
            UpdatePhoneNumberCommand.Subscribe(UpdatePhoneNumber);
            SignOutCommand.Subscribe(SignOut);
            LinkOrUnlinkWithGoogleCommand.Subscribe(() => IsLinkedWithGoogle.Value ? UnlinkWithProvider("google.com") : LinkWithGoogle());
            LinkOrUnlinkWithTwitterCommand.Subscribe(() => IsLinkedWithTwitter.Value ? UnlinkWithProvider("twitter.com") : LinkWithProvider("twitter.com"));
            LinkOrUnlinkWithFacebookCommand.Subscribe(() => IsLinkedWithFacebook.Value ? UnlinkWithProvider("facebook.com") : LinkWithFacebook());
            LinkOrUnlinkWithGitHubCommand.Subscribe(() => IsLinkedWithGitHub.Value ? UnlinkWithProvider("github.com") : LinkWithProvider("github.com"));
            LinkOrUnlinkWithYahooCommand.Subscribe(() => IsLinkedWithYahoo.Value ? UnlinkWithProvider("yahoo.com") : LinkWithProvider("yahoo.com"));
            LinkOrUnlinkWithMicrosoftCommand.Subscribe(() => IsLinkedWithMicrosoft.Value ? UnlinkWithProvider("microsoft.com") : LinkWithProvider("microsoft.com"));
            LinkOrUnlinkWithAppleCommand.Subscribe(() => IsLinkedWithApple.Value ? UnlinkWithProvider("apple.com") : LinkWithApple());
            EnrollOrUnenrollMultiFactorCommand.Subscribe(() => IsEnrolledMultiFactor.Value ? UnenrollMultiFactor() : EnrollMultiFactor());
            DeleteCommand.Subscribe(Delete);
        }
Esempio n. 2
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IGoogleService googleService, IFacebookService facebookService, IAppleService appleService)
            : base(navigationService)
        {
            _pageDialogService = pageDialogService;
            _googleService     = googleService;
            _facebookService   = facebookService;
            _appleService      = appleService;

            _multiFactorService = new MultiFactorService(this);

            Title = "Main Page";

            _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) =>
            {
                _isSignedIn.Value = auth.CurrentUser != null;
            });

            ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand();

            SignUpCommand.Subscribe(SignUp);
            SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword);
            SignInWithGoogleCommand.Subscribe(SignInWithGoogle);
            SignInWithTwitterCommand.Subscribe(() => SignInWithProvider("twitter.com"));
            SignInWithFacebookCommand.Subscribe(SignInWithFacebook);
            SignInWithGitHubCommand.Subscribe(() => SignInWithProvider("github.com"));
            SignInWithYahooCommand.Subscribe(() => SignInWithProvider("yahoo.com"));
            SignInWithMicrosoftCommand.Subscribe(() => SignInWithProvider("microsoft.com"));
            SignInWithAppleCommand.Subscribe(SignInWithApple);
            SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber);
            SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously);
            ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>());
        }
 public AppleListViewModel(IDialogService dialogService,
                           IRegionManager regionManager,
                           IAppleService appleService)
 {
     this._dialogService = dialogService;
     this._regionManager = regionManager;
     this._appleService  = appleService;
     this._appleService.SaveApple(new AppleModel()
     {
         Name = "Ariane", Colour = "Red"
     });
     this._appleService.SaveApple(new AppleModel()
     {
         Name = "Golden", Colour = "Yellow"
     });
     this.MyAppleList = new NotifierObservableCollection <AppleModel>();
     this.MyAppleList.AddRange(this._appleService.GetApples());
 }
Esempio n. 4
0
 public AppleDetailViewModel(IRegionManager regionManager, IAppleService appleService)
 {
     this._regionManager = regionManager;
     this._appleService  = appleService;
 }
Esempio n. 5
0
 public AppleViewModel(IApplicationService application,
                       IAppleService apple)
 {
     _application = application;
     _apple       = apple;
 }