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