blob: b39eca86548d3f0018396a7a4e2d594408f5be6d [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 Jager5a197d52016-10-25 11:24:03 -040046 void removeItem(AccountListItem^ item);
Nicolas Jagerbf406b22016-10-21 11:32:33 -040047
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040048 /* properties */
Nicolas Jagerbf406b22016-10-21 11:32:33 -040049 property Vector<AccountListItem^>^ itemsList
50 {
51 Vector<AccountListItem^>^ get()
52 {
53 return itemsList_;
54 }
55 }
56
57 property AccountListItem^ _selectedItem
58 {
59 AccountListItem^ get()
60 {
61 return currentItem_;
62 }
63 void set(AccountListItem^ value)
64 {
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040065 if (currentItem_)
66 currentItem_->_isSelected = false;
Nicolas Jagerbf406b22016-10-21 11:32:33 -040067 currentItem_ = value;
68 }
69 }
70
71private:
72 AccountListItemsViewModel(); // singleton
73 Vector<AccountListItem^>^ itemsList_;
74 AccountListItem^ currentItem_;
75
76 void OnaccountAdded(RingClientUWP::Account ^account);
77 void OnclearAccountsList();
78};
79}
80}