@@ -15,65 +15,76 @@ public SettingsView()
1515
1616 public override void ViewWillAppear ( bool animated )
1717 {
18- var application = Mvx . Resolve < IApplicationService > ( ) ;
19- var root = new RootElement ( Title ) ;
20- var currentAccount = application . Account ;
21- var vm = ( SettingsViewModel ) ViewModel ;
22-
23- root . Add ( new Section ( string . Empty , "If disabled, CodeHub will prompt you for your password when you switch to this account" . t ( ) ) {
24- new TrueFalseElement ( "Remember Credentials" . t ( ) , ! currentAccount . DontRemember , e => {
25- currentAccount . DontRemember = ! e . Value ;
26- application . Accounts . Update ( currentAccount ) ;
27- } )
28- } ) ;
29-
30- root . Add ( new Section ( string . Empty , "If enabled, your teams will be shown in the CodeHub slideout menu under Events" . t ( ) ) {
31- new TrueFalseElement ( "Show Organizations in Events" . t ( ) , currentAccount . ShowOrganizationsInEvents , e => {
32- currentAccount . ShowOrganizationsInEvents = e . Value ;
33- application . Accounts . Update ( currentAccount ) ;
34- } )
35- } ) ;
36-
37- root . Add ( new Section ( string . Empty , "If enabled, every organization will be listed under Organizations" . t ( ) ) {
38- new TrueFalseElement ( "List Organizations" . t ( ) , currentAccount . ExpandOrganizations , e => {
39- currentAccount . ExpandOrganizations = e . Value ;
40- application . Accounts . Update ( currentAccount ) ;
41- } )
42- } ) ;
43-
44- root . Add ( new Section ( string . Empty , "If enabled, repository descriptions will be shown in the list of repositories" . t ( ) ) {
45- new TrueFalseElement ( "Show Repo Descriptions" . t ( ) , currentAccount . ShowRepositoryDescriptionInList , e => {
46- currentAccount . ShowRepositoryDescriptionInList = e . Value ;
47- application . Accounts . Update ( currentAccount ) ;
48- } )
49- } ) ;
18+ var vm = ( SettingsViewModel ) ViewModel ;
19+ vm . Bind ( x => x . PushNotificationsEnabled , CreateTable ) ;
20+ CreateTable ( ) ;
21+ base . ViewWillAppear ( animated ) ;
22+ }
23+
24+ private void CreateTable ( )
25+ {
26+ var application = Mvx . Resolve < IApplicationService > ( ) ;
27+ var vm = ( SettingsViewModel ) ViewModel ;
28+ var root = new RootElement ( Title ) ;
29+ var currentAccount = application . Account ;
30+
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+ } )
40+ } ) ;
41+
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+ } )
47+ } ) ;
48+
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+ } )
54+ } ) ;
55+
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+ } )
61+ } ) ;
5062
5163 var el = new StyledStringElement ( "Startup View" , vm . DefaultStartupViewName , MonoTouch . UIKit . UITableViewCellStyle . Value1 )
5264 {
5365 Accessory = MonoTouch . UIKit . UITableViewCellAccessory . DisclosureIndicator ,
5466 } ;
5567 el . Tapped += ( ) => vm . GoToDefaultStartupViewCommand . Execute ( null ) ;
56- root . Add ( new Section ( string . Empty , "Select the default startup view after login" . t ( ) ) { el } ) ;
57-
58- root . Add ( new Section ( string . Empty , "If enabled, send anonymous usage statistics to build a better app" . t ( ) ) {
59- new TrueFalseElement ( "Send Anonymous Usage" . t ( ) , vm . AnalyticsEnabled , e => vm . AnalyticsEnabled = e . Value )
60- } ) ;
61-
62- var totalCacheSizeMB = vm . CacheSize . ToString ( "0.##" ) ;
63- var cacheSection = new Section ( string . Empty , string . Format ( "{0} MB of cache used" . t ( ) , totalCacheSizeMB ) ) ;
64- cacheSection . Add ( new StyledStringElement ( "Delete Cache" . t ( ) , ( ) =>
65- {
66- vm . DeleteAllCacheCommand . Execute ( null ) ;
67- cacheSection . Footer = string . Format ( "{0} MB of cache used" . t ( ) , 0 ) ;
68- ReloadData ( ) ;
69- } ) ) ;
70- root . Add ( cacheSection ) ;
71-
72- //Assign the root
73- Root = root ;
74-
75- base . ViewWillAppear ( animated ) ;
76- }
68+ root . Add ( new Section ( string . Empty , "Select the default startup view after login" . t ( ) ) { el } ) ;
69+
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+ } ) ;
73+
74+ 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 ) ;
83+
84+ //Assign the root
85+ Root = root ;
86+
87+ }
7788 }
7889}
7990
0 commit comments