Esempio n. 1
0
        nfloat CalculateHeightFor(Message msg, UITableView tableView)
        {
            var index = (int)msg.Type;
            BubbleCell cell = sizingCells [index];
            if (cell == null)
                cell = sizingCells [index] = (BubbleCell)tableView.DequeueReusableCell (GetReuseId (msg.Type));

            cell.Message = msg;

            cell.SetNeedsLayout ();
            cell.LayoutIfNeeded ();
            CGSize size = cell.ContentView.SystemLayoutSizeFittingSize (UIView.UILayoutFittingCompressedSize);
            return NMath.Ceiling (size.Height) + 1;
        }
Esempio n. 2
0
        void OnSendClicked(object sender, EventArgs e)
        {
            var text = TextView.Text;
            TextView.Text = string.Empty; // this will not generate change text event
            UpdateButtonState ();

            if (string.IsNullOrWhiteSpace (text))
                return;

            var msg = new Message {
                Type = MessageType.Outgoing,
                Text = text.Trim ()
            };

            messages.Add (msg);
            tableView.InsertRows (new NSIndexPath[] { NSIndexPath.FromRowSection (messages.Count - 1, 0) }, UITableViewRowAnimation.None);
            ScrollToBottom (true);
        }