Browse Source

Add userIsLogged contiditon in view for fake location

pull/809/head
Christian Arenas 7 years ago
parent
commit
19647d8b7d
3 changed files with 14 additions and 7 deletions
  1. +3
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs
  2. +4
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/SettingsViewModel.cs
  3. +7
    -5
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/SettingsView.xaml

+ 3
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs View File

@ -215,8 +215,10 @@ namespace eShopOnContainers.Core.ViewModels
if(Settings.UseMocks) if(Settings.UseMocks)
{ {
Settings.AuthAccessToken = string.Empty; Settings.AuthAccessToken = string.Empty;
Settings.AuthIdToken = string.Empty;
Settings.AuthIdToken = string.Empty;
} }
Settings.UseFakeLocation = false;
} }
private async Task NavigateAsync(string url) private async Task NavigateAsync(string url)


+ 4
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/SettingsViewModel.cs View File

@ -140,6 +140,8 @@ namespace eShopOnContainers.Core.ViewModels
} }
} }
public bool UserIsLogged => !string.IsNullOrEmpty(Settings.AuthAccessToken);
public ICommand ToggleMockServicesCommand => new Command(async () => await ToggleMockServicesAsync()); public ICommand ToggleMockServicesCommand => new Command(async () => await ToggleMockServicesAsync());
public ICommand ToggleFakeLocationCommand => new Command(() => ToggleFakeLocationAsync()); public ICommand ToggleFakeLocationCommand => new Command(() => ToggleFakeLocationAsync());
@ -194,8 +196,9 @@ namespace eShopOnContainers.Core.ViewModels
Latitude = _latitude, Latitude = _latitude,
Longitude = _longitude Longitude = _longitude
}; };
var authToken = Settings.AuthAccessToken;
await _locationService.UpdateUserLocation(locationRequest);
await _locationService.UpdateUserLocation(locationRequest, authToken);
} }
private void UpdateInfo() private void UpdateInfo()


+ 7
- 5
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/SettingsView.xaml View File

@ -163,7 +163,8 @@
Grid.ColumnSpan="2"/> Grid.ColumnSpan="2"/>
<StackLayout <StackLayout
Grid.Column="0" Grid.Column="0"
Grid.Row="4">
Grid.Row="4"
IsVisible="{Binding UserIsLogged}">
<Label <Label
Text="{Binding TitleUseFakeLocation}" Text="{Binding TitleUseFakeLocation}"
TextColor="{StaticResource GreenColor}" TextColor="{StaticResource GreenColor}"
@ -179,7 +180,8 @@
Animate="True" Animate="True"
Checked="{Binding UseFakeLocation, Mode=TwoWay}" Checked="{Binding UseFakeLocation, Mode=TwoWay}"
Command="{Binding ToggleFakeLocationCommand}" Command="{Binding ToggleFakeLocationCommand}"
Style="{StaticResource SettingsToggleButtonStyle}">
Style="{StaticResource SettingsToggleButtonStyle}"
IsVisible="{Binding UserIsLogged}">
<controls:ToggleButton.CheckedImage> <controls:ToggleButton.CheckedImage>
<OnPlatform x:TypeArguments="ImageSource" <OnPlatform x:TypeArguments="ImageSource"
Android="switch_on.png" Android="switch_on.png"
@ -193,7 +195,7 @@
WinPhone="Assets/switchOff.png"/> WinPhone="Assets/switchOff.png"/>
</controls:ToggleButton.UnCheckedImage> </controls:ToggleButton.UnCheckedImage>
</controls:ToggleButton> </controls:ToggleButton>
<!-- ENDPOINT -->
<!-- FAKE LOCATIONS -->
<StackLayout <StackLayout
Grid.Row="5" Grid.Row="5"
Grid.Column="0" Grid.Column="0"
@ -205,7 +207,7 @@
Style="{StaticResource HeaderLabelStyle}"/> Style="{StaticResource HeaderLabelStyle}"/>
<Entry <Entry
Text="{Binding Latitude, Mode=TwoWay}" Text="{Binding Latitude, Mode=TwoWay}"
Keyboard="Numeric">
Keyboard="Text">
<Entry.Style> <Entry.Style>
<OnPlatform <OnPlatform
x:TypeArguments="Style" x:TypeArguments="Style"
@ -219,7 +221,7 @@
Style="{StaticResource HeaderLabelStyle}"/> Style="{StaticResource HeaderLabelStyle}"/>
<Entry <Entry
Text="{Binding Longitude, Mode=TwoWay}" Text="{Binding Longitude, Mode=TwoWay}"
Keyboard="Numeric">
Keyboard="Text">
<Entry.Style> <Entry.Style>
<OnPlatform <OnPlatform
x:TypeArguments="Style" x:TypeArguments="Style"


Loading…
Cancel
Save