diff --git a/ContactsViewModel.cpp b/ContactsViewModel.cpp index 0aa9aed0a0380924d0fededcc2845727d5b1ff11..1519fad990dd88f599844a8ec2f3aa6698d7a4d4 100644 --- a/ContactsViewModel.cpp +++ b/ContactsViewModel.cpp @@ -50,7 +50,7 @@ ContactsViewModel::ContactsViewModel() return; } - screenConversationMessage("" /* accountId not used yet at this stage */, from, payload); + contact->_conversation->addMessage(""/* date not yet used*/, MSG_FROM_CONTACT, payload); if (contact->ringID_ == from && isNotSelected) notifyNewConversationMessage(); diff --git a/Conversation.cpp b/Conversation.cpp index 5e64a7ed1fba13b1ab55434c3289aed1302640f8..b3444b91ac966fc2f4532e94fc1c1beaa50e9901 100644 --- a/Conversation.cpp +++ b/Conversation.cpp @@ -28,6 +28,7 @@ using namespace RingClientUWP; Conversation::Conversation() { + messagesList_ = ref new Vector<ConversationMessage^>(); } void @@ -40,4 +41,9 @@ Conversation::addMessage(String^ date, bool fromContact, String^ payload) std::string owner((fromContact) ? "from contact" : " from me"); MSG_("{Conversation::addMessage}"); MSG_("owner = " + owner); + + /* add message to _messagesList_ */ + messagesList_->Append(message); + + // TODO store message on the disk } diff --git a/Conversation.h b/Conversation.h index 7717330bb796b3367ad99dd10c84a78d7be93c3d..22e6831dc997eb422c47110390868ef36af02cf8 100644 --- a/Conversation.h +++ b/Conversation.h @@ -36,11 +36,23 @@ private: public: + /* functions */ Conversation(); void addMessage(String^ date, bool fromContact, String^ payload); +internal: + /* properties */ + property Vector<ConversationMessage^>^ _messages + { + Vector<ConversationMessage^>^ get() + { + return messagesList_; + } + } + private: - Vector<ConversationMessage^> messages; + /* members */ + Vector<ConversationMessage^>^ messagesList_; }; #define MSG_FROM_CONTACT true diff --git a/MessageTextPage.xaml b/MessageTextPage.xaml index b505878bf3628667da3aa612cdc660073b67273d..19aefd9ed1863f389c5daea5b7789bcf8261ee80 100644 --- a/MessageTextPage.xaml +++ b/MessageTextPage.xaml @@ -9,20 +9,11 @@ mc:Ignorable="d"> <Page.Resources> - <!--<DataTemplate x:Key="MessageTemplate" x:DataType="local:RingInstantMessage"> + <DataTemplate x:Key="ConversationMessageTemplate" x:DataType="local:ConversationMessage"> <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="70" /> - <ColumnDefinition /> - </Grid.ColumnDefinitions> - <Image x:Name="_contactAvatar_" - Margin="2,2" - Source="ms-appx:///contact-avatar-test.png" - VerticalAlignment="Center" HorizontalAlignment="Center"/> - <TextBlock x:Name="_msgContent_" Text="{x:Bind msg_}"/> + <TextBlock x:Name="_msgContent_" Text="{x:Bind Payload}"/> </Grid> - </DataTemplate>--> - + </DataTemplate> <!-- barre d'envoi de message --> <Style TargetType="TextBox"> @@ -121,7 +112,10 @@ Grid.Row="1"> <StackPanel x:Name="_messagesWindowOutput_" Background="#FFF2F2F2"> - + <ListBox x:Name="_messagesList_" + Margin="0" + Padding="0" + ItemTemplate="{StaticResource ConversationMessageTemplate}"/> </StackPanel> </ScrollViewer> <Grid Height="50" diff --git a/MessageTextPage.xaml.cpp b/MessageTextPage.xaml.cpp index c32650428d22bd1b97ac0d7ba2f24354a1ba63fb..3def2afedfb1707aa93cc9709c2ab3dd28785146 100644 --- a/MessageTextPage.xaml.cpp +++ b/MessageTextPage.xaml.cpp @@ -40,6 +40,12 @@ using namespace Windows::UI::Xaml::Navigation; MessageTextPage::MessageTextPage() { InitializeComponent(); + + /* connect delegates. */ // may be useless + RingD::instance->incomingAccountMessage += ref new IncomingAccountMessage([&](String^ accountId, + String^ from, String^ payload) { + }); + } void @@ -57,7 +63,8 @@ RingClientUWP::Views::MessageTextPage::updatePageContent() _title_->Text = contact->name_; - _messagesWindowOutput_->Children->Clear(); + _messagesList_->ItemsSource = contact->_conversation->_messages; + } void