blob: 95feadf455693b8e0e7fb4e8303d295e454735ab [file] [log] [blame]
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -04001#pragma once
2/**************************************************************************
3* Copyright (C) 2016 by Savoir-faire Linux *
4* Author: Jäger Nicolas <nicolas.jager@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**************************************************************************/
19using namespace Platform::Collections;
20
21namespace RingClientUWP
22{
23
Nicolas Jager8a85e1f2016-08-15 15:11:06 -040024delegate void NewContactSelected();
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040025delegate void NoContactSelected();
26
27namespace ViewModel {
28public ref class ContactsViewModel sealed
29{
30internal:
31 /* singleton */
32 static property ContactsViewModel^ instance
33 {
34 ContactsViewModel^ get()
35 {
36 static ContactsViewModel^ instance_ = ref new ContactsViewModel();
37 return instance_;
38 }
39 }
40
41 /* functions */
42 Contact^ findContactByName(String^ name);
43
44 Contact^ addNewContact(String^ name, String^ ringId);
45
46 /* properties */
47 property Contact^ selectedContact
48 {
49 Contact^ get()
50 {
51 return currentItem_;
52 }
53 void set(Contact^ value)
54 {
55 oldItem_ = currentItem_;
56 currentItem_ = value;
57 if (value)
Nicolas Jager8a85e1f2016-08-15 15:11:06 -040058 newContactSelected();
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040059 else
60 noContactSelected();
61 }
62 }
63
64 property Vector<Contact^>^ contactsList
65 {
66 Vector<Contact^>^ get()
67 {
68 return contactsList_;
69 }
70 }
71
72 /* events */
73 event NewContactSelected^ newContactSelected;
74 event NoContactSelected^ noContactSelected;
75
76private:
77 ContactsViewModel(); // singleton
78 Vector<Contact^>^ contactsList_;
79 Contact^ currentItem_;
80 Contact^ oldItem_;
81
82};
83}
84}