Add userIsLogged contiditon in view for fake location

This commit is contained in:
Christian Arenas 2017-06-12 20:22:38 +02:00
parent 3b5d081086
commit 2283a9d12b
3 changed files with 14 additions and 7 deletions

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)

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()

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"