clean up and style improving
This commit is contained in:
parent
f34a4fee2a
commit
56ec1d9ed9
@ -27,15 +27,15 @@ namespace eShopOnContainers.Core.Helpers
|
|||||||
private const string IdUrlBase = "url_base";
|
private const string IdUrlBase = "url_base";
|
||||||
private const string IdUseFakeLocation = "use_fake_location";
|
private const string IdUseFakeLocation = "use_fake_location";
|
||||||
private const string IdLatitude = "latitude";
|
private const string IdLatitude = "latitude";
|
||||||
private const string IdLongitude = "flongitude";
|
private const string IdLongitude = "longitude";
|
||||||
private const string IdAllowGpsLocation = "allow_gps_location";
|
private const string IdAllowGpsLocation = "allow_gps_location";
|
||||||
private static readonly string AccessTokenDefault = string.Empty;
|
private static readonly string AccessTokenDefault = string.Empty;
|
||||||
private static readonly string IdTokenDefault = string.Empty;
|
private static readonly string IdTokenDefault = string.Empty;
|
||||||
private static readonly bool UseMocksDefault = true;
|
private static readonly bool UseMocksDefault = true;
|
||||||
private static readonly bool UseFakeLocationDefault = false;
|
private static readonly bool UseFakeLocationDefault = false;
|
||||||
private static readonly bool AllowGpsLocationValue = false;
|
private static readonly bool AllowGpsLocationDefault = false;
|
||||||
private static readonly double FakeLatitudeValue = 47.604610d;
|
private static readonly double FakeLatitudeDefault = 47.604610d;
|
||||||
private static readonly double FakeLongitudeValue = -122.315752d;
|
private static readonly double FakeLongitudeDefault = -122.315752d;
|
||||||
private static readonly string UrlBaseDefault = GlobalSetting.Instance.BaseEndpoint;
|
private static readonly string UrlBaseDefault = GlobalSetting.Instance.BaseEndpoint;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -78,19 +78,19 @@ namespace eShopOnContainers.Core.Helpers
|
|||||||
|
|
||||||
public static double Latitude
|
public static double Latitude
|
||||||
{
|
{
|
||||||
get => AppSettings.GetValueOrDefault<double>(IdLatitude, FakeLatitudeValue);
|
get => AppSettings.GetValueOrDefault<double>(IdLatitude, FakeLatitudeDefault);
|
||||||
set => AppSettings.AddOrUpdateValue<double>(IdLatitude, value);
|
set => AppSettings.AddOrUpdateValue<double>(IdLatitude, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double Longitude
|
public static double Longitude
|
||||||
{
|
{
|
||||||
get => AppSettings.GetValueOrDefault<double>(IdLongitude, FakeLongitudeValue);
|
get => AppSettings.GetValueOrDefault<double>(IdLongitude, FakeLongitudeDefault);
|
||||||
set => AppSettings.AddOrUpdateValue<double>(IdLongitude, value);
|
set => AppSettings.AddOrUpdateValue<double>(IdLongitude, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AllowGpsLocation
|
public static bool AllowGpsLocation
|
||||||
{
|
{
|
||||||
get => AppSettings.GetValueOrDefault<bool>(IdAllowGpsLocation, AllowGpsLocationValue);
|
get => AppSettings.GetValueOrDefault<bool>(IdAllowGpsLocation, AllowGpsLocationDefault);
|
||||||
set => AppSettings.AddOrUpdateValue<bool>(IdAllowGpsLocation, value);
|
set => AppSettings.AddOrUpdateValue<bool>(IdAllowGpsLocation, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace eShopOnContainers.Core.Services.Location
|
namespace eShopOnContainers.Core.Services.Location
|
||||||
{
|
{
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using eShopOnContainers.Core.Models.Location;
|
using Models.Location;
|
||||||
|
|
||||||
public interface ILocationService
|
public interface ILocationService
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace eShopOnContainers.Core.Services.Location
|
namespace eShopOnContainers.Core.Services.Location
|
||||||
{
|
{
|
||||||
using eShopOnContainers.Core.Models.Location;
|
|
||||||
using eShopOnContainers.Core.Services.RequestProvider;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Models.Location;
|
||||||
|
using RequestProvider;
|
||||||
|
|
||||||
public class LocationService : ILocationService
|
public class LocationService : ILocationService
|
||||||
{
|
{
|
||||||
@ -25,4 +25,4 @@
|
|||||||
await _requestProvider.PostAsync(uri, newLocReq, token);
|
await _requestProvider.PostAsync(uri, newLocReq, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
namespace eShopOnContainers.Core.Services.Marketing
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace eShopOnContainers.Core.Services.Marketing
|
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Models.Marketing;
|
using Models.Marketing;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public class CampaignMockService : ICampaignService
|
public class CampaignMockService : ICampaignService
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
using eShopOnContainers.Core.Extensions;
|
namespace eShopOnContainers.Core.Services.Marketing
|
||||||
using eShopOnContainers.Core.Helpers;
|
|
||||||
|
|
||||||
namespace eShopOnContainers.Core.Services.Marketing
|
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Models.Marketing;
|
using Models.Marketing;
|
||||||
using RequestProvider;
|
using RequestProvider;
|
||||||
|
using Extensions;
|
||||||
|
using Helpers;
|
||||||
|
|
||||||
public class CampaignService : ICampaignService
|
public class CampaignService : ICampaignService
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
namespace eShopOnContainers.Core.Services.Marketing
|
||||||
namespace eShopOnContainers.Core.Services.Marketing
|
|
||||||
{
|
{
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
private double _longitude;
|
private double _longitude;
|
||||||
private string _gpsWarningMessage;
|
private string _gpsWarningMessage;
|
||||||
|
|
||||||
|
|
||||||
private readonly ILocationService _locationService;
|
private readonly ILocationService _locationService;
|
||||||
|
|
||||||
public SettingsViewModel(ILocationService locationService)
|
public SettingsViewModel(ILocationService locationService)
|
||||||
@ -187,7 +186,7 @@
|
|||||||
{
|
{
|
||||||
_allowGpsLocation = value;
|
_allowGpsLocation = value;
|
||||||
|
|
||||||
UpdateGpsUsage();
|
UpdateAllowGpsLocation();
|
||||||
|
|
||||||
RaisePropertyChanged(() => AllowGpsLocation);
|
RaisePropertyChanged(() => AllowGpsLocation);
|
||||||
}
|
}
|
||||||
@ -207,7 +206,7 @@
|
|||||||
{
|
{
|
||||||
UpdateInfoUseAzureServices();
|
UpdateInfoUseAzureServices();
|
||||||
UpdateInfoFakeLocation();
|
UpdateInfoFakeLocation();
|
||||||
UpdateInfoGpsUsage();
|
UpdateInfoAllowGpsLocation();
|
||||||
|
|
||||||
return base.InitializeAsync(navigationData);
|
return base.InitializeAsync(navigationData);
|
||||||
}
|
}
|
||||||
@ -258,7 +257,7 @@
|
|||||||
|
|
||||||
private void ToggleAllowGpsLocation()
|
private void ToggleAllowGpsLocation()
|
||||||
{
|
{
|
||||||
UpdateInfoGpsUsage();
|
UpdateInfoAllowGpsLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateInfoUseAzureServices()
|
private void UpdateInfoUseAzureServices()
|
||||||
@ -278,28 +277,30 @@
|
|||||||
private void UpdateInfoFakeLocation()
|
private void UpdateInfoFakeLocation()
|
||||||
{
|
{
|
||||||
if (!UseFakeLocation)
|
if (!UseFakeLocation)
|
||||||
|
{
|
||||||
|
TitleUseFakeLocation = "Use Real Location";
|
||||||
|
DescriptionUseFakeLocation = "When enabling the use of real location, the app will attempt to use real location from the device.";
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
TitleUseFakeLocation = "Use Fake Location";
|
TitleUseFakeLocation = "Use Fake Location";
|
||||||
DescriptionUseFakeLocation = "Fake Location are added for marketing campaign testing.";
|
DescriptionUseFakeLocation = "Fake Location are added for marketing campaign testing.";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
TitleUseFakeLocation = "Use Real Location";
|
|
||||||
DescriptionUseFakeLocation = "When enabling the use of real location, the app will attempt to use real location from the device.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateInfoGpsUsage()
|
private void UpdateInfoAllowGpsLocation()
|
||||||
{
|
{
|
||||||
if (!AllowGpsLocation)
|
if (!AllowGpsLocation)
|
||||||
{
|
{
|
||||||
TitleAllowGpsLocation = "Allow GPS location";
|
TitleAllowGpsLocation = "GPS location Denied";
|
||||||
DescriptionAllowGpsLocation = "When allowing the use of device gps you will get the location campaigns through your real location.";
|
DescriptionAllowGpsLocation = "When denying the use of device gps you won't get the location campaigns through your real location.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TitleAllowGpsLocation = "Deny GPS location";
|
TitleAllowGpsLocation = "GPS location Allowed";
|
||||||
DescriptionAllowGpsLocation = "When denying the use of device gps you won't get the location campaigns through your real location.";
|
DescriptionAllowGpsLocation = "When allowing the use of device gps you will get the location campaigns through your real location.";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,14 +334,14 @@
|
|||||||
Settings.Longitude = _longitude;
|
Settings.Longitude = _longitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateGpsUsage()
|
private void UpdateAllowGpsLocation()
|
||||||
{
|
{
|
||||||
if (_allowGpsLocation)
|
if (_allowGpsLocation)
|
||||||
{
|
{
|
||||||
var locator = CrossGeolocator.Current;
|
var locator = CrossGeolocator.Current;
|
||||||
if (!locator.IsGeolocationEnabled)
|
if (!locator.IsGeolocationEnabled)
|
||||||
{
|
{
|
||||||
_allowGpsLocation = !_allowGpsLocation;
|
_allowGpsLocation = false;
|
||||||
GpsWarningMessage = "Enable your GPS system in your device";
|
GpsWarningMessage = "Enable your GPS system in your device";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -349,6 +350,10 @@
|
|||||||
GpsWarningMessage = string.Empty;
|
GpsWarningMessage = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Settings.AllowGpsLocation = _allowGpsLocation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,13 +7,6 @@
|
|||||||
Title="Campaign Details">
|
Title="Campaign Details">
|
||||||
<ContentPage.Resources>
|
<ContentPage.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<Style x:Key="CampaignStyle"
|
|
||||||
TargetType="{x:Type StackLayout}">
|
|
||||||
<Setter Property="VerticalOptions"
|
|
||||||
Value="Center" />
|
|
||||||
<Setter Property="Margin"
|
|
||||||
Value="0" />
|
|
||||||
</Style>
|
|
||||||
<Style x:Key="CampaignTitleStyle"
|
<Style x:Key="CampaignTitleStyle"
|
||||||
TargetType="{x:Type Label}">
|
TargetType="{x:Type Label}">
|
||||||
<Setter Property="FontFamily"
|
<Setter Property="FontFamily"
|
||||||
@ -26,6 +19,8 @@
|
|||||||
Value="Center" />
|
Value="Center" />
|
||||||
<Setter Property="Margin"
|
<Setter Property="Margin"
|
||||||
Value="12, 0" />
|
Value="12, 0" />
|
||||||
|
<Setter Property="TextColor"
|
||||||
|
Value="{StaticResource GreenColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="CampaignDescriptionStyle"
|
<Style x:Key="CampaignDescriptionStyle"
|
||||||
@ -33,6 +28,44 @@
|
|||||||
BasedOn="{StaticResource CampaignTitleStyle}">
|
BasedOn="{StaticResource CampaignTitleStyle}">
|
||||||
<Setter Property="FontSize"
|
<Setter Property="FontSize"
|
||||||
Value="{StaticResource LittleSize}" />
|
Value="{StaticResource LittleSize}" />
|
||||||
|
<Setter Property="TextColor"
|
||||||
|
Value="{StaticResource BlackColor}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="CampaignImageStyle"
|
||||||
|
TargetType="{x:Type Image}">
|
||||||
|
<Setter Property="Aspect"
|
||||||
|
Value="AspectFit" />
|
||||||
|
<Setter Property="VerticalOptions"
|
||||||
|
Value="Start" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="12" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="CampaignAvailabilityDescriptionStyle"
|
||||||
|
TargetType="{x:Type Label}">
|
||||||
|
<Setter Property="FontFamily"
|
||||||
|
Value="{StaticResource MontserratRegular}" />
|
||||||
|
<Setter Property="TextColor"
|
||||||
|
Value="{StaticResource WhiteColor}" />
|
||||||
|
<Setter Property="HorizontalOptions"
|
||||||
|
Value="CenterAndExpand" />
|
||||||
|
<Setter Property="VerticalOptions"
|
||||||
|
Value="Center" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="CampaignAvailabilityButtonStyle"
|
||||||
|
TargetType="{x:Type Grid}">
|
||||||
|
<Setter Property="BackgroundColor"
|
||||||
|
Value="{StaticResource LightGreenColor}" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="12" />
|
||||||
|
<Setter Property="VerticalOptions"
|
||||||
|
Value="Center" />
|
||||||
|
<Setter Property="ColumnSpacing"
|
||||||
|
Value="0" />
|
||||||
|
<Setter Property="RowSpacing"
|
||||||
|
Value="0" />
|
||||||
</Style>
|
</Style>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ContentPage.Resources>
|
</ContentPage.Resources>
|
||||||
@ -40,62 +73,57 @@
|
|||||||
ColumnSpacing="0"
|
ColumnSpacing="0"
|
||||||
RowSpacing="0">
|
RowSpacing="0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="60" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!-- CAMPAIGN DETAILS -->
|
<!-- CAMPAIGN DETAILS -->
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<StackLayout
|
<StackLayout>
|
||||||
x:Name="Campaign">
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="1" />
|
<RowDefinition Height="1" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="1" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid
|
<Grid
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="0"
|
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
BackgroundColor="Gray"/>
|
BackgroundColor="Gray"/>
|
||||||
<StackLayout
|
<Image
|
||||||
Style ="{StaticResource CampaignStyle}"
|
Grid.Row="1"
|
||||||
Grid.Column="0"
|
Source="{Binding Campaign.PictureUri, Converter={StaticResource ImageConverter}}"
|
||||||
Grid.Row="1">
|
Style="{StaticResource CampaignImageStyle}"/>
|
||||||
<Image
|
<Label
|
||||||
Source="{Binding Campaign.PictureUri, Converter={StaticResource ImageConverter}}"
|
Grid.Row="2"
|
||||||
Aspect="AspectFit"
|
Text="{Binding Campaign.Name}"
|
||||||
VerticalOptions="Start"
|
Style="{StaticResource CampaignTitleStyle}"/>
|
||||||
Margin="12,0,0,0" />
|
<Label
|
||||||
<Label
|
Grid.Row="3"
|
||||||
Text="{Binding Campaign.Name}"
|
Text="{Binding Campaign.Description}"
|
||||||
TextColor="{StaticResource GreenColor}"
|
Style="{StaticResource CampaignDescriptionStyle}"/>
|
||||||
Style="{StaticResource CampaignTitleStyle}"/>
|
|
||||||
<Label
|
|
||||||
Text="{Binding Campaign.Description}"
|
|
||||||
Style="{StaticResource CampaignDescriptionStyle}"/>
|
|
||||||
<StackLayout
|
|
||||||
HorizontalOptions="Center"
|
|
||||||
Margin="12,0,0,0" >
|
|
||||||
<Label
|
|
||||||
Text="{Binding Campaign.From, StringFormat='From {0:MMMM dd, yyyy}'}"
|
|
||||||
Style="{StaticResource CampaignDescriptionStyle}"/>
|
|
||||||
<Label
|
|
||||||
Text="{Binding Campaign.To, StringFormat='until {0:MMMM dd, yyyy}'}"
|
|
||||||
Style="{StaticResource CampaignDescriptionStyle}"/>
|
|
||||||
</StackLayout>
|
|
||||||
</StackLayout>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
<Grid
|
||||||
|
Grid.Row="1"
|
||||||
|
Style="{StaticResource CampaignAvailabilityButtonStyle}">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Label
|
||||||
|
Grid.Row="0"
|
||||||
|
Text="{Binding Campaign.From, StringFormat='From {0:MMMM dd, yyyy}'}"
|
||||||
|
Style="{StaticResource CampaignAvailabilityDescriptionStyle}"/>
|
||||||
|
<Label
|
||||||
|
Grid.Row="1"
|
||||||
|
Text="{Binding Campaign.To, StringFormat='until {0:MMMM dd, yyyy}'}"
|
||||||
|
Style="{StaticResource CampaignAvailabilityDescriptionStyle}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<!-- INDICATOR -->
|
<!-- INDICATOR -->
|
||||||
<ActivityIndicator
|
<ActivityIndicator
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.RowSpan="2"
|
|
||||||
Color="{StaticResource LightGreenColor}"
|
Color="{StaticResource LightGreenColor}"
|
||||||
IsRunning="{Binding IsBusy}"
|
IsRunning="{Binding IsBusy}"
|
||||||
IsVisible="{Binding IsBusy}"
|
IsVisible="{Binding IsBusy}"
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="eShopOnContainers.Core.Views.CampaignView"
|
x:Class="eShopOnContainers.Core.Views.CampaignView"
|
||||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||||
xmlns:views="clr-namespace:eShopOnContainers.Core.Views;assembly=eShopOnContainers.Core"
|
|
||||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||||
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
|
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
|
||||||
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"
|
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user