コード例 #1
0
        void SetUpToolbar()
        {
            toolbar = new UIToolbar
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            chatInputView = new ChatInputView
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            toolbar.LayoutIfNeeded();
            View.AddSubview(toolbar);


            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {   // iPhone X layout
                var safeGuide = View.SafeAreaLayoutGuide;
                toolbar.HeightAnchor.ConstraintEqualTo(44).Active = true;
                toolbar.LeadingAnchor.ConstraintEqualTo(safeGuide.LeadingAnchor).Active   = true;
                toolbar.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor).Active = true;
                toolbarBottomConstraint        = toolbar.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor);
                toolbarBottomConstraint.Active = true;
            }
            else
            {
                var pinLeft = NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f);
                View.AddConstraint(pinLeft);

                var pinRight = NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f);
                View.AddConstraint(pinRight);

                toolbarBottomConstraint = NSLayoutConstraint.Create(View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, toolbar, NSLayoutAttribute.Bottom, 1f, 0f);
                View.AddConstraint(toolbarBottomConstraint);

                toolbarHeightConstraint = NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 0f, 44f);
                View.AddConstraint(toolbarHeightConstraint);
            }

            toolbar.AddSubview(chatInputView);

            var c1 = NSLayoutConstraint.FromVisualFormat("H:|[chat_container_view]|",
                                                         0,
                                                         "chat_container_view", chatInputView
                                                         );
            var c2 = NSLayoutConstraint.FromVisualFormat("V:|[chat_container_view]|",
                                                         0,
                                                         "chat_container_view", chatInputView
                                                         );

            toolbar.AddConstraints(c1);
            toolbar.AddConstraints(c2);
        }
コード例 #2
0
        public void InitModule()
        {
            mTitleContainer = FindViewById <LinearLayout>(Resource.Id.title_container);
            mTitle          = FindViewById <TextView>(Resource.Id.title_tv);
            mMsgList        = FindViewById <MessageList>(Resource.Id.msg_list);
            mChatInput      = FindViewById <ChatInputView>(Resource.Id.chat_input);
            mPtrLayout      = FindViewById <PullToRefreshLayout>(Resource.Id.pull_to_refresh_layout);

            mChatInput.SetMenuContainerHeight(819);
            mRecordVoiceBtn = mChatInput.RecordVoiceButton;
            mSelectAlbumIb  = mChatInput.SelectAlbumBtn;
            PtrDefaultHeader header = new PtrDefaultHeader(Context);

            int[] colors = Resources.GetIntArray(Resource.Array.google_colors);
            header.SetColorSchemeColors(colors);
            header.LayoutParameters = new ViewGroup.LayoutParams(-1, -2);
            header.SetPadding(0, DisplayUtil.Dp2px(Context, 15), 0, DisplayUtil.Dp2px(Context, 10));
            header.SetPtrFrameLayout(mPtrLayout);

            //        mMsgList.setDateBgColor(Color.parseColor("#FF4081"));
            //        mMsgList.setDatePadding(5, 10, 10, 5);
            //        mMsgList.setEventTextPadding(5);
            //        mMsgList.setEventBgColor(Color.parseColor("#34A350"));
            //        mMsgList.setDateBgCornerRadius(15);

            mMsgList.HasFixedSize = true;
            mPtrLayout.SetLoadingMinTime(1000);
            mPtrLayout.SetDurationToCloseHeader(1500);
            mPtrLayout.HeaderView = header;
            mPtrLayout.AddPtrUIHandler(header);

            mPtrLayout.PinContent = true;
            // set show display name or not
            //        mMsgList.setShowReceiverDisplayName(true);
            //        mMsgList.setShowSenderDisplayName(false);

            CN.Jiguang.Imui.Chatinput.Menu.MenuManager menuManager = mChatInput.MenuManager;
            menuManager.AddCustomMenu("MY_CUSTOM", Resource.Layout.menu_text_item, Resource.Layout.menu_text_feature);

            // Custom menu order
            menuManager.SetMenu(CN.Jiguang.Imui.Chatinput.Menu.Menu.NewBuilder()
                                .Customize(true)
                                .SetRight(CN.Jiguang.Imui.Chatinput.Menu.Menu.TagSend)
                                .SetBottom(CN.Jiguang.Imui.Chatinput.Menu.Menu.TagVoice,
                                           CN.Jiguang.Imui.Chatinput.Menu.Menu.TagEmoji,
                                           CN.Jiguang.Imui.Chatinput.Menu.Menu.TagGallery,
                                           CN.Jiguang.Imui.Chatinput.Menu.Menu.TagCamera, "MY_CUSTOM")
                                .Build());

            menuManager.SetCustomMenuClickListener(new CustomMenuEventListener());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            OverridePendingTransition(0, 0);

            SetTheme(StyleHelper.Style.CommonActivityStyle);

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_chat_conversations);

            _navigationBarView = FindViewById <NavigationBarView>(Resource.Id.activity_chat_conversations_navigation_bar);
            _navigationBarView.SetLeftButton(StyleHelper.Style.NavigationBarBackButtonIcon, ViewModel.BackCommand);
            if (ViewModel.HasInfo)
            {
                _navigationBarView.SetRightButton(StyleHelper.Style.NavigationBarDetailsButtonIcon, ViewModel.ShowInfoCommand);
            }

            _conversationsRecyclerView = FindViewById <RecyclerView>(Resource.Id.rv_conversations_list);

            _scrollDownImageButton = FindViewById <ImageButton>(Resource.Id.ib_conversations_scroll_down);
            _scrollDownImageButton.SetImageResource(StyleHelper.Style.ScrollDownButtonIcon);

            _chatInputView = FindViewById <ChatInputView>(Resource.Id.ll_chat_input_view);

            InitializeConversationsRecyclerView();

            _contextMenuHandler = new ContextMenuHandler <ChatMessageViewModel>(itemViewModel =>
            {
                var commandActions = ViewModel.GetCommandActionsForMessage(itemViewModel);
                return(new ContextMenuComponent(commandActions));
            });

            _scrollDownImageButton.SetCommand(nameof(_scrollDownImageButton.Click), new RelayCommand(ScrollToBottom));

            ViewModel.MessageAddedCommand = new RelayCommand(ScrollToBottomIfNeeded);
        }
コード例 #5
0
        void SetUpToolbar()
        {
            toolbar = new UIToolbar {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            chatInputView = new ChatInputView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            View.AddSubview (toolbar);

            var pinLeft = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f);
            View.AddConstraint (pinLeft);

            var pinRight = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f);
            View.AddConstraint (pinRight);

            toolbarBottomConstraint = NSLayoutConstraint.Create (View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, toolbar, NSLayoutAttribute.Bottom, 1f, 0f);
            View.AddConstraint (toolbarBottomConstraint);

            toolbarHeightConstraint = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 0f, 44f);
            View.AddConstraint (toolbarHeightConstraint);

            toolbar.AddSubview (chatInputView);

            var c1 = NSLayoutConstraint.FromVisualFormat ("H:|[chat_container_view]|",
                (NSLayoutFormatOptions)0,
                "chat_container_view", chatInputView
            );
            var c2 = NSLayoutConstraint.FromVisualFormat ("V:|[chat_container_view]|",
                (NSLayoutFormatOptions)0,
                "chat_container_view", chatInputView
            );
            toolbar.AddConstraints (c1);
            toolbar.AddConstraints (c2);
        }