Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 6e8985a

Browse files
committed
Updated the settings view
1 parent dc6c03d commit 6e8985a

3 files changed

Lines changed: 34 additions & 40 deletions

File tree

CodeHub.Core/ViewModels/App/SettingsViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ private async Task RegisterPushNotifications(bool enabled)
6161
else
6262
await Task.Run(() => notificationService.Deregister());
6363
this.GetApplication().Account.PushNotificationsEnabled = enabled;
64+
this.GetApplication().Accounts.Update(this.GetApplication().Account);
6465
RaisePropertyChanged(() => PushNotificationsEnabled);
6566
}
6667
catch (Exception e)

CodeHub.iOS/Views/App/SettingsView.cs

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,63 +25,56 @@ private void CreateTable()
2525
{
2626
var application = Mvx.Resolve<IApplicationService>();
2727
var vm = (SettingsViewModel)ViewModel;
28-
var root = new RootElement(Title);
2928
var currentAccount = application.Account;
3029

31-
root.Add(new Section(string.Empty, "If disabled, CodeHub will prompt you for your password when you switch to this account") {
32-
new TrueFalseElement("Push Notifications".t(), vm.PushNotificationsEnabled, e => vm.PushNotificationsEnabled = e.Value)
33-
});
34-
35-
root.Add(new Section(string.Empty, "If disabled, CodeHub will prompt you for your password when you switch to this account".t()) {
36-
new TrueFalseElement("Remember Credentials".t(), !currentAccount.DontRemember, e => {
37-
currentAccount.DontRemember = !e.Value;
38-
application.Accounts.Update(currentAccount);
39-
})
30+
var saveCredentials = new TrueFalseElement("Save Credentials".t(), !currentAccount.DontRemember, e =>
31+
{
32+
currentAccount.DontRemember = !e.Value;
33+
application.Accounts.Update(currentAccount);
4034
});
4135

42-
root.Add(new Section(string.Empty, "If enabled, your teams will be shown in the CodeHub slideout menu under Events".t()) {
43-
new TrueFalseElement("Show Organizations in Events".t(), currentAccount.ShowOrganizationsInEvents, e => {
44-
currentAccount.ShowOrganizationsInEvents = e.Value;
45-
application.Accounts.Update(currentAccount);
46-
})
36+
var showOrganizationsInEvents = new TrueFalseElement("Show Organizations in Events".t(), currentAccount.ShowOrganizationsInEvents, e =>
37+
{
38+
currentAccount.ShowOrganizationsInEvents = e.Value;
39+
application.Accounts.Update(currentAccount);
4740
});
4841

49-
root.Add(new Section(string.Empty, "If enabled, every organization will be listed under Organizations".t()) {
50-
new TrueFalseElement("List Organizations".t(), currentAccount.ExpandOrganizations, e => {
51-
currentAccount.ExpandOrganizations = e.Value;
52-
application.Accounts.Update(currentAccount);
53-
})
42+
var showOrganizations = new TrueFalseElement("List Organizations in Menu".t(), currentAccount.ExpandOrganizations, e =>
43+
{
44+
currentAccount.ExpandOrganizations = e.Value;
45+
application.Accounts.Update(currentAccount);
5446
});
5547

56-
root.Add(new Section(string.Empty, "If enabled, repository descriptions will be shown in the list of repositories".t()) {
57-
new TrueFalseElement("Show Repo Descriptions".t(), currentAccount.ShowRepositoryDescriptionInList, e => {
58-
currentAccount.ShowRepositoryDescriptionInList = e.Value;
59-
application.Accounts.Update(currentAccount);
60-
})
48+
var repoDescriptions = new TrueFalseElement("Show Repo Descriptions".t(), currentAccount.ShowRepositoryDescriptionInList, e =>
49+
{
50+
currentAccount.ShowRepositoryDescriptionInList = e.Value;
51+
application.Accounts.Update(currentAccount);
6152
});
6253

63-
var el = new StyledStringElement("Startup View", vm.DefaultStartupViewName, MonoTouch.UIKit.UITableViewCellStyle.Value1)
54+
var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, MonoTouch.UIKit.UITableViewCellStyle.Value1)
6455
{
6556
Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
6657
};
67-
el.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);
68-
root.Add(new Section(string.Empty, "Select the default startup view after login".t()) { el });
58+
startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);
6959

70-
root.Add(new Section(string.Empty, "If enabled, send anonymous usage statistics to build a better app".t()) {
71-
new TrueFalseElement("Send Anonymous Usage".t(), vm.AnalyticsEnabled, e => vm.AnalyticsEnabled = e.Value)
72-
});
60+
var pushNotifications = new TrueFalseElement("Push Notifications".t(), vm.PushNotificationsEnabled, e => vm.PushNotificationsEnabled = e.Value);
7361

7462
var totalCacheSizeMB = vm.CacheSize.ToString("0.##");
75-
var cacheSection = new Section(string.Empty, string.Format("{0} MB of cache used".t(), totalCacheSizeMB));
76-
cacheSection.Add(new StyledStringElement("Delete Cache".t(), () =>
77-
{
78-
vm.DeleteAllCacheCommand.Execute(null);
79-
cacheSection.Footer = string.Format("{0} MB of cache used".t(), 0);
80-
ReloadData();
81-
}));
82-
root.Add(cacheSection);
63+
var deleteCache = new StyledStringElement("Delete Cache".t(), string.Format("{0} MB of cache used".t(), totalCacheSizeMB), MonoTouch.UIKit.UITableViewCellStyle.Subtitle);
64+
deleteCache.Tapped += () =>
65+
{
66+
vm.DeleteAllCacheCommand.Execute(null);
67+
deleteCache.Value = string.Format("{0} MB of cache used".t(), 0);
68+
ReloadData();
69+
};
70+
71+
var usage = new TrueFalseElement("Send Anonymous Usage".t(), vm.AnalyticsEnabled, e => vm.AnalyticsEnabled = e.Value);
8372

8473
//Assign the root
74+
var root = new RootElement(Title);
75+
root.Add(new Section("Account") { saveCredentials, pushNotifications });
76+
root.Add(new Section("Apperance") { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
77+
root.Add(new Section ("Internal") { deleteCache, usage });
8578
Root = root;
8679

8780
}

0 commit comments

Comments
 (0)