summaryrefslogtreecommitdiff
path: root/Juick/ViewModels/AppViewModel.cs
blob: 77970df04beffa0ba0fd20513fcca1f3925c4e05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Juick.Classes;
using JuickApi;
using RestSharp;

namespace Juick.ViewModels
{
    public class AppViewModel : ViewModelBase
    {
        private ObservableCollection<PageViewModel> _pages;
        public ObservableCollection<PageViewModel> Pages
        {
            get { return _pages ?? (_pages = new ObservableCollection<PageViewModel>()); }
        }

        static readonly string IsDataLoadingPropertyName = ExpressionHelper.GetPropertyName<AppViewModel>(x => x.IsDataLoading);
        bool _isDataLoading;

        public bool IsDataLoading
        {
            get { return _isDataLoading; }
            set
            {
                _isDataLoading = value;
                NotifyPropertyChanged(IsDataLoadingPropertyName);
                foreach (var page in Pages)
                {
                    page.LoadMessagesPageCommand.NotifyCanExecuteChanged();
                }
            }
        }

        private AccountManager _acc;

        public AccountManager Account
        {
            get { return _acc ?? (_acc = new AccountManager()); }
        }

        private RestClient _cl;
        public RestClient Client
        {
            get
            {
                return _cl ?? (_cl = new RestClient("http://api.juick.com")
                {
                    UserAgent = "Juick 1.1/Windows Phone " + Environment.OSVersion.Version
                });
            }
        }
    }
}