private void InitNavigationBar()
 {
     _navigationBarView = FindViewById <NavigationBarView>(Resource.Id.activity_chat_new_nav_bar);
     _navigationBarView.SetLeftButton(StyleHelper.Style.NavigationBarBackButtonIcon, ViewModel.CancelCommand);
     _navigationBarView.SetTitle(ViewModel.LocalizedStrings.NewChat);
     _navigationBarView.SetBackground(Resource.Color.chat_content_color);
 }
        protected override void DoAttachBindings()
        {
            base.DoAttachBindings();

            Bindings.Add(this.SetBinding(() => ViewModel.ConnectionStatus.ConnectionStatusText).WhenSourceChanges(() =>
            {
                Execute.BeginOnUIThread(() =>
                {
                    _navigationBarView.SetTitle(ViewModel.ConnectionStatus.ConnectionStatusText);
                });
            }));
            Bindings.Add(this.SetBinding(() => ViewModel.MessagesList.Messages).WhenSourceChanges(() =>
            {
                if (_isAdapterSourceInitialized)
                {
                    return;
                }

                _conversationsAdapter = new ConversationsObservableRecyclerViewAdapter(
                    ViewModel.MessagesList.Messages,
                    ScrollToPositionIfNeeded,
                    LoadItemsRequestedScrollChangeHandler,
                    ViewModel.GetDateString,
                    _contextMenuHandler);

                _conversationsAdapter.SetCommand(nameof(_conversationsAdapter.LastItemRequested),
                                                 ViewModel.MessagesList.LoadOlderMessagesCommand);

                _conversationsRecyclerView.SetAdapter(_conversationsAdapter);

                _isAdapterSourceInitialized = true;
            }));

            _chatInputView.BindViewModel(ViewModel.MessageInput);
        }
 private void InitNavigationBarView(View view)
 {
     _navigationBarView = view.FindViewById <NavigationBarView>(Resource.Id.dialog_select_members_nav_bar);
     _navigationBarView.SetLeftButton(StyleHelper.Style.NavigationBarBackButtonIcon, new RelayCommand(Close));
     _navigationBarView.SetRightButton(ViewModel.Resources.Done, ViewModel.DoneCommand);
     _navigationBarView.SetTitle(ViewModel.Title);
     _navigationBarView.SetBackground(StyleHelper.Style.ContentColor);
 }
