Skip to content

Commit f923aa6

Browse files
author
Javier Suárez Ruiz
committed
Updated mobile settings view
1 parent 0d2ec11 commit f923aa6

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
using eShopOnContainers.ViewModels.Base;
22
using System.Windows.Input;
33
using Xamarin.Forms;
4+
using System.Threading.Tasks;
45

56
namespace eShopOnContainers.Core.ViewModels
67
{
78
public class SettingsViewModel : ViewModelBase
89
{
10+
private string _title;
11+
private string _description;
912
private bool _useMockServices;
1013

1114
public SettingsViewModel()
1215
{
1316
UseMockServices = ViewModelLocator.Instance.UseMockService;
1417
}
1518

19+
public string Title
20+
{
21+
get { return _title; }
22+
set
23+
{
24+
_title = value;
25+
RaisePropertyChanged(() => Title);
26+
}
27+
}
28+
29+
public string Description
30+
{
31+
get { return _description; }
32+
set
33+
{
34+
_description = value;
35+
RaisePropertyChanged(() => Description);
36+
}
37+
}
38+
1639
public bool UseMockServices
1740
{
1841
get { return _useMockServices; }
@@ -28,6 +51,28 @@ public bool UseMockServices
2851
private void MockServices()
2952
{
3053
ViewModelLocator.Instance.UpdateServices(UseMockServices);
54+
UpdateInfo();
55+
}
56+
57+
public override Task InitializeAsync(object navigationData)
58+
{
59+
UpdateInfo();
60+
61+
return base.InitializeAsync(navigationData);
62+
}
63+
64+
private void UpdateInfo()
65+
{
66+
if (!UseMockServices)
67+
{
68+
Title = "Use Mock Services";
69+
Description = "Mock Services are simulated objects that mimic the behavior of real services in controlled ways";
70+
}
71+
else
72+
{
73+
Title = "Use Azure Services";
74+
Description = "Azure Services are real objects that required a valid internet connection";
75+
}
3176
}
3277
}
3378
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
Grid.Column="0"
6868
Grid.Row="1">
6969
<Label
70-
Text="Use Mock Services"
70+
Text="{Binding Title}"
7171
TextColor="{StaticResource GreenColor}"
7272
Style="{StaticResource SettingsTitleStyle}"/>
7373
<Label
74-
Text="Mock Services are simulated objects that mimic the behavior of real services in controlled ways"
74+
Text="{Binding Description}"
7575
Style="{StaticResource SettingsDescriptionStyle}"/>
7676
</StackLayout>
7777
<controls:ToggleButton

0 commit comments

Comments
 (0)