Nicolas Jager | bf406b2 | 2016-10-21 11:32:33 -0400 | [diff] [blame] | 1 | /***************************************************************************
|
| 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 |
|
| 21 | using namespace Platform::Collections;
|
| 22 | using namespace Concurrency;
|
| 23 |
|
| 24 | using namespace RingClientUWP;
|
| 25 | using namespace RingClientUWP::Controls;
|
| 26 |
|
| 27 | namespace RingClientUWP
|
| 28 | {
|
| 29 | namespace ViewModel {
|
| 30 |
|
| 31 | public ref class AccountListItemsViewModel sealed
|
| 32 | {
|
| 33 | internal:
|
| 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 Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame] | 45 | AccountListItem^ findItem(String^ accountId);
|
Nicolas Jager | bf406b2 | 2016-10-21 11:32:33 -0400 | [diff] [blame] | 46 |
|
Nicolas Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame] | 47 | /* properties */
|
Nicolas Jager | bf406b2 | 2016-10-21 11:32:33 -0400 | [diff] [blame] | 48 | 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 Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame] | 64 | if (currentItem_)
|
| 65 | currentItem_->_isSelected = false;
|
Nicolas Jager | bf406b2 | 2016-10-21 11:32:33 -0400 | [diff] [blame] | 66 | currentItem_ = value;
|
| 67 | }
|
| 68 | }
|
| 69 |
|
| 70 | private:
|
| 71 | AccountListItemsViewModel(); // singleton
|
| 72 | Vector<AccountListItem^>^ itemsList_;
|
| 73 | AccountListItem^ currentItem_;
|
| 74 |
|
| 75 | void OnaccountAdded(RingClientUWP::Account ^account);
|
| 76 | void OnclearAccountsList();
|
| 77 | };
|
| 78 | }
|
| 79 | }
|