Skip to content

Commit 56ec1d9

Browse files
committed
clean up and style improving
1 parent f34a4fe commit 56ec1d9

9 files changed

Lines changed: 110 additions & 82 deletions

File tree

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Helpers/Settings.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ private static ISettings AppSettings
2727
private const string IdUrlBase = "url_base";
2828
private const string IdUseFakeLocation = "use_fake_location";
2929
private const string IdLatitude = "latitude";
30-
private const string IdLongitude = "flongitude";
30+
private const string IdLongitude = "longitude";
3131
private const string IdAllowGpsLocation = "allow_gps_location";
3232
private static readonly string AccessTokenDefault = string.Empty;
3333
private static readonly string IdTokenDefault = string.Empty;
3434
private static readonly bool UseMocksDefault = true;
3535
private static readonly bool UseFakeLocationDefault = false;
36-
private static readonly bool AllowGpsLocationValue = false;
37-
private static readonly double FakeLatitudeValue = 47.604610d;
38-
private static readonly double FakeLongitudeValue = -122.315752d;
36+
private static readonly bool AllowGpsLocationDefault = false;
37+
private static readonly double FakeLatitudeDefault = 47.604610d;
38+
private static readonly double FakeLongitudeDefault = -122.315752d;
3939
private static readonly string UrlBaseDefault = GlobalSetting.Instance.BaseEndpoint;
4040

4141
#endregion
@@ -78,19 +78,19 @@ public static bool UseFakeLocation
7878

7979
public static double Latitude
8080
{
81-
get => AppSettings.GetValueOrDefault<double>(IdLatitude, FakeLatitudeValue);
81+
get => AppSettings.GetValueOrDefault<double>(IdLatitude, FakeLatitudeDefault);
8282
set => AppSettings.AddOrUpdateValue<double>(IdLatitude, value);
8383
}
8484

8585
public static double Longitude
8686
{
87-
get => AppSettings.GetValueOrDefault<double>(IdLongitude, FakeLongitudeValue);
87+
get => AppSettings.GetValueOrDefault<double>(IdLongitude, FakeLongitudeDefault);
8888
set => AppSettings.AddOrUpdateValue<double>(IdLongitude, value);
8989
}
9090