Exemple #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            OverridePendingTransition(0, 0);

            SetTheme(StyleHelper.Style.CommonActivityStyle);

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_chat_details);

            _navigationBarView = FindViewById <NavigationBarView>(Resource.Id.activity_chat_details_navigation_bar);
            _navigationBarView.SetLeftButton(StyleHelper.Style.NavigationBarBackButtonIcon, ViewModel.BackCommand);
            _navigationBarView.SetTitle(ViewModel.LocalizedStrings.DetailsTitle);
            _navigationBarView.SetRightButton(ViewModel.LocalizedStrings.Save, new RelayCommand(OnSaveClick));
            _navigationBarView.RightTextButton.Visibility = ViewStates.Gone;

            _chatPhotoImageView = FindViewById <MvxCachedImageView>(Resource.Id.iv_chat_photo);

            _chatEditedPhotoImageView = FindViewById <MvxCachedImageView>(Resource.Id.iv_chat_photo_edited);

            _chatNameText     = FindViewById <TextView>(Resource.Id.activity_chat_details_chat_name);
            _chatNameEditText = FindViewById <EditText>(Resource.Id.activity_chat_details_chat_name_edit);

            _chatMembersCountTextView = FindViewById <TextView>(Resource.Id.tv_members_count);

            _addMemberContainer = FindViewById <LinearLayout>(Resource.Id.activity_chat_details_add_member_container);
            _addmemberImageView = FindViewById <ImageView>(Resource.Id.activity_chat_details_add_member_image);
            _addmemberImageView.SetImageResource(StyleHelper.Style.AddMemberIcon);
            _addMemberTextView      = FindViewById <TextView>(Resource.Id.activity_chat_details_add_member_text);
            _addMemberTextView.Text = ViewModel.LocalizedStrings.AddMembers;

            _membersRecyclerView = FindViewById <RecyclerView>(Resource.Id.rv_contacts_list);

            _changeChatPhotoButton = FindViewById <Button>(Resource.Id.b_chat_change_photo);
            _changeChatPhotoButton.SetCommand(new RelayCommand(OpenImagePicker));
            _changeChatPhotoButton.Text = ViewModel.LocalizedStrings.ChangePhoto;

            _muteNotificationsLabel      = FindViewById <TextView>(Resource.Id.activity_chat_details_mute_label);
            _muteNotificationsLabel.Text = ViewModel.LocalizedStrings.Notifications;
            _muteNotificationsSwitch     = FindViewById <SwitchCompat>(Resource.Id.activity_chat_details_mute_switch);
            _muteNotificationsSwitch.SetCommand(ViewModel.HeaderViewModel.ChangeMuteNotificationsCommand);

            InitializeMembersRecyclerView();

            // TODO YP: remove ServiceLocator
            _imagePicker = new ImagePicker(
                Dependencies.Container.Resolve <IPermissionsManager>(),
                Dependencies.Container.Resolve <IImagePickerService>())
            {
                MaxImageWidth = 300
            };

            _busyOverlayView = FindViewById <BusyOverlayView>(Resource.Id.activity_chat_details_busy_view);
        }
        protected override void DoAttachBindings()
        {
            base.DoAttachBindings();

            if (!StyleHelper.Style.UseLogoInsteadOfConnectionStatus)
            {
                Bindings.Add(this.SetBinding(() => ViewModel.ConnectionStatusViewModel.ConnectionStatusText).WhenSourceChanges(() =>
                {
                    Execute.BeginOnUIThread(() =>
                    {
                        _navigationBarView.SetTitle(ViewModel.ConnectionStatusViewModel.ConnectionStatusText);
                    });
                }));
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            OverridePendingTransition(0, 0);

            SetTheme(StyleHelper.Style.CommonActivityStyle);

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_chat_create);

            _navigationBarView = FindViewById <NavigationBarView>(Resource.Id.activity_chat_create_navigation_bar);
            _navigationBarView.SetLeftButton(StyleHelper.Style.NavigationBarBackButtonIcon, ViewModel.BackCommand);
            _navigationBarView.SetTitle(ViewModel.LocalizedStrings.CreateGroup);
            _navigationBarView.SetRightButton(ViewModel.LocalizedStrings.Create, new RelayCommand(() =>
            {
                KeyboardService.HideSoftKeyboard(_chatNameEditTextView);

                ViewModel.SaveCommand.Execute(_imagePicker.GetStreamFunc());
            }));
            _navigationBarView.RightTextButton.SetBackgroundColor(Color.Transparent);

            _chatPhotoImageView       = FindViewById <MvxCachedImageView>(Resource.Id.iv_chat_photo);
            _chatEditedPhotoImageView = FindViewById <MvxCachedImageView>(Resource.Id.iv_chat_photo_edited);
            _chatNameEditTextView     = FindViewById <EditText>(Resource.Id.et_chat_name);
            _contactsRecyclerView     = FindViewById <RecyclerView>(Resource.Id.rv_contacts_list);
            _membersCountTextView     = FindViewById <TextView>(Resource.Id.tv_members_count);
            _changeChatPhotoButton    = FindViewById <Button>(Resource.Id.b_chat_change_photo);
            _changeChatPhotoButton.SetCommand(new RelayCommand(ChangePhoto));
            _changeChatPhotoButton.Text = ViewModel.LocalizedStrings.ChangePhoto;

            InitializeContactsRecyclerView();

            _imagePicker = new ImagePicker(Dependencies.PermissionsManager, Dependencies.Container.Resolve <IImagePickerService>())
            {
                MaxImageWidth = 300
            };

            _chatPhotoImageView.SetImageResource(StyleHelper.Style.ChatGroupNoAvatarIcon);
            _chatEditedPhotoImageView.Visibility = ViewStates.Gone;

            _addMembers      = FindViewById <Button>(Resource.Id.activity_chat_create_add_member);
            _addMembers.Text = ViewModel.LocalizedStrings.AddMembers;
            _addMembers.SetCommand(ViewModel.AddMembersCommand);

            _chatNameEditTextView.Hint = ViewModel.LocalizedStrings.ChatName;

            _busyOverlayView = FindViewById <BusyOverlayView>(Resource.Id.activity_chat_create_busy_view);
        }