blob: 9f766c0ade2e810b0ffed5dbe9840e13ac7296b7 [file] [log] [blame]
atraczyk8ce1dee2016-08-25 18:15:07 -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
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040020#pragma once
atraczyk82f8dda2016-08-25 16:34:52 -040021
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040022using namespace Platform::Collections;
23
24namespace RingClientUWP
25{
26
atraczyk4a8cffc2016-08-25 20:01:25 -040027delegate void NewAccountSelected();
28delegate void NoAccountSelected();
atraczyk196936e2016-09-02 15:31:53 -040029delegate void UpdateScrollView();
atraczyk4a8cffc2016-08-25 20:01:25 -040030
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040031namespace ViewModel {
32public ref class AccountsViewModel sealed
33{
34internal:
35 /* singleton */
36 static property AccountsViewModel^ instance
37 {
38 AccountsViewModel^ get()
39 {
40 static AccountsViewModel^ instance_ = ref new AccountsViewModel();
41 return instance_;
42 }
43 }
44
45 /* functions */
atraczyk797fa1a2016-08-31 09:55:53 -040046 void add(std::string& name, std::string& ringID, std::string& accountType, std::string& accountID);
atraczyk82f8dda2016-08-25 16:34:52 -040047 void clearAccountList();
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040048
49 /* properties */
atraczyk4a8cffc2016-08-25 20:01:25 -040050 property Account^ selectedAccount
51 {
52 Account^ get()
53 {
54 return currentItem_;
55 }
56 void set(Account^ value)
57 {
58 oldItem_ = currentItem_;
59 currentItem_ = value;
60 if (value)
61 newAccountSelected();
62 else
63 noAccountSelected();
64 }
65 }
66
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040067 property Vector<Account^>^ accountsList
68 {
69 Vector<Account^>^ get()
70 {
71 return accountsList_;
72 }
73 }
74
75 /* events */
atraczyk4a8cffc2016-08-25 20:01:25 -040076 event NewAccountSelected^ newAccountSelected;
77 event NoAccountSelected^ noAccountSelected;
atraczyk196936e2016-09-02 15:31:53 -040078 event UpdateScrollView^ updateScrollView;
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040079
80private:
81 AccountsViewModel(); // singleton
82 Vector<Account^>^ accountsList_;
atraczyk4a8cffc2016-08-25 20:01:25 -040083 Account^ currentItem_;
84 Account^ oldItem_;
85
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040086};
87}
88}