blob: 0674557b7ee4368d6ff228825089e5179a6de125 [file] [log] [blame]
Nicolas Jagerbf406b22016-10-21 11:32:33 -04001/***************************************************************************
2 * Copyright (C) 2016 by Savoir-faire Linux *
3 * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
4 * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 **************************************************************************/
19#pragma once
20
21using namespace Platform::Collections;
22using namespace Concurrency;
23
24using namespace RingClientUWP;
25using namespace RingClientUWP::Controls;
26
27namespace RingClientUWP
28{
29namespace ViewModel {
30
31public ref class AccountListItemsViewModel sealed
32{
33internal:
34 /* singleton */
35 static property AccountListItemsViewModel^ instance
36 {
37 AccountListItemsViewModel^ get()
38 {
39 static AccountListItemsViewModel^ instance_ = ref new AccountListItemsViewModel();
40 return instance_;
41 }
42 }
43
44 /* functions */
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040045 AccountListItem^ findItem(String^ accountId);
Nicolas Jagerbf406b22016-10-21 11:32:33 -040046
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040047 /* properties */
Nicolas Jagerbf406b22016-10-21 11:32:33 -040048 property Vector<AccountListItem^>^ itemsList
49 {
50 Vector<AccountListItem^>^ get()
51 {
52 return itemsList_;
53 }
54 }
55
56 property AccountListItem^ _selectedItem
57 {
58 AccountListItem^ get()
59 {
60 return currentItem_;
61 }
62 void set(AccountListItem^ value)
63 {
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040064 if (currentItem_)
65 currentItem_->_isSelected = false;
Nicolas Jagerbf406b22016-10-21 11:32:33 -040066 currentItem_ = value;
67 }
68 }
69
70private:
71 AccountListItemsViewModel(); // singleton
72 Vector<AccountListItem^>^ itemsList_;
73 AccountListItem^ currentItem_;
74
75 void OnaccountAdded(RingClientUWP::Account ^account);
76 void OnclearAccountsList();
77};
78}
79}