public ChatView(ViewModelBase bindingContext)
        {
            BindingContext = bindingContext;

            var chat = new SfChat
            {
                Messages    = ((ChatViewModel)BindingContext).Messages,
                CurrentUser = ((ChatViewModel)BindingContext).CurrentUser,
                ShowOutgoingMessageTimestamp  = true,
                ShowTypingIndicator           = false,
                ShowIncomingMessageAuthorName = true,
                ShowIncomingMessageTimestamp  = true,
                ShowTimeBreak = true,
                IncomingMessageTimestampFormat = "HH:mm",
                OutgoingMessageTimestampFormat = "HH:mm",
                TypingIndicator = ((ChatViewModel)BindingContext).TypingIndicator,
            };

            chat.SendMessage += (sender, args) => ((ChatViewModel)BindingContext).MessageSent(sender, args);

            var stackLayout = new StackLayout
            {
                Spacing  = 10,
                Children = { chat }
            };

            Content = stackLayout;
        }
 /// <summary>
 /// Method will be called when the view is attached to the window
 /// </summary>
 /// <param name="bindable">SampleView type parameter as bindable</param>
 protected override void OnAttachedTo(SampleView bindable)
 {
     this.sfChat    = bindable.FindByName <SfChat>("sfChat");
     this.viewModel = bindable.FindByName <FlightBookingViewModel>("viewModel");
     this.viewModel.Messages.CollectionChanged += OnMessagesCollectionChanged;
     base.OnAttachedTo(bindable);
 }
 protected override void OnDetachingFrom(MainPage bindable)
 {
     this.viewModel.Messages.CollectionChanged -= Messages_CollectionChanged;
     this.sfChat    = null;
     this.viewModel = null;
     base.OnDetachingFrom(bindable);
 }
        protected override void OnAttachedTo(MainPage bindable)
        {
            this.sfChat    = bindable.FindByName <SfChat>("sfChat");
            this.viewModel = bindable.FindByName <GettingStattedViewModel>("viewModel");
            this.viewModel.Messages.CollectionChanged += Messages_CollectionChanged;

            base.OnAttachedTo(bindable);
        }
 /// <summary>
 /// Method will be called when the view is detached from window
 /// </summary>
 /// <param name="bindable">SampleView type of bindAble parameter</param>
 protected override void OnDetachingFrom(ContentPage bindable)
 {
     this.viewModel.Messages.CollectionChanged -= OnMessagesCollectionChanged;
     Connectivity.ConnectivityChanged          -= this.viewModel.BotService.OnConnectivityChanged;
     this.sfChat    = null;
     this.viewModel = null;
     base.OnDetachingFrom(bindable);
 }
        public App()
        {
            InitializeComponent();

            SfChat sfChat = new SfChat();

            MainPage = new MainPage();
        }
Esempio n. 7
0
 public ChatPage()
 {
     InitializeComponent();
     sfChat                                = new SfChat();
     viewModel                             = new GettingStartedViewModel();
     this.sfChat.Messages                  = viewModel.Messages;
     this.sfChat.CurrentUser               = viewModel.CurrentUser;
     this.sfChat.MessageTemplate           = new MessageTemplateSelector(sfChat);
     this.sfChat.ShowIncomingMessageAvatar = true;
     this.sfChat.ShowOutgoingMessageAvatar = true;
     this.Content                          = sfChat;
 }
 /// <summary>
 /// Disposes the created instances.
 /// </summary>
 private void Dispose()
 {
     this.sfChat.Scrolled -= ChatScrolled;
     if (this.sfChat != null)
     {
         this.sfChat.Dispose();
         this.sfChat = null;
     }
     if (this.viewModel != null)
     {
         this.viewModel = null;
     }
 }
 public ChatPage()
 {
     InitializeComponent();
     sfChat                      = new SfChat();
     viewModel                   = new GettingStartedViewModel();
     this.sfChat.Messages        = viewModel.Messages;
     this.sfChat.CurrentUser     = viewModel.CurrentUser;
     this.sfChat.MessageTemplate = new ChatMessageTemplateSelector()
     {
         Chat = this.sfChat
     };
     this.Content = sfChat;
 }
        /// <summary>
        /// Method will be called when the view is detached from window
        /// </summary>
        /// <param name="bindable">SampleView type of bindAble parameter</param>
        protected override void OnDetachingFrom(SampleView bindable)
        {
            this.viewModel.Messages.CollectionChanged -= OnMessagesCollectionChanged;
            Connectivity.ConnectivityChanged          -= this.viewModel.BotService.OnConnectivityChanged;
            this.viewModel.Bot = null;
            if (this.sfChat != null)
            {
                this.sfChat.Dispose();
                this.sfChat = null;
            }
            if (this.viewModel != null)
            {
                this.viewModel = null;
            }

            base.OnDetachingFrom(bindable);
        }
Esempio n. 11
0
 private void InitViews(View sampleView = null)
 {
     if (sampleView != null)
     {
         this.loadMoreView = sampleView.FindByName <LoadMoreView>("LoadMoreView");
         this.sfChat       = loadMoreView.FindByName <SfChat>("sfChat");
         this.viewModel    = loadMoreView.FindByName <LoadMoreViewModel>("viewModel");
         this.InitBadgeView(loadMoreView.FindByName <SfBadgeView>("ScrollDown"));
         this.sfChat.Scrolled += ChatScrolled;
     }
     else
     {
         this.loadMoreView = new LoadMoreView();
         this.sfChat       = loadMoreView.FindByName <SfChat>("sfChat");
         this.viewModel    = loadMoreView.FindByName <LoadMoreViewModel>("viewModel");
         this.InitBadgeView(loadMoreView.FindByName <SfBadgeView>("ScrollDown"));
         this.sfChat.Scrolled += ChatScrolled;
     }
 }
Esempio n. 12
0
 public MessageTemplateSelector(SfChat chat) : base(chat)
 {
 }
 public MessageTemplateSelector(SfChat sfChat) : base(sfChat)
 {
     this.Chat = sfChat;
     this.ratingDataTemplate = new DataTemplate(typeof(RatingTemplate));
 }
 public MessageTemplateSelector(SfChat sfChat) : base(sfChat)
 {
     this.customMessageTemplate = new DataTemplate(typeof(CustomMessageTemplate));
 }