Ejemplo n.º 1
0
        public LoginPage(TeslaService teslaService, IProfileService profileService, ITeslaAPIWrapper teslaAPIWrapper)
        {
            TeslaService    = teslaService;
            ProfileService  = profileService;
            TeslaAPIWrapper = teslaAPIWrapper;

            Email = new Entry
            {
                Placeholder = "Email",
                Keyboard    = Keyboard.Numeric,
            };
            Email.TextChanged += TextChanged;
            Password           = new Entry
            {
                Placeholder = "Password",
                Keyboard    = Keyboard.Numeric,
            };
            Password.TextChanged += TextChanged;
            LoginButton           = new Button
            {
                Text      = "Login",
                IsEnabled = false,
            };
            LoginButton.Clicked += Button_Clicked;

            Content = new StackLayout
            {
                Children =
                {
                    Email,
                    Password,
                    LoginButton,
                },
            };
        }
Ejemplo n.º 2
0
        private async void Setup()
        {
            // TODO Need a way to determine if this is from cache or not to force a refresh
            var cachedVehicles = await TeslaService.GetVehicles();

            Device.BeginInvokeOnMainThread(() =>
            {
                ShowVehicles(cachedVehicles);
            });
        }
Ejemplo n.º 3
0
        public VehicleNavigation(TeslaService teslaService, IProfileService profileService, ITeslaAPIWrapper teslaAPIWrapper)
        {
            TeslaService    = teslaService;
            ProfileService  = profileService;
            TeslaAPIWrapper = teslaAPIWrapper;
            NavigationPage.SetHasNavigationBar(this, false);
            Children.Add(new LoadingPage());
            var thread = new Thread(new ThreadStart(Setup))
            {
                IsBackground = true
            };

            thread.Start();
        }
        protected override void OnInitialized()
        {
            var authorization = TeslaService.GetAuthorization();

            if (authorization == null)
            {
                NavigationManager.NavigateTo($"/login?redirect={WebUtility.UrlEncode(new Uri(NavigationManager.Uri).PathAndQuery)}");
            }
            else
            {
                Authorization = authorization;
            }

            base.OnInitialized();
        }