Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CustomNavigationBar.TintColor = StyleHelper.Style.AccentColor;
            if (StyleHelper.Style.UseLogoInsteadOfConnectionStatus)
            {
                var titleImage = new UIImageView
                {
                    Image = UIImage.FromBundle(StyleHelper.Style.LogoBoundleName)
                };
                CustomNavigationItem.AddTitleView(titleImage);
            }
            else
            {
                _customTitleView = new ConnectionStatusView(CGRect.Empty);
                CustomNavigationItem.AddTitleView(_customTitleView);
            }
            CustomNavigationItem.SetCommand(UIBarButtonSystemItem.Add, ViewModel.CreateChatCommand, false);

            ChatsTableView.RegisterNibForCellReuse(ChatSummaryViewCell.Nib, ChatSummaryViewCell.Key);
            ChatsTableView.RowHeight       = 80;
            ChatsTableView.TableFooterView = new UIView();

            var source = ViewModel.Chats.GetTableViewSource((cell, viewModel, index) =>
            {
                (cell as ChatSummaryViewCell).BindViewModel(viewModel);
            }, ChatSummaryViewCell.Key);

            ChatsTableView.Source   = source;
            ChatsTableView.Delegate = new CustomViewDelegate(source, ViewModel);
            _sourceRef = WeakReferenceEx.Create(source);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _customTitleView = new ConnectionStatusView(CGRect.Empty);

            TableNode = new ASTableNode(UITableViewStyle.Grouped);
            Table     = TableNode.View;

            Input = new ChatInputView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            Input.Init(this);

            CustomNavigationItem.AddTitleView(_customTitleView);
            CustomNavigationItem.SetCommand(
                UIImage.FromBundle(StyleHelper.Style.BackButtonBundleName),
                ViewModel.BackCommand,
                true);

            if (ViewModel.HasInfo)
            {
                CustomNavigationItem.SetCommand(
                    UIImage.FromBundle(StyleHelper.Style.ChatDetailsButtonBundleName),
                    ViewModel.ShowInfoCommand,
                    false);
            }

            MainView.InsertSubview(Table, 1);
            InitTableView();

            _contextMenuHandler = new ContextMenuHandler <ChatMessageViewModel>(CreateContextMenuComponentForViewModel);

            Input.EditingCloseButton.SetCommand(ViewModel.MessageInput.CancelEditingCommand);
            Input.OpenCameraButton.SetCommand(ViewModel.MessageInput.OpenCameraCommand);
            Input.OpenGalleryButton.SetCommand(ViewModel.MessageInput.OpenGalleryCommand);
            Input.SendButton.SetCommand(ViewModel.MessageInput.SendMessageCommand);
            Input.DeleteButton.SetCommand(ViewModel.MessageInput.DeleteImageCommand);
            Input.SetLabels(
                ViewModel.MessageInput.EditMessageHeaderString,
                ViewModel.MessageInput.EnterMessagePlaceholderString);

            ScrollToBottomButton.SetCommand(new RelayCommand(() => ScrollToBottom(true)));
            ScrollToBottomButton.SetBackgroundImage(UIImage.FromBundle(StyleHelper.Style.ScrollDownBoundleName), UIControlState.Normal);
        }