9191
public static bool AllowGpsLocation
9292
{
93-
get => AppSettings.GetValueOrDefault<bool>(IdAllowGpsLocation, AllowGpsLocationValue);
93+
get => AppSettings.GetValueOrDefault<bool>(IdAllowGpsLocation, AllowGpsLocationDefault);
9494
set => AppSettings.AddOrUpdateValue<bool>(IdAllowGpsLocation, value);
9595
}
9696
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/ILocationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace eShopOnContainers.Core.Services.Location
22
{
33
using System.Threading.Tasks;
4-
using eShopOnContainers.Core.Models.Location;
4+
using Models.Location;
55

66
public interface ILocationService
77
{

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/LocationService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace eShopOnContainers.Core.Services.Location
22
{
3-
using eShopOnContainers.Core.Models.Location;
4-
using eShopOnContainers.Core.Services.RequestProvider;
53
using System;
64
using System.Threading.Tasks;
5+
using Models.Location;
6+
using RequestProvider;
77

88
public class LocationService : ILocationService
99
{
@@ -25,4 +25,4 @@ public async Task UpdateUserLocation(Location newLocReq, string token)
2525
await _requestProvider.PostAsync(uri, newLocReq, token);
2626
}
2727
}
28-
}
28+
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Marketing/CampaignMockService.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
4-
namespace eShopOnContainers.Core.Services.Marketing
1+
namespace eShopOnContainers.Core.Services.Marketing
52
{
63
using System;
74
using System.Collections.ObjectModel;
85
using System.Threading.Tasks;
96
using Models.Marketing;
107
using Xamarin.Forms;
8+
using System.Linq;
119

1210
public class CampaignMockService : ICampaignService
1311
{

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Marketing/CampaignService.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
using eShopOnContainers.Core.Extensions;
2-
using eShopOnContainers.Core.Helpers;
3-
4-
namespace eShopOnContainers.Core.Services.Marketing
1+
namespace eShopOnContainers.Core.Services.Marketing
52
{
63
using System;
74
using System.Collections.ObjectModel;
85
using System.Threading.Tasks;
96
using Models.Marketing;
107
using RequestProvider;
8+
using Extensions;
9+
using Helpers;
1110

1211
public class CampaignService : ICampaignService
1312
{

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Marketing/ICampaignService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
namespace eShopOnContainers.Core.Services.Marketing
1+
namespace eShopOnContainers.Core.Services.Marketing
32
{
43
using System.Collections.ObjectModel;
54
using System.Threading.Tasks;

src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/SettingsViewModel.cs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class SettingsViewModel : ViewModelBase
2626
private double _longitude;
2727
private string _gpsWarningMessage;
2828

29-
3029
private readonly ILocationService _locationService;
3130

3231
public SettingsViewModel(ILocationService locationService)
@@ -187,7 +186,7 @@ public bool AllowGpsLocation
187186
{
188187
_allowGpsLocation = value;
189188

190-
UpdateGpsUsage();
189+
UpdateAllowGpsLocation();
191190

192191
RaisePropertyChanged(() => AllowGpsLocation);
193192
}
@@ -207,7 +206,7 @@ public override Task InitializeAsync(object navigationData)
207206
{
208207
UpdateInfoUseAzureServices();
209208
UpdateInfoFakeLocation();
210-
UpdateInfoGpsUsage();
209+
UpdateInfoAllowGpsLocation();
211210

212211
return base.InitializeAsync(navigationData);
213212
}
@@ -258,7 +257,7 @@ private async Task ToggleSendLocationAsync()
258257

259258
private void ToggleAllowGpsLocation()
260259
{
261-
UpdateInfoGpsUsage();
260+
UpdateInfoAllowGpsLocation();
262261
}
263262

264263
private void UpdateInfoUseAzureServices()
@@ -279,27 +278,29 @@ private void UpdateInfoFakeLocation()
279278
{
280279
if (!UseFakeLocation)
281280
{
282-
TitleUseFakeLocation = "Use Fake Location";
283-
DescriptionUseFakeLocation = "Fake Location are added for marketing campaign testing.";
281+
TitleUseFakeLocation = "Use Real Location";
282+
DescriptionUseFakeLocation = "When enabling the use of real location, the app will attempt to use real location from the device.";
283+
284284
}
285285
else
286286
{
287-
TitleUseFakeLocation = "Use Real Location";
288-
DescriptionUseFakeLocation = "When enabling the use of real location, the app will attempt to use real location from the device.";
287+
TitleUseFakeLocation = "Use Fake Location";
288+
DescriptionUseFakeLocation = "Fake Location are added for marketing campaign testing.";
289289
}
290290
}
291291

292-
private void UpdateInfoGpsUsage()
292+
private void UpdateInfoAllowGpsLocation()
293293
{
294294
if (!AllowGpsLocation)
295295
{
296-
TitleAllowGpsLocation = "Allow GPS location";
297-
DescriptionAllowGpsLocation = "When allowing the use of device gps you will get the location campaigns through your real location.";
296+
TitleAllowGpsLocation = "GPS location Denied";
297+
DescriptionAllowGpsLocation = "When denying the use of device gps you won't get the location campaigns through your real location.";
298298
}
299299
else
300300
{
301-
TitleAllowGpsLocation = "Deny GPS location";
302-
DescriptionAllowGpsLocation = "When denying the use of device gps you won't get the location campaigns through your real location.";
301+
TitleAllowGpsLocation = "GPS location Allowed";
302+
DescriptionAllowGpsLocation = "When allowing the use of device gps you will get the location campaigns through your real location.";
303+
303304
}
304305
}
305306

@@ -333,14 +334,14 @@ private void UpdateLongitude()
333334
Settings.Longitude = _longitude;
334335
}
335336

336-
private void UpdateGpsUsage()
337+
private void UpdateAllowGpsLocation()
337338
{
338339
if (_allowGpsLocation)
339340
{
340341
var locator = CrossGeolocator.Current;
341342
if (!locator.IsGeolocationEnabled)
342343
{
343-
_allowGpsLocation = !_allowGpsLocation;
344+
_allowGpsLocation = false;
344345
GpsWarningMessage = "Enable your GPS system in your device";
345346
}
346347
else
@@ -349,6 +350,10 @@ private void UpdateGpsUsage()
349350
GpsWarningMessage = string.Empty;
350351
}
351352
}
353+
else
354+
{
355+
Settings.AllowGpsLocation = _allowGpsLocation;
356+
}
352357
}
353358
}
354359
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CampaignDetailsView.xaml

Lines changed: 73 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
Title="Campaign Details">
88
<ContentPage.Resources>
99
<ResourceDictionary>
10-
<Style x:Key="CampaignStyle"
11-
TargetType="{x:Type StackLayout}">
12-
<Setter Property="VerticalOptions"
13-
Value="Center" />
14-
<Setter Property="Margin"
15-
Value="0" />
16-
</Style>
1710
<Style x:Key="CampaignTitleStyle"
1811
TargetType="{x:Type Label}">
1912
<Setter Property="FontFamily"
@@ -26,76 +19,111 @@
2619
Value="Center" />
2720
<Setter Property="Margin"
2821
Value="12, 0" />
22+
<Setter Property="TextColor"
23+
Value="{StaticResource GreenColor}" />
2924
</Style>
3025

3126
<Style x:Key="CampaignDescriptionStyle"
3227
TargetType="{x:Type Label}"
3328
BasedOn="{StaticResource CampaignTitleStyle}">
3429
<Setter Property="FontSize"
3530
Value="{StaticResource LittleSize}" />
31+
<Setter Property="TextColor"
32+
Value="{StaticResource BlackColor}" />
33+
</Style>
34+
35+
<Style x:Key="CampaignImageStyle"
36+
TargetType="{x:Type Image}">
37+
<Setter Property="Aspect"
38+
Value="AspectFit" />
39+
<Setter Property="VerticalOptions"
40+
Value="Start" />
41+
<Setter Property="Margin"
42+
Value="12" />
43+
</Style>
44+
45+
<Style x:Key="CampaignAvailabilityDescriptionStyle"
46+
TargetType="{x:Type Label}">
47+
<Setter Property="FontFamily"
48+
Value="{StaticResource MontserratRegular}" />
49+
<Setter Property="TextColor"
50+
Value="{StaticResource WhiteColor}" />
51+
<Setter Property="HorizontalOptions"
52+
Value="CenterAndExpand" />
53+
<Setter Property="VerticalOptions"
54+
Value="Center" />
55+
</Style>
56+
57+
<Style x:Key="CampaignAvailabilityButtonStyle"
58+
TargetType="{x:Type Grid}">
59+
<Setter Property="BackgroundColor"
60+
Value="{StaticResource LightGreenColor}" />
61+
<Setter Property="Padding"
62+
Value="12" />
63+
<Setter Property="VerticalOptions"
64+
Value="Center" />
65+
<Setter Property="ColumnSpacing"
66+
Value="0" />
67+
<Setter Property="RowSpacing"
68+
Value="0" />
3669
</Style>
3770
</ResourceDictionary>
3871
</ContentPage.Resources>
3972
<Grid
4073
ColumnSpacing="0"
4174
RowSpacing="0">
4275
<Grid.RowDefinitions>
43-
<RowDefinition Height="Auto" />
76+
<RowDefinition Height="*" />
77+
<RowDefinition Height="60" />
4478
</Grid.RowDefinitions>
4579
<!-- CAMPAIGN DETAILS -->
4680
<ScrollView>
47-
<StackLayout
48-
x:Name="Campaign">
81+
<StackLayout>
4982
<Grid>
50-
<Grid.ColumnDefinitions>
51-
<ColumnDefinition Width="*" />
52-
<ColumnDefinition Width="Auto" />
53-
</Grid.ColumnDefinitions>
5483
<Grid.RowDefinitions>
5584
<RowDefinition Height="1" />
5685
<RowDefinition Height="Auto" />
5786
<RowDefinition Height="Auto" />
58-
<RowDefinition Height="1" />
87+
<RowDefinition Height="*" />
5988
</Grid.RowDefinitions>
6089
<Grid
6190
Grid.Row="0"
62-
Grid.Column="0"
63-
Grid.ColumnSpan="2"
6491
BackgroundColor="Gray"/>
65-
<StackLayout
66-
Style ="{StaticResource CampaignStyle}"
67-
Grid.Column="0"
68-
Grid.Row="1">
69-
<Image
70-
Source="{Binding Campaign.PictureUri, Converter={StaticResource ImageConverter}}"
71-
Aspect="AspectFit"
72-
VerticalOptions="Start"
73-
Margin="12,0,0,0" />
74-
<Label
75-
Text="{Binding Campaign.Name}"
76-
TextColor="{StaticResource GreenColor}"
77-
Style="{StaticResource CampaignTitleStyle}"/>
78-
<Label
79-
Text="{Binding Campaign.Description}"
80-
Style="{StaticResource CampaignDescriptionStyle}"/>
81-
<StackLayout
82-
HorizontalOptions="Center"
83-
Margin="12,0,0,0" >
84-
<Label
85-
Text="{Binding Campaign.From, StringFormat='From {0:MMMM dd, yyyy}'}"
86-
Style="{StaticResource CampaignDescriptionStyle}"/>
87-
<Label
88-
Text="{Binding Campaign.To, StringFormat='until {0:MMMM dd, yyyy}'}"
89-
Style="{StaticResource CampaignDescriptionStyle}"/>
90-
</StackLayout>
91-
</StackLayout>
92+
<Image
93+
Grid.Row="1"
94+
Source="{Binding Campaign.PictureUri, Converter={StaticResource ImageConverter}}"
95+
Style="{StaticResource CampaignImageStyle}"/>
96+
<Label
97+
Grid.Row="2"
98+
Text="{Binding Campaign.Name}"
99+
Style="{StaticResource CampaignTitleStyle}"/>
100+
<Label
101+
Grid.Row="3"
102+
Text="{Binding Campaign.Description}"
103+
Style="{StaticResource CampaignDescriptionStyle}"/>
92104
</Grid>
93105
</StackLayout>
94106
</ScrollView>
107+
<Grid
108+
Grid.Row="1"
109+
Style="{StaticResource CampaignAvailabilityButtonStyle}">
110+
<Grid.RowDefinitions>
111+
<RowDefinition Height="Auto" />
112+
<RowDefinition Height="Auto" />
113+
</Grid.RowDefinitions>
114+
<Label
115+
Grid.Row="0"
116+
Text="{Binding Campaign.From, StringFormat='From {0:MMMM dd, yyyy}'}"
117+
Style="{StaticResource CampaignAvailabilityDescriptionStyle}"/>
118+
<Label
119+
Grid.Row="1"
120+
Text="{Binding Campaign.To, StringFormat='until {0:MMMM dd, yyyy}'}"
121+
Style="{StaticResource CampaignAvailabilityDescriptionStyle}"/>
122+
</Grid>
123+
95124
<!-- INDICATOR -->
96125
<ActivityIndicator
97126
Grid.Row="0"
98-
Grid.RowSpan="2"
99127
Color="{StaticResource LightGreenColor}"
100128
IsRunning="{Binding IsBusy}"
101129
IsVisible="{Binding IsBusy}"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CampaignView.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
x:Class="eShopOnContainers.Core.Views.CampaignView"
55
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
6-
xmlns:views="clr-namespace:eShopOnContainers.Core.Views;assembly=eShopOnContainers.Core"
76
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
87
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
98
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"

0 commit comments

Comments
 (0